POST /api/v2/logout
Log out the current user and invalidate their access token.Headers
Bearer token or JWT token from login response
application/json
Authentication
This endpoint requires authentication. The user’s JWT token must be provided in the Authorization header.Response
“Successfully Logged Out.”
How It Works
- Token is extracted from Authorization header
- Token is marked as blocked in
user_token_logstable - Token is added to Redis blacklist for fast validation
- Blacklist entry expires after configured time (
REDIS_BLACKLIST_OBJECT_EXPIRY_IN_SEC)
Code Examples
Error Responses
401 Unauthorized- No Authorization header is provided
- Token is invalid or expired
- Token is already blacklisted
POST /api/v2/logout-all-device
Log out user from all devices by invalidating all active tokens.Headers
Bearer token from login
application/json
Authentication
Requires valid JWT token in Authorization header.Response
“Successfully Logged Out From All Device.”
How It Works
- Retrieves all active (non-blocked) tokens for the user
- Adds all tokens to Redis blacklist
- Marks all tokens as blocked in
user_token_logstable - User must re-authenticate on all devices
Code Examples
Use Cases
- User suspects unauthorized access
- Password was changed
- Security policy requires re-authentication
- User wants to revoke all active sessions
POST /api/v2/lgt-all
Internal endpoint to log out a user from all devices (Laravel integration). Access: Internal use only - requires APP_ID and APP_KEY authentication.Headers
application/json
Request Body
User ID to log out
Application ID (validated against settings)
Application secret key (validated against settings)
Response
“Successfully Logged Out From All Device.”
Error Responses
401 Unauthorized (Missing User ID)Code Examples
Security Notes
- This endpoint is for internal service-to-service communication
- APP_ID and APP_KEY are validated against server configuration
- Should not be exposed to public/client applications
- Logs out user from ALL devices without exception
Token Blacklisting
All logout endpoints use a dual-layer approach:- Database Layer: Tokens marked as blocked in
user_token_logstable - Cache Layer: Tokens added to Redis blacklist for fast validation
Blacklist Expiration
Blacklisted tokens expire from Redis afterREDIS_BLACKLIST_OBJECT_EXPIRY_IN_SEC (typically matches JWT expiration time).
Token Validation Flow
Best Practices
Client-Side
- Clear local storage: Remove token from localStorage/sessionStorage after logout
- Clear cookies: Remove any authentication cookies
- Redirect: Send user to login page after successful logout
- Handle errors: Display error if logout fails
Example Client Implementation
Server-Side
- Always validate tokens: Check blacklist before processing requests
- Set appropriate TTL: Match blacklist expiry to token expiry
- Monitor failed attempts: Log repeated logout failures
- Clean up old data: Periodically remove expired token logs