HTTP API
Everything the web app shows is also available through the API, under /api. The list below covers every route.
Authentication
Section titled “Authentication”The read API uses the browser session cookie. Read tokens for scripts are not available yet. Until then:
- In the browser: sign in and call
fetchfrom the developer console:await (await fetch("/api/environments/<environmentId>/metrics")).json(). - With
curl: copy the session cookie from the developer tools (Application, Cookies). Its name is__Secure-better-auth.session_tokenover HTTPS (better-auth.session_tokenover plain HTTP). Send it as-H "Cookie: <name>=<value>".
API keys authenticate /v1/traces and /v1/whoami only, never /api.
Mutating requests to /api must come from the app’s origin (Origin or Referer equal to the app URL) and send application/json; otherwise 403 or 415.
Conventions
Section titled “Conventions”- Tenancy: a project, environment, conversation or turn of another organization answers
404. - Pagination:
limit(1–100, default 50) andcursor; pass the previousnextCursor, which isnullon the last page. Cursors are opaque. - Ranges:
from(inclusive) andto(exclusive), ISO 8601 withZor an offset;frommust be beforeto, else400. On large environments always send a range. - Figures:
{ status, value, reason, unlockedBy, docsPath }; ratios as{ numerator, denominator, ratio }. A missing signal isunavailablewithvalue: null, never 0. See Never a false zero. - Ids: the environment id is on the project page and in the URLs of the app;
GET /api/projects/<projectId>/environmentslists them.
curl -H "Cookie: <name>=<value>" \ "https://app.ctxflow.sh/api/environments/<environmentId>/metrics?from=2026-11-01T00:00:00Z&to=2026-12-01T00:00:00Z"Ingestion
Section titled “Ingestion”| Method | Path | Permission | Description |
|---|---|---|---|
POST | /v1/traces | API key | OTLP/HTTP trace ingestion. See OTLP endpoint. |
GET | /v1/whoami | API key | Which project and environment the key sends to, and when data last arrived there. Read-only; used by ctxflow-otel check. See Verify your setup. |
Environment views
Section titled “Environment views”| Method | Path | Permission | Description |
|---|---|---|---|
GET | /api/environments/:environmentId/actions/calls | environment:read | Tool calls, newest first. user or unattributed=true. |
GET | /api/environments/:environmentId/actions/users | environment:read | Tool calls grouped by end user, with an unattributed bucket. |
GET | /api/environments/:environmentId/agents | environment:read | Agents of the environment (id, serviceName), for the agent filter. |
GET | /api/environments/:environmentId/capabilities | environment:read | Signals S1–S11 with state, coverage, what unlocks them and what they unlock. |
GET | /api/environments/:environmentId/conversations | environment:read | Conversations, newest first. Filters user, agent, from, to, dateMode (started or active); limit, cursor. |
GET | /api/environments/:environmentId/conversations/:conversationId/turns | environment:read | Turns of a conversation (numeric id), in time order. |
GET | /api/environments/:environmentId/conversations/issue-counts | environment:read | How many conversations matching the filters have each omission kind (null when not computable). |
GET | /api/environments/:environmentId/data/delivered | environment:read | Chunks delivered to the model in the range: total, per turn, turns by chunks delivered (0, 1, 2-3, 4-6, 7+) and the documents delivered most. from, to. |
GET | /api/environments/:environmentId/data/index-health | environment:read | Index: C1 coverage, ID stability, changes per day, lag. |
GET | /api/environments/:environmentId/data/never-retrieved | environment:read | Live chunks or documents never retrieved in the range, with the id-match guard. level=documents|chunks. |
GET | /api/environments/:environmentId/data/sources | environment:read | Sources with version, last change, live chunks, index up to date, deleted but indexed. |
GET | /api/environments/:environmentId/health | environment:read | The Health page: four tiles, secondary figures, up to 5 rows that need attention and the figures not measured. from, to. |
GET | /api/environments/:environmentId/metrics | environment:read | Metrics M3, M4, M5 and C6 as numerator over denominator. from, to, agent. |
GET | /api/environments/:environmentId/omissions | environment:read | Omissions, newest first, with reason and evidence ids. kind, from, to, agent, limit, cursor. |
GET | /api/environments/:environmentId/omissions/summary | environment:read | Count of each omission kind in the slice (null when unavailable). |
GET | /api/environments/:environmentId/status | environment:read | Ingest status: receiving, waiting, silent, rejected, no_key. |
GET | /api/environments/:environmentId/turns/:turnId | environment:read | One turn: tokens, model, status, tool calls, context items with lineage, omissions. |
GET | /api/environments/:environmentId/turns/:turnId/neighbours | environment:read | Turns around one turn (radius 1–20, default 10). |
GET | /api/environments/:environmentId/turns/:turnId/text | environment:read | Text of the turn (prompt, answer, tool inputs, results and errors, item texts), each with a state. |
Projects, environments and keys
Section titled “Projects, environments and keys”| Method | Path | Permission | Description |
|---|---|---|---|
GET | /api/projects | project:read | Projects of the active organization. |
POST | /api/projects | project:create | Create a project (with the environments dev, staging, prod). |
GET | /api/projects/:projectId | project:read | One project, with its text settings. |
GET | /api/projects/:projectId/catalog/chunks | project:read | Chunks of one document: source=<source_id> or unknownSource=true. |
GET | /api/projects/:projectId/catalog/documents | project:read | Consulted documents by source_id: chunks, retrieved, turns, versions. environment, from, to. |
GET | /api/projects/:projectId/environments | environment:read | Environments in creation order, each with its ingest status. |
POST | /api/projects/:projectId/environments | environment:create | Create an environment. |
GET | /api/projects/:projectId/environments/:environmentId/api-keys | apiKey:read | API keys of the environment (prefix, last use, last rejection; never the hash). |
POST | /api/projects/:projectId/environments/:environmentId/api-keys | apiKey:create | Create a key. The secret is in this response only. |
POST | /api/projects/:projectId/environments/:environmentId/api-keys/:keyId/revoke | apiKey:revoke | Revoke a key. |
POST | /api/projects/:projectId/environments/:environmentId/api-keys/:keyId/rotate | apiKey:create | Create a new key and mark the old one as replaced. The old key keeps working until you revoke it. The new secret is in this response only. |
PATCH | /api/projects/:projectId/settings | project:update | Set storeText and/or textRetentionDays (1–3650). |
Service
Section titled “Service”| Method | Path | Permission | Description |
|---|---|---|---|
GET | /api/auth-providers | none | Which optional sign-in methods are configured. |
ANY | /api/auth/** | none | Sign-in and session handling (Better Auth). |
GET | /api/health | none | Liveness: process and database. |
GET | /api/health/ingest | none | 503 when no trace arrived for CTXFLOW_INGEST_STALE_HOURS. |
ANY | /third-party-notices.txt | none | Third-party licence notices (self-hosted image only; 404 elsewhere). |
Related
Section titled “Related”OTLP endpoint for ingestion, Error codes, API keys for the keys.