POST /api/auth/refresh
Exchange a valid refresh token for a new access token. Use this endpoint when your access token expires to maintain authenticated sessions without requiring the user to log in again.Request Body
Valid refresh token received from login or registration
Response
Indicates if the request was successful
Error Responses
401 Unauthorized - Invalid Token
Returned when the refresh token is invalid, expired, or malformed.
401 Unauthorized - User Not Found
Returned when the user associated with the token no longer exists or is inactive.
Example Request
Example Response
Token Lifecycle
- Initial Authentication: User logs in and receives both access and refresh tokens
- API Requests: Client uses access token in
Authorizationheader - Token Expiration: When access token expires, API returns 401
- Token Refresh: Client calls this endpoint with refresh token to get new access token
- Continue: Client continues making requests with new access token
Best Practices
- Store refresh tokens securely (httpOnly cookies or secure storage)
- Implement automatic token refresh before access token expires
- Handle 401 errors by attempting to refresh before prompting re-login
- Refresh tokens are valid for 7 days from issuance
- Logging out invalidates all refresh tokens for the user