Revoke the current access token and log out the authenticated user.
Authentication
This endpoint requires authentication. Include a valid Bearer token in the Authorization header.
Authorization: Bearer YOUR_ACCESS_TOKEN
Request
This endpoint does not require any request body parameters. The token to revoke is identified from the Authorization header.
Response
Confirmation message indicating successful logout
Code Examples
curl -X POST https://api.example.com/api/v1/auth/logout \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json"
Response Examples
Success Response
{
"message": "Logout exitoso"
}
Error Responses
401 Unauthorized - Missing or Invalid Token
{
"message": "Unauthenticated."
}
Token Revocation
When you logout, only the current access token is revoked. If the user has other active tokens from different sessions or devices, those tokens will remain valid.
After logout, the revoked token cannot be used for any further API requests. You must login again to obtain a new token.
Best Practices
- Always call this endpoint when the user explicitly logs out of your application
- Clear the stored token from your client application after successful logout
- Handle 401 errors gracefully by redirecting users to the login page
- Consider implementing token refresh mechanisms for long-running applications