Base URL
Authentication flow
The Authentication API uses a dual-token system for secure session management:- Access Token - Short-lived JWT token (included in
Authorizationheader) - Refresh Token - Long-lived token for rotating access tokens
Standard authentication flow
Registration flow
- Client submits email and password to
/auth/register - Server creates user account with
CUSTOMERrole - Server returns access token and refresh token
- Email verification is pending (user can still authenticate)
Login flow
- Client submits credentials to
/auth/login - Server validates credentials and account status
- Server creates session with device tracking
- Server returns JWT tokens for session
Token refresh flow
- Client detects access token expiration
- Client submits refresh token to
/auth/refresh-token - Server validates refresh token and session
- Server rotates both tokens (old tokens invalidated)
- Server returns new access token and refresh token
JWT token structure
Access tokens are JWTs containing user claims:Security headers
All authenticated endpoints require theAuthorization header:
Session tracking
The API tracks sessions using:- Device ID - Optional client-provided identifier
- User-Agent - Browser/client information (from header)
- IP Address - Client IP (supports
X-Forwarded-For)
- Multi-device session management
- Security audit logging
- Selective logout (single device vs all devices)
User roles
The Authentication API supports four user roles:CUSTOMER- Default role for registered usersVENDOR- Marketplace seller accountsADMIN- Administrative accessSUPER_ADMIN- Full system access
Account status
User accounts can have three status values:ACTIVE- Account is active and can authenticateLOCKED- Account is locked (returns 423 on login)SUSPENDED- Account is suspended
Error handling
The API uses standard HTTP status codes:| Status | Description |
|---|---|
200 | Request successful |
201 | Resource created (registration) |
400 | Invalid request payload |
401 | Invalid credentials or unauthorized |
403 | Email not verified |
423 | Account locked |
Rate limiting
Authentication endpoints implement rate limiting to prevent brute force attacks. Consider implementing:- Login attempt throttling per IP address
- Registration limits per IP/email domain
- Token refresh frequency limits
Next steps
Endpoint reference
Detailed documentation for all authentication endpoints
Security best practices
Learn how to secure your authentication implementation