Skip to Content
🎉 BSH Engine v0.0.7 is out with new features and improvements. See what's new →

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/sessions

Endpoints

MethodEndpointDescription
GET/api/auth/sessions/currentGet the session of the current request
GET/api/auth/sessions/{sid}Get a session by ID
DELETE/api/auth/sessions/{sid}/revokeRevoke a session
GET/api/auth/sessions?queryList and filter by URI parametersSimilar to Entities API
POST/api/auth/sessions/searchSearch sessions by POSTSimilar to Entities API
GET/api/auth/sessions/countCount sessionsSimilar to Entities API
POST/api/auth/sessions/countCount filtered sessionsSimilar 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_ADMIN role see and can revoke the sessions of every user.
  • Cookie sessions must send the X-XSRF-TOKEN header on POST and DELETE requests 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 } }
FieldDescription
sidSession ID
subID of the user who owns the session
iatWhen the session was created or last refreshed (UTC)
expWhen the session ends at the latest (UTC), see auth.config.sessionTtl
statusActive, Expired, Revoked, LoggedOut or Blocked. See Lifecycle.
reasonWhy the session was closed, when the engine closed it itself.
metadataDevice and app captured at login (browser, OS, device type, X-Bsh-Client name). Every field is optional. See Device details.
currenttrue when this is the session used by the request
Last updated on