Get a session by ID
Returns the current state of a session, including its factors and all currently satisfied assurance levels.
An assurance level is a profile, such as urn:nist:aal:2, that the
session's verified factors satisfy. assurance_levels[] may shrink over time
as factor freshness windows expire, without the session itself expiring.
To restore a dropped level, use step-up authentication: create an
authentication attempt with the same session_id.
A session is read by its own user, by an admin of its project and by the deployment's operators. A viewer or an editor of the project is refused.
oauth2 session.readAuthorizationBearer <token>Scope: session.read
session_id*stringThe session_id that createSession (POST /sessions) or exchangeHandoff (POST /sessions/exchange) returns, or that
querySessions (POST /sessions/query) lists.
^sess_[a-zA-Z0-9_-]+$The session.
application/json- response
The current state of a session.
A session is the durable record of a user who has signed in. It accumulates verified
authentication factors and exposes assurance_levels[], the set of assurance profiles
its current factors satisfy. Sessions are read-only for the client: factors flow
in through authentication attempts.
session_id*session-idThe unique identifier of this session, an opaque string with a sess_ prefix.
^sess_[a-zA-Z0-9_-]+$project_id*project-id^[a-zA-Z0-9_-]+$state*stringCurrent lifecycle state of the session:
building: no verified authentication factors yetactive: has at least one verified authentication factor;assurance_levels[]may shrink as factors ageexpired: the session's lifetime has passed
"building""active""expired"user_id?|The authenticated user. Null for anonymous sessions and until the user
factor has been verified through an authentication attempt.
user?The authenticated user's resolved reference, derived live from the
user schema's x-identifier/x-display designations.
Present on identity-hydrating reads (GET /sessions/me, session get
and query) whenever the session has an authenticated user; absent
for anonymous sessions. Clients render display, falling back to
identifier, then user_id.
factors*array<>Verified authentication factors accumulated by this session.
Each key is a factor type, for example password, totp or passkey.
Each value is a factor event object with at least verified_at and
method-specific properties, for example user_verified and hardware for passkeys.
assurance_levels?array<string>All assurance levels whose schemas the current session factors satisfy. This list shrinks as factor freshness windows expire and grows when step-up authentication attempts add or refresh factors. The request context, not the session, decides whether any level is enough.
metadata?|Arbitrary key/value metadata attached to the session.
user_agent?|User agent information captured at session creation.
created_at*stringWhen this session was created.
date-timeexpires_at*stringWhen this session expires. An anonymous session lasts 10 minutes. The lifetime resets to the full configured session lifetime once the first authentication factor is written.
date-timeimport { createZitadelApi, ZitadelClient } from "@zitadel/api/client";const api = createZitadelApi( new ZitadelClient({ baseUrl: process.env.ZITADEL_URL ?? "http://localhost:8080", token: process.env.ZITADEL_PROJECT_SECRET!, // server-side only }),);const result = await api.getSession("sess_01J0Z9KX7Y0Q2Y7JX5M9K2YF3C");{ "session_id": "string", "project_id": "string", "state": "building", "user_id": "string", "user": { "user_id": "string", "identifier": "string", "identifier_property": "string", "display": "string" }, "factors": [ { "method": "identifier", "verified_at": "2019-08-24T14:15:22Z", "payload": { "method": "identifier", "user_id": "string" } } ], "assurance_levels": [ "string" ], "metadata": {}, "user_agent": { "fingerprint": "string", "ip": "string" }, "created_at": "2019-08-24T14:15:22Z", "expires_at": "2019-08-24T14:15:22Z"}Was this helpful?