Docs

Get my session

GET
/sessions/me

Returns the current state of the caller's session, including its factors and all currently satisfied assurance levels.

With project_id, the session is returned only when it belongs to that project.

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.

Authorization

sessionCookie
cookie__Host-zitadel_session<token>

The session cookie issued at session creation or superseding handoff exchange.

A browser holds it as __Host-zitadel_session, with Secure. Over plain http to a loopback host (localhost, 127.0.0.1, ::1) the server sets it as zitadel_session instead, without Secure or the prefix, so that Safari keeps it, and accepts that name there too; __Host-zitadel_session takes precedence. A program sends __Host-zitadel_session over any transport.

A missing or invalid cookie yields 401 with code auth.unauthorized and the message Missing or invalid session token.

Cross-site request forgery (CSRF) protection: a state-changing request that this cookie authenticates must come from the same origin. A cross-site browser request is refused with 403 and code auth.csrf_invalid. Every such request must also send the session's token from GET /sessions/me/csrf in the X-Zitadel-CSRF header, or it answers the same 403. The only exceptions are the POST …/query reads and POST /invitations/lookup, which need no token. Safe methods (GET) are not checked. A request a project secret authenticates is not affected.

Query Parameters

project_id?string

The project the caller signs its users in to. The cookie's session is used only when it belongs to this project; a session of any other project answers 403 with sess.project_mismatch.

A session belongs to one project, while a browser sends its cookie to every app on the same host. An app passes its own project, so that a session of another project never reads or acts as one of its users, and signing out of the app never ends it. The SDKs pass it when they read the session or sign out.

sess.project_mismatch does not mean the session is invalid: it is live in its own project, so keep its cookie.

Match^[a-zA-Z0-9_-]+$

Response Body

The session.

application/json
  1. 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-id

The unique identifier of this session, an opaque string with a sess_ prefix.

Match^sess_[a-zA-Z0-9_-]+$
project_id*project-id
Match^[a-zA-Z0-9_-]+$
state*string

Current lifecycle state of the session:

  • building: no verified authentication factors yet
  • active: has at least one verified authentication factor; assurance_levels[] may shrink as factors age
  • expired: the session's lifetime has passed
Value in"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*string

When this session was created.

Formatdate-time
expires_at*string

When 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.

Formatdate-time
Example Request
import { configureZitadel, getApi } from "@zitadel/api/config";// In the browser, through the SDK proxy: the session cookie authenticates the call.const api = getApi(configureZitadel({ projectId: "proj_01KWH1P4MYS7F0N9WD3P2E4YM5" }));const mySession = await api.getMySession();
Example Response
{  "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?