Get current session
Method and path
Authentication
Authentication is determined by checking (in order):Cookieheader containing an Ory Kratos session cookieAuthorization: bearer <session-token>headerX-Session-Tokenheader
Request parameters
Returns the session additionally as a token (such as JWT). The value must be a valid, configured Ory Session token template. See session to JWT documentation for more information.
Session token for non-browser clients. Format:
MP2YWEMeM8MxjkGKpH4dqOQ4Q4DlSPajHTTP Cookie header. Required when calling from server-side applications to forward the session cookie. Example:
ory_kratos_session=a19iOVAbdzdgl70Rq1QZmrKmcjDtdsviCTZx7m9a9yHIUS8Wa9T7hvqyGTsLHi6Qifn2WUfpAKx9DWp0SJGleIn9vh2YF4A16id93kXFTgIgmwIOvbVAScyrx7yVl6bPZnCx27ec4WQDtaTewC1CpgudeDV2jQQnSaCP6ny3xa8qLH-QUgYqdQuoA_LF1phxgRCUfIrCLQOkolX5nv3ze_f==Response
Session ID
Active state. If false, the session is no longer active.
When this session expires
When this session was authenticated. For multi-factor authentication, this is when the last factor was completed.
When this session was issued. Usually equal or close to
authenticated_at.The identity that owns this session
The authenticator assurance level. Higher numbers mean harder to compromise.
aal1 means one factor was used, aal2 means two factors (e.g. password + TOTP).List of authenticators used during authentication
History of all endpoints where the session was used
The tokenized (e.g. JWT) version of the session. Only set when
tokenize_as query parameter was provided.Error responses
Unauthorized - No valid session found
Forbidden - Session has lower Authenticator Assurance Level (AAL) than possible for the identity. For example, the identity has password + webauthn credentials (AAL2) but the session only has AAL1.
Use cases
This endpoint is useful for:- AJAX calls - Remember to send credentials and configure CORS
- Reverse proxies and API gateways - Validate sessions before forwarding requests
- Server-side calls - Use the
X-Session-Tokenheader - Session verification - Check if a user is logged in
List active sessions
/sessions/whoami.
Method and path
Authentication
Requires authentication via Cookie or X-Session-Token header.Request parameters
Number of items per page (max: 500, min: 1)
Next page token for pagination. See pagination documentation.
Deprecated: Use
page_token instead. This parameter will be removed in the future. Number of items per page (max: 1000, min: 1).Deprecated: Use
page_token instead. This parameter will be removed in the future. Page reference (not sequential).Session token for non-browser clients. Format:
MP2YWEMeM8MxjkGKpH4dqOQ4Q4DlSPajHTTP Cookie header for forwarding session cookies from server-side applications
Response
Returns an array of session objects. Each session has the same structure as the/sessions/whoami response.
Error responses
Bad Request - Invalid pagination parameters
Unauthorized - No valid session found
Revoke a session
Method and path
Authentication
Requires authentication via Cookie or X-Session-Token header.Request parameters
The session ID to revoke
Session token for non-browser clients
HTTP Cookie header for forwarding session cookies
Response
Returns HTTP204 No Content on success.
Error responses
Bad Request - Cannot revoke current session or invalid session ID
Unauthorized - No valid session found
Revoke all other sessions
Method and path
Authentication
Requires authentication via Cookie or X-Session-Token header.Request parameters
Session token for non-browser clients
HTTP Cookie header for forwarding session cookies
Response
The number of sessions that were revoked
Error responses
Bad Request
Unauthorized - No valid session found
Exchange session token
Method and path
Authentication
No authentication required (the codes serve as authentication).Request parameters
The part of the code returned when initializing the flow
The part of the code returned by the return_to URL
Response
The session object
A session token equivalent to a session cookie. Can be sent in the HTTP Authorization header:
Authorization: bearer ${session-token}. Only issued for API flows, not browser flows.List of actions that could follow this flow (e.g., verification flow reference)
Error responses
Forbidden - Invalid codes
Not Found - Code exchange not found
Gone - Code exchange expired