Skip to main content

POST /api/auth/logout

Ends the current user session by invalidating the authentication tokens.

Authentication

Required. Include the access token in the Authorization header.

Request Headers

Authorization
string
required
Bearer token for authenticationExample: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

Request Body

No request body required.

Response Fields

message
string
Success message confirming the session was closed

Example Request

curl -X POST https://api.example.com/api/auth/logout \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Example Response

{
  "message": "Sesión cerrada exitosamente"
}

Error Responses

400 Bad Request

Logout operation failed:
{
  "error": "Error message from authentication service"
}

401 Unauthorized

Missing or invalid authentication token:
{
  "error": "No autorizado"
}

500 Internal Server Error

{
  "error": "Error en el servidor"
}
After logout, the access token and refresh token will be invalidated and cannot be used for further requests.
Make sure to clear any stored tokens from the client side after logout to prevent unauthorized access.

Build docs developers (and LLMs) love