Skip to main content

Endpoint

POST /api/auth/logout
Logs out the user by invalidating the refresh token in the database and clearing the refresh token cookie.

Request

This endpoint optionally uses the refresh_token cookie if present. No request body is needed.

Response

message
string
Success message confirming logout

Success response

"Logged out"
The response also clears the refresh_token cookie by setting its Max-Age to 0.

Behavior

  • If a refresh token cookie is present, it will be invalidated in the database
  • The refresh token cookie is cleared by setting an expired cookie
  • The endpoint succeeds even if no refresh token is provided

Example request

curl -X POST https://api.brautcloud.com/api/auth/logout \
  -H "Content-Type: application/json" \
  -b cookies.txt \
  -c cookies.txt
The -b cookies.txt flag sends the refresh token cookie (if available), and -c cookies.txt saves the cleared cookie.

Status codes

CodeDescription
200Logout successful

Build docs developers (and LLMs) love