Auth Sessions API
The Auth Sessions API lets a logged-in user list, inspect and revoke their auth sessions, one per device or browser they logged in from.
For how sessions, tokens and rotation work, see the Sessions documentation.
Base Endpoint
/api/auth/sessionsEndpoints
| Method | Endpoint | Description | |
|---|---|---|---|
| GET | /api/auth/sessions/current | Get the session of the current request | |
| GET | /api/auth/sessions/{sid} | Get a session by ID | |
| DELETE | /api/auth/sessions/{sid}/revoke | Revoke a session | |
| GET | /api/auth/sessions?query | List and filter by URI parameters | Similar to Entities API |
| POST | /api/auth/sessions/search | Search sessions by POST | Similar to Entities API |
| GET | /api/auth/sessions/count | Count sessions | Similar to Entities API |
| POST | /api/auth/sessions/count | Count filtered sessions | Similar to Entities API |
Access rules
- These endpoints require a user session (JWT bearer token or cookie session). Requests authenticated with an API key get
401 Only user authentication can manage sessions. - Regular users only see and revoke their own sessions.
- Users with the
BSH_ADMINrole see and can revoke the sessions of every user. - Cookie sessions must send the
X-XSRF-TOKENheader onPOSTandDELETErequests here.
Session object
{
"sid": "4c0f7a1e-2f6b-4d5e-9a63-7f1f0b0e9c2d",
"sub": "user-id",
"iat": { "$date": 1794045600000 },
"exp": { "$date": 1796637600000 },
"status": "Active",
"metadata": {
"label": "Chrome 131 on macOS",
"browser": "Chrome",
"browserVersion": "131",
"os": "macOS",
"device": "Desktop",
"client": "My App",
"userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36"
},
"current": true,
"CreatedAt": { "$date": 1794045600000 },
"LastUpdatedAt": { "$date": 1794046500000 }
}| Field | Description |
|---|---|
sid | Session ID |
sub | ID of the user who owns the session |
iat | When the session was created or last refreshed (UTC) |
exp | When the session ends at the latest (UTC), see auth.config.sessionTtl |
status | Active, Expired, Revoked, LoggedOut or Blocked. See Lifecycle. |
reason | Why the session was closed, when the engine closed it itself. |
metadata | Device and app captured at login (browser, OS, device type, X-Bsh-Client name). Every field is optional. See Device details. |
current | true when this is the session used by the request |
Last updated on