Skip to main content

Logout

Logout the currently authenticated user and invalidate their JWT token.
This endpoint requires authentication. Include the JWT token in the Authorization header.

Endpoint

POST /auth/logout

Authentication

This endpoint requires a valid JWT token in the Authorization header:
Authorization: Bearer {token}

Request

No request body parameters required.

Response

success
boolean
Indicates whether the request was successful
message
string
Success message indicating the user logged out successfully

Example Request

curl -X POST https://api.example.com/auth/logout \
  -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9..." \
  -H "Content-Type: application/json"

Example Response

{
  "success": true,
  "message": "User logged out successfully"
}

Error Responses

{
  "success": false,
  "message": "User already logged out"
}
{
  "success": false,
  "message": "Unauthenticated."
}
{
  "success": false,
  "message": "Token has expired"
}
{
  "success": false,
  "message": "Unauthenticated."
}

Build docs developers (and LLMs) love