Check Who the Current HTTP Session Belongs To
GEThttps://accounts.<domain>/auth/sessions/whoami
Uses the HTTP Headers in the GET request to determine (e.g. by using checking the cookies) who is authenticated. Returns a session object in the body or 401 if the credentials are invalid or no credentials were sent.
If you call this endpoint from a server-side application, you must forward the HTTP Cookie Header to this endpoint:
pseudo-code example
router.get('/protected-endpoint', async function (req, res) {
const session = await client.toSession(undefined, req.header('cookie'))
console.log(session)
})
When calling this endpoint from a non-browser application (e.g. mobile app) you must include the session token:
pseudo-code example
...
const session = await client.toSession("the-session-token")
console.log(session)
When using a token template, the token is included in the tokenized
field of the session.
pseudo-code example
...
const session = await client.toSession("the-session-token", { tokenize_as: "example-jwt-template" })
console.log(session.tokenized) // The JWT
Depending on your configuration this endpoint might return a 403 status code if the session has a lower Authenticator Assurance Level (AAL) than is possible for the identity. This can happen if the identity has password + webauthn credentials (which would result in AAL2) but the session has only AAL1. If this error occurs, ask the user to sign in with the second factor or change the configuration.
This endpoint is useful for:
AJAX calls. Remember to send credentials and set up CORS correctly!
Reverse proxies and API Gateways
Server-side calls - use the X-Session-Token
header!
Request
Query Parameters
Returns the session additionally as a token (such as a JWT)
The value of this parameter has to be a valid, configured Session token template. For more information head over to the documentation.
Header Parameters
Set the Session Token when calling from non-browser clients. A session token has a format of MP2YWEMeM8MxjkGKpH4dqOQ4Q4DlSPaj
.
Set the Cookie Header. This is especially useful when calling this endpoint from a server-side application. In that scenario you must include the HTTP Cookie Header which originally was included in the request to your server.
Responses
- 200
- 401
- 403
- default
session
- application/json
- Schema
- Example (from schema)
Schema
Active state. If false the session is no longer active.
The Session Authentication Timestamp
When this session was authenticated at. If multi-factor authentication was used this is the time when the last factor was authenticated (e.g. the TOTP code challenge was completed).
authentication_methods object[]
Possible values: [aal0
, aal1
, aal2
, aal3
]
The authenticator assurance level can be one of "aal1", "aal2", or "aal3". A higher number means that it is harder for an attacker to compromise the account.
Generally, "aal1" implies that one authentication factor was used while AAL2 implies that two factors (e.g. password + TOTP) have been used.
devices object[]
The Session Expiry
When this session expires at.
Session ID
identity object
The Session Issuance Timestamp
When this session was issued at. Usually equal or close to authenticated_at
.
Tokenized is the tokenized (e.g. JWT) version of the session.
It is only set when the tokenize
query parameter was set to a valid tokenize template during calls to /session/whoami
.
{
"active": true,
"authenticated_at": "2025-04-17T12:10:30.853Z",
"authentication_methods": [
{
"aal": "aal0",
"completed_at": "2025-04-17T12:10:30.853Z",
"method": "link_recovery",
"organization": "string",
"provider": "string"
}
],
"authenticator_assurance_level": "aal0",
"devices": [
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"ip_address": "string",
"location": "string",
"user_agent": "string"
}
],
"expires_at": "2025-04-17T12:10:30.853Z",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"identity": {
"created_at": "2025-04-17T12:10:30.853Z",
"credentials": {},
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"organization_id": "string",
"recovery_addresses": [
{
"created_at": "2025-04-17T12:10:30.853Z",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"updated_at": "2025-04-17T12:10:30.853Z",
"value": "string",
"via": "string"
}
],
"schema_id": "string",
"schema_url": "string",
"state": "active",
"state_changed_at": "2025-04-17T12:10:30.853Z",
"updated_at": "2025-04-17T12:10:30.853Z",
"verifiable_addresses": [
{
"created_at": "2014-01-01T23:28:56.782Z",
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"status": "string",
"updated_at": "2014-01-01T23:28:56.782Z",
"value": "string",
"verified": true,
"verified_at": "2025-04-17T12:10:30.853Z",
"via": "email"
}
]
},
"issued_at": "2025-04-17T12:10:30.853Z",
"tokenized": "string"
}
errorGeneric
- application/json
- Schema
- Example (from schema)
Schema
error objectrequired
{
"error": {
"code": 404,
"debug": "SQL field \"foo\" is not a bool.",
"details": {},
"id": "string",
"message": "The resource could not be found",
"reason": "User with ID 1234 does not exist.",
"request": "d7ef54b1-ec15-46e6-bccb-524b82c035e6",
"status": "Not Found"
}
}
errorGeneric
- application/json
- Schema
- Example (from schema)
Schema
error objectrequired
{
"error": {
"code": 404,
"debug": "SQL field \"foo\" is not a bool.",
"details": {},
"id": "string",
"message": "The resource could not be found",
"reason": "User with ID 1234 does not exist.",
"request": "d7ef54b1-ec15-46e6-bccb-524b82c035e6",
"status": "Not Found"
}
}
errorGeneric
- application/json
- Schema
- Example (from schema)
Schema
error objectrequired
{
"error": {
"code": 404,
"debug": "SQL field \"foo\" is not a bool.",
"details": {},
"id": "string",
"message": "The resource could not be found",
"reason": "User with ID 1234 does not exist.",
"request": "d7ef54b1-ec15-46e6-bccb-524b82c035e6",
"status": "Not Found"
}
}
- curl
- python
- go
- nodejs
- ruby
- csharp
- php
- java
- powershell
- CURL
curl -L -X GET 'https://accounts.<domain>/auth/sessions/whoami' \
-H 'Accept: application/json'