Docs

Query sessions

POST
/sessions/query

Returns a page of a project's sessions.

Sessions of every lifecycle state are returned; each carries its state. Requires the session.read scope and the admin role on the project: each session records the IP and user agent its user signed in from, so a viewer or an editor is refused.

Authorization

oauth2 session.read
headerAuthorizationBearer <token>

Scope: session.read

Query Parameters

project_id*string

The project ID: the id that createProject (POST /projects) returns. zitadel setup prints it as "Project id" in its summary and as project_id with --json, and writes it to .env.local as ZITADEL_PROJECT_ID.

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

Request Body

Request to query the sessions of a project.

application/json
  1. body

Request to query the sessions of a project.

limit?limit
Range1 <= value <= 100
Default20
page_token?|

Token to retrieve the next page of results.

sorting?
filter?array<>

Filter criteria for querying sessions.

Response Body

A page of the project's sessions.

application/json
  1. response

Paginated list of sessions.

sessions*array<>
next_page_token?|

Token to pass as page_token in the next request to fetch the following page. Absent when there are no more results.

Example Request
import { 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 sessions = await api.querySessions({}, { project_id: "proj_01KWH1P4MYS7F0N9WD3P2E4YM5" });
Example Response
{  "sessions": [    {      "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"    }  ],  "next_page_token": "string"}

Was this helpful?