Overview
This page documents endpoints for managing authentication tokens and retrieving the current authenticated user’s information.Refresh Access Token
Refresh an expired access token using a valid refresh token. This endpoint returns new access and refresh tokens.Request Body
Valid refresh token obtained from the login endpoint.
Response
New JWT access token for API requests.
New refresh token. The old refresh token is automatically revoked.
Token type. Always
"bearer".Access token expiration time in seconds (default: 1800).
Example Request
Example Response
Error Responses
401 Unauthorized
Returned when the refresh token is invalid, expired, or revoked.500 Internal Server Error
Token Rotation
When you refresh your tokens:- The old refresh token is immediately revoked
- A new access token is generated (expires in 30 minutes)
- A new refresh token is generated (expires in 7 days)
- Device information and IP address are updated
Get Current User
Retrieve information about the currently authenticated user. Requires a valid access token.Headers
Bearer token with valid access token.Format:
Bearer <access_token>Response
Unique identifier for the user.
User’s email address.
User’s full name.
Whether the user account is active.
Whether the user’s email has been verified.
Timestamp when the user account was created.
Example Request
Example Response
Error Responses
401 Unauthorized
Returned when the access token is missing, invalid, or expired.403 Forbidden
Returned when the user account is inactive.Authentication Flow
Using Access Tokens
Include the access token in theAuthorization header for all authenticated requests:
Handling Token Expiration
- Make authenticated API request with access token
- If you receive a 401 error, the access token may be expired
- Call
/api/auth/refreshwith your refresh token - Receive new access and refresh tokens
- Retry the original request with the new access token
- Store the new refresh token for future use
JWT Token Details
Access Token Payload:- Algorithm: HS256 (HMAC with SHA-256)
- Access Token Expiration: 30 minutes (1800 seconds)
- Refresh Token Expiration: 7 days
- Refresh Token Storage: SHA-256 hashed
Logout
Invalidate the current refresh token, effectively logging out the user. The access token will continue to work until it expires (30 minutes), but cannot be refreshed.Authentication
Requires valid JWT access token in Authorization header.Request Body
The refresh token to invalidate.
Response
Confirmation message.
Always
true on successful logout.Example Request
cURL
Example Response
After logout, the refresh token is permanently invalidated. The user must login again to obtain new tokens.
Error Responses
| Status | Description |
|---|---|
| 400 | Bad Request - Missing refresh token |
| 401 | Unauthorized - Invalid or expired access token |
| 404 | Not Found - Refresh token not found or already revoked |
| 500 | Internal Server Error |
Token Details
JWT Token Format
Access tokens are JWT tokens with the following structure: Header:Token Lifetimes
- Access Token Expiration: 30 minutes (1800 seconds)
- Refresh Token Expiration: 7 days
- Refresh Token Storage: SHA-256 hashed
Security Best Practices
- Store tokens securely (never in localStorage for web apps)
- Always use HTTPS in production
- Implement token refresh before expiration
- Handle token expiration gracefully
- Call the logout endpoint when users log out
- Clear tokens from storage after logout