GET /api/auth/logout
Logs out the current authenticated user by destroying their session.Authentication
This endpoint requires authentication. The user must have an active session.Request
No request body or query parameters required.Response
Indicates whether the logout was successful. Always returns
true on success.Behavior
- Retrieves the current user’s session
- Deletes the session from the database
- Destroys the session cookie
- Logs the logout event with user information and IP address
Error Responses
401 Unauthorized- No active session or invalid authentication403 Forbidden- User does not have permission to perform this action
Example Request
Example Request (Using API Token)
Example Response
Notes
- This endpoint uses the GET method (not POST)
- Only destroys the current session, not all user sessions
- After logout, the user must authenticate again to access protected endpoints
- The session cookie is cleared in the response