Skip to content

HTTP API

Everything the web app shows is also available through the API, under /api. The list below covers every route.

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 fetch from 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_token over HTTPS (better-auth.session_token over 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.

  • Tenancy: a project, environment, conversation or turn of another organization answers 404.
  • Pagination: limit (1–100, default 50) and cursor; pass the previous nextCursor, which is null on the last page. Cursors are opaque.
  • Ranges: from (inclusive) and to (exclusive), ISO 8601 with Z or an offset; from must be before to, else 400. On large environments always send a range.
  • Figures: { status, value, reason, unlockedBy, docsPath }; ratios as { numerator, denominator, ratio }. A missing signal is unavailable with value: 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>/environments lists them.
Terminal window
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"
MethodPathPermissionDescription
POST/v1/tracesAPI keyOTLP/HTTP trace ingestion. See OTLP endpoint.
GET/v1/whoamiAPI keyWhich project and environment the key sends to, and when data last arrived there. Read-only; used by ctxflow-otel check. See Verify your setup.
MethodPathPermissionDescription
GET/api/environments/:environmentId/actions/callsenvironment:readTool calls, newest first. user or unattributed=true.
GET/api/environments/:environmentId/actions/usersenvironment:readTool calls grouped by end user, with an unattributed bucket.
GET/api/environments/:environmentId/agentsenvironment:readAgents of the environment (id, serviceName), for the agent filter.
GET/api/environments/:environmentId/capabilitiesenvironment:readSignals S1–S11 with state, coverage, what unlocks them and what they unlock.
GET/api/environments/:environmentId/conversationsenvironment:readConversations, newest first. Filters user, agent, from, to, dateMode (started or active); limit, cursor.
GET/api/environments/:environmentId/conversations/:conversationId/turnsenvironment:readTurns of a conversation (numeric id), in time order.
GET/api/environments/:environmentId/conversations/issue-countsenvironment:readHow many conversations matching the filters have each omission kind (null when not computable).
GET/api/environments/:environmentId/data/deliveredenvironment:readChunks 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-healthenvironment:readIndex: C1 coverage, ID stability, changes per day, lag.
GET/api/environments/:environmentId/data/never-retrievedenvironment:readLive chunks or documents never retrieved in the range, with the id-match guard. level=documents|chunks.
GET/api/environments/:environmentId/data/sourcesenvironment:readSources with version, last change, live chunks, index up to date, deleted but indexed.
GET/api/environments/:environmentId/healthenvironment:readThe Health page: four tiles, secondary figures, up to 5 rows that need attention and the figures not measured. from, to.
GET/api/environments/:environmentId/metricsenvironment:readMetrics M3, M4, M5 and C6 as numerator over denominator. from, to, agent.
GET/api/environments/:environmentId/omissionsenvironment:readOmissions, newest first, with reason and evidence ids. kind, from, to, agent, limit, cursor.
GET/api/environments/:environmentId/omissions/summaryenvironment:readCount of each omission kind in the slice (null when unavailable).
GET/api/environments/:environmentId/statusenvironment:readIngest status: receiving, waiting, silent, rejected, no_key.
GET/api/environments/:environmentId/turns/:turnIdenvironment:readOne turn: tokens, model, status, tool calls, context items with lineage, omissions.
GET/api/environments/:environmentId/turns/:turnId/neighboursenvironment:readTurns around one turn (radius 1–20, default 10).
GET/api/environments/:environmentId/turns/:turnId/textenvironment:readText of the turn (prompt, answer, tool inputs, results and errors, item texts), each with a state.
MethodPathPermissionDescription
GET/api/projectsproject:readProjects of the active organization.
POST/api/projectsproject:createCreate a project (with the environments dev, staging, prod).
GET/api/projects/:projectIdproject:readOne project, with its text settings.
GET/api/projects/:projectId/catalog/chunksproject:readChunks of one document: source=<source_id> or unknownSource=true.
GET/api/projects/:projectId/catalog/documentsproject:readConsulted documents by source_id: chunks, retrieved, turns, versions. environment, from, to.
GET/api/projects/:projectId/environmentsenvironment:readEnvironments in creation order, each with its ingest status.
POST/api/projects/:projectId/environmentsenvironment:createCreate an environment.
GET/api/projects/:projectId/environments/:environmentId/api-keysapiKey:readAPI keys of the environment (prefix, last use, last rejection; never the hash).
POST/api/projects/:projectId/environments/:environmentId/api-keysapiKey:createCreate a key. The secret is in this response only.
POST/api/projects/:projectId/environments/:environmentId/api-keys/:keyId/revokeapiKey:revokeRevoke a key.
POST/api/projects/:projectId/environments/:environmentId/api-keys/:keyId/rotateapiKey:createCreate 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/settingsproject:updateSet storeText and/or textRetentionDays (1–3650).
MethodPathPermissionDescription
GET/api/auth-providersnoneWhich optional sign-in methods are configured.
ANY/api/auth/**noneSign-in and session handling (Better Auth).
GET/api/healthnoneLiveness: process and database.
GET/api/health/ingestnone503 when no trace arrived for CTXFLOW_INGEST_STALE_HOURS.
ANY/third-party-notices.txtnoneThird-party licence notices (self-hosted image only; 404 elsewhere).

OTLP endpoint for ingestion, Error codes, API keys for the keys.