Authentication

Invalidate session

Revoke an active access token to log out a user and end their session.

The Invalidate Session endpoint allows you to log out a user by revoking their active access and refresh tokens. This ensures that the session can no longer be used to authenticate API requests.

Endpoint

DELETE /v1/auth/session

Headers

Key

Value

Required

Content-Type

application/json

Yes

Authorization

Bearer <access_token>

Yes

Request Body

Optional, depending on whether you want to target a specific session or all sessions.

{
  "session_id": "optional_session_id"
}

Field

Type

Description

session_id

string

If provided, only the specified session is invalidated. If omitted, the current session is invalidated.

Response

Successful Response (200 OK)

{
  "message": "Session invalidated successfully.",
  "session_id": "optional_session_id"
}

Field

Type

Description

message

string

Confirmation message.

session_id

string

The ID of the invalidated session (if provided).

Error Response (401 / 404)

{
  "error": "invalid_session",
  "message": "Session not found or already invalidated."
}

Error Code

Meaning

unauthorized

Missing or invalid access token.

invalid_session

The session does not exist or is already invalid.

Example Usage

cURL

curl -X DELETE "https://api.example.com/v1/auth/session" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your_access_token" \
  -d '{
    "session_id": "1234567890"
  }'

JavaScript (Fetch)

const response = await fetch("https://api.example.com/v1/auth/session", {
  method: "DELETE",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer your_access_token"
  },
  body: JSON.stringify({ session_id: "1234567890" })
});

const data = await response.json();
console.log(data.message);

Use this endpoint when a user logs out or if you need to revoke a compromised session. For security, all tokens tied to the invalidated session are immediately unusable.

Need help? Contact Support

Questions? Contact Sales

On this page

Create a free website with Framer, the website builder loved by startups, designers and agencies.