Revokes the user’s refresh token and ends their session. This endpoint invalidates the provided refresh token, preventing it from being used to obtain new access tokens.
Authentication
Requires a valid access token in the Authorization header.
Request Body
The refresh token to revoke. If not provided, the endpoint will still return success. Validation : Must be a non-empty string if provided.
Providing the refresh token is optional but recommended to ensure the token is properly revoked on the server side.
Response
Always returns true on successful logout.
Example Request
curl -X POST https://api.rs-tunnel.example.com/v1/auth/logout \
-H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." \
-H "Content-Type: application/json" \
-d '{
"refreshToken": "hashed_refresh_token_string"
}'
Example Response
{
"code" : "MISSING_AUTH" ,
"message" : "Missing bearer access token."
}
{
"code" : "INVALID_INPUT" ,
"message" : "Invalid logout request payload."
}
Error Codes
Code HTTP Status Description MISSING_AUTH401 Authorization header missing or malformed INVALID_AUTH401 Access token expired or invalid INVALID_INPUT400 Request body validation failed
Implementation Notes
The logout endpoint requires authentication to prevent unauthorized token revocation
Calling logout with an already-revoked refresh token will still return success
After logout, the access token remains valid until it expires (default: 15 minutes)
Best practice: Delete both access and refresh tokens from client storage after logout
Always clear both the access token and refresh token from your client storage after calling logout, even if the request fails.
Client-Side Cleanup
After successful logout, ensure you:
Delete the access token from memory/storage
Delete the refresh token from memory/storage
Clear any cached user profile data
Redirect the user to the login page or unauthenticated state
Refresh Token Obtain a new access token using a refresh token
Token Exchange Exchange login code for initial tokens