---
title: "Get session inventory stats"
method: GET
path: "/admin/sessions/stats"
tags: ["Admin Sessions"]
---

# Get session inventory stats

`GET /admin/sessions/stats`

## Request

- Base URL: `https://h2ogpte.genai.h2o.ai/api/v1`
- URL: `https://h2ogpte.genai.h2o.ai/api/v1/admin/sessions/stats`
- Auth: HTTP bearer
- TypeScript: <https://skmtc.dev/h2o/apis/h2ogpte-rest-api/docs/admin/sessions/stats/get.ts> (a function with typed inputs; its response is checked against the schema)

Returns aggregate counters across all live sessions (total, by transport, anonymous count, Azure exchange-cache count). Result is cached per-process for ~30 seconds; the `cache_age_seconds` field communicates freshness so a polling dashboard can render it.

## Response `200`

Successful operation

- AdminSessionsStatsResponse
  - `total` integer, required: Total number of live sessions.
  - `by_transport` object, required: Counters partitioned by `transport` (keycloak, anonymous, spoof, unknown).
  - `anonymous_count` integer, required: Number of guest / anonymous sessions.
  - `azure_cache_count` integer, required: Number of distinct Azure tokens currently cached for federation exchange. Approximate; not a user count.
  - `computed_at` string, date-time, required: When the cached stats were computed.
  - `cache_age_seconds` integer, required: Wall-clock age of the cached stats, in seconds. Useful for rendering freshness in a polling UI.
  - `session_default_ttl` string, required: Configured default TTL for session keys (Go duration string, e.g. `168h0m0s`).

## Other responses

- `401`: Unauthorized - Invalid or missing API key
- `403`: Caller is not an admin.
- `500`: Internal server error
- `default`: Unexpected error

---

[API](https://skmtc.dev/h2o/apis/h2ogpte-rest-api.md) - [All operations](https://skmtc.dev/h2o/apis/h2ogpte-rest-api/llms.txt) - [OpenAPI document](https://skmtc.dev/h2o/apis/h2ogpte-rest-api/revisions/a82a117320f4?raw)
