Skip to content

Analytics API

GET /api/v1/admin/optimization · operation getOptimizationInsights

Global quotas:read. Measured effects (gateway_cache, provider_prompt_cache, auto_routing; prompt_compression and reasoning_control as not_measured) of successful requests in [from, to) (RFC 3339, at most 92 days, default the last 30; team filters before aggregation), valued with exact approved rates priced per request as request valuation prices it (the reported service tier, an unapproved tier unpriced; the long-context tier for the whole request strictly above its threshold; cache reads and five-minute and one-hour writes at their own prices), one effect class per request; unpriced requests are counted and excluded. provider_prompt_cache is net (gross_savings_usd minus write_premium_usd, possibly negative) and counts cache_write_unknown_requests, served requests whose cache writes are unknown while the rate prices writes. With baseline_id both windows are valued at the baseline’s frozen rates and each model is comparable, insufficient_sample, workload_changed, incomplete, truncated or unpriced; a baseline captured before body version 2 is valued only at rates without tiers, long-context or write prices. Advisory recommendations with sample, confidence, ceiling, prerequisites and caveats; applies_changes is always false. Requires optimization_insights; no-store.

Authentication: adminSession

Parameters

Name In Type Description
from query string (date-time)
to query string (date-time)
team query string
baseline_id query string, pattern ^ob_[0-9a-f]{24}$

Responses

Status Description Body
200 from, to, team, basis, truncated, effects (effect, state, requests, estimated_usd, unpriced_requests, basis, notes; provider_prompt_cache adds gross_savings_usd, write_premium_usd and cache_write_unknown_requests), models, recommendations, applies_changes (false), note and, with a baseline, baseline (id, name, from, to, fingerprint, truncated, body_version) —
400 invalid_range, baseline_scope_mismatch or window_overlaps_baseline —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled or baseline_not_found —
503 Local concurrency limit reached application/json: Error

GET /api/v1/admin/optimization/baselines · operation listOptimizationBaselines

Global quotas:read. The last 100 immutable baselines. Requires optimization_insights; no-store.

Authentication: adminSession

Responses

Status Description Body
200 items: id, name, team, from, to, fingerprint, created_at —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

POST /api/v1/admin/optimization/baselines · operation createOptimizationBaseline

Global administrator with quotas:manage, same origin and CSRF. Freezes the window’s usage per model, reported service tier, long-context side and cache reads and writes (body version 2) and the approved rates in force; immutable and audited (optimization.baseline.create).

Authentication: adminSession

Parameters

Name In Type Description
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • name (string, required, min length 1, max length 120)
    • team (string)
    • from (string (date-time), required)
    • to (string (date-time), required)

Responses

Status Description Body
201 The baseline with its body (rows, rates, truncated, version) and fingerprint —
400 invalid_baseline —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error
503 Local concurrency limit reached application/json: Error

GET /api/v1/admin/external-usage · operation getExternalUsage

Global quotas:read. External usage per day, connector, tool and model in [from, to) (UTC dates, at most 92 days) from external usage connectors, with provider_estimated_usd (nullable; the source’s own estimate), state (synced or provisional), gateway_requests_same_provider and possible_overlap. Reporting only (enforcement none). Requires external_usage_connectors; no-store.

Authentication: adminSession

Parameters

Name In Type Description
from query string (date), required First UTC date of the report, inclusive; at most 92 days before to.
to query string (date), required

Responses

Status Description Body
200 from, to, days, enforcement, estimate_basis —
400 invalid_period —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

GET /api/v1/admin/external-usage/connectors

Section titled “GET /api/v1/admin/external-usage/connectors”

GET /api/v1/admin/external-usage/connectors · operation listExternalUsageConnectors

Global quotas:read. YAML external usage connectors (never the credential, only whether it is configured) with their last five runs, and deferred_sources not yet implemented.

Authentication: adminSession

Responses

Status Description Body
200 usage_connectors: the YAML connectors with their last runs, and deferred_sources application/json: object
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

Response 200 fields:

  • application/json: object
    • usage_connectors (array of UsageConnector, required)
    • deferred_sources (array of string, required)

POST /api/v1/admin/external-usage/connectors/{id}/sync

Section titled “POST /api/v1/admin/external-usage/connectors/{id}/sync”

POST /api/v1/admin/external-usage/connectors/{id}/sync · operation syncExternalUsageConnector

Global administrator, quotas:manage, same origin and CSRF. Reads the connector’s usage report for [from, to) (UTC dates, at most 31 days, ending no later than tomorrow) at its fixed origin and keeps the latest report per record (new, corrected, withdrawn). Audited as external_usage.sync. The provider’s body is never echoed.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • from (string (date), required)
    • to (string (date), required)

Responses

Status Description Body
200 The run: pages, records, new_records, corrected_records, withdrawn_records, final_through —
400 invalid_period —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled or connector_not_found —
422 connector_report_too_large —
502 connector_credential_rejected, connector_unavailable or connector_invalid_report —
503 connector_credential_missing, connector_rate_limited or storage unavailable —

GET /api/v1/admin/log-destinations · operation listLogDestinations

Log destinations (ADR 0144) declared in the log_destinations block: S3, GCS, Azure Blob, Langfuse, Datadog or HTTP. Every request is delivered as a metadata record (never prompt, answer or credential) in batches. Per destination: target without credentials, queued, sent, batches, dropped, failed batches, last delivery and object, last failure class (credential_unavailable, denied, rejected, timeout, unreachable, failed). credential_unavailable means the gateway could not obtain its own cloud credential: the records are kept (bounded) and retried with backoff instead of dropped. Counters are this process’s since start. Requires log_destinations and logs:read.

Authentication: adminSession

Responses

Status Description Body
200 data: one status per destination —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

POST /api/v1/admin/log-destinations/{id}/test

Section titled “POST /api/v1/admin/log-destinations/{id}/test”

POST /api/v1/admin/log-destinations/{id}/test · operation testLogDestination

Queues one synthetic record and flushes the destination now, with whatever else is queued, so an operator sees the object written or the failure class at once. Requires log_destinations and alerts:manage.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, max length 64
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Responses

Status Description Body
200 ok and the destination status, with the object written —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled or destination not found —
502 Not delivered: error class and the destination status —
503 queue_full —

GET /api/v1/admin/savings · operation gatewaySavings

Cost optimization panel (ADR 0147): what the gateway cache, provider prompt caching and the auto-router saved across every key, or one team’s keys (team viewers see only their teams), with daily figures and the ten keys that saved most. Estimates at the current automatic price of each model; rows without a published price count tokens only. from and to together, within 90 days; default the last 30 days. Requires usage_analytics, cost_optimization and analytics:read.

Authentication: adminSession

Parameters

Name In Type Description
from query string (date-time)
to query string (date-time)
team query string

Responses

Status Description Body
200 total (total_saved_usd, gateway_cache, prompt_caching, auto_router, days, note), keys (top ten, same buckets), team and truncated (true when a storage bound of 20000 aggregated rows cut the daily totals or the key ranking, so the figures are a lower bound) —
400 invalid_range —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

POST /api/v1/admin/playground/{version}/{route}

Section titled “POST /api/v1/admin/playground/{version}/{route}”

POST /api/v1/admin/playground/{version}/{route} · operation playgroundSessionCall

T186.004 S3b: the console Playground sends one inference request with the console session instead of a typed key. version is v1 or v1beta; route is one of chat/completions, responses, messages, embeddings, images/generations, audio/speech, audio/transcriptions, decisions, systemone, moderations or rerank (v1beta: decisions); any other is 404 playground_route_unavailable (stateful objects such as files, batches, vector stores and realtime keep a typed key). After the session checks (cookie, same origin, CSRF, role, custom role, plan), the caller is built from the session: principal and owner are the console user, the team is X-Gateway-Playground-Team (a team the session is a member of, a team of its organization for an organization admin, any stored team for the global administrator role without a custom role; 403 team_forbidden otherwise, the same for a missing, deleted or disabled team), and the routes and models are those the team policy and organization ceiling allow. Viewers, team viewers, customer credentials and the admin bearer token are refused (403 role_forbidden). The caller’s key ID is playground:<team>:<user>, so key-bound state (a key-scoped semantic cache, signed stored responses, key limits) never crosses teams. The request then runs through the ordinary inference route: team policy, plan entitlements, attribution requirements, concurrency, rate limits, budgets, guardrails, capture, logs, metrics, ledger and cost apply as for any client request, and the row is origin playground. The body, query, response and streaming are the inference route’s. Requires playground, evaluation_tracing and playground:use.

Authentication: adminSession

Parameters

Name In Type Description
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.
version path string, required, one of "v1", "v1beta"
route path string, required, max length 64 The inference route below /<version>/, for example chat/completions
X-Gateway-Playground-Team header string, required, min length 1, max length 128 The team the request runs as and is billed to

Request body (required)

  • application/json: object — The inference route’s own body

Responses

Status Description Body
200 The inference route’s answer (JSON or an event stream) application/json: object
text/event-stream: string
400 Invalid input application/json: Error
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error
503 Provider unavailable application/json: Error

POST /api/v1/admin/ask · operation askAI

m7 ai (ADR 0136, T146): a question in plain language about this gateway’s data, answered by a chat model through read-only tools that are the console’s own GET endpoints called with the asker’s session, so RBAC, team scope, flags, plan entitlements and retention are the screen’s. Tools: usage_query (GET /analytics/query), usage_report (GET /analytics), request_logs (GET /logs), search_text (RE2 search run in the gateway over request log metadata, audit, effective configuration with secrets redacted, the served documentation build and the embedded OpenAPI), read_document and read_console (session, config, keys, teams, organizations, guardrails, alerts, quotas, rate limits, routing, resilience, prices, MCP health, savings, one request). Body: question (1-2000 characters), model (an enabled chat alias, not auto-routed) and optional history (up to 10 user/assistant turns). At most 8 tool rounds with up to 4 calls each (more, and repeats of an identical call, are refused to the model), then one round without tools that carries the question and a digest of the results (at most 48 KB) instead of the tool-call history; at most 120000 prompt tokens per question, estimated before each round; at most 2 questions in flight per console user (429 ask_ai_busy with Retry-After), 1500 answer tokens per round and 24 KB per tool result. Every model call goes through the gateway, bypasses the cache and is recorded under console-ask-ai:<user>; with evaluation_tracing it is a helper call (helper_kind ask_ai) billed to the team in team (or the session’s only team). Returns answer, steps (round, tool, declared arguments, HTTP status, error, summary and, for usage_query, the normalized query that ran), rounds, limit_reached (rounds or prompt_tokens when the answer came from the final round without tools) and token usage. With ask_ai_actions (T150) the model may also call propose_create_key, propose_revoke_key, propose_create_team, propose_set_budget, propose_add_team_member and propose_remove_team_member, offered only when the session’s role could make the change and the change’s flags are on; they change nothing and add proposals to the answer (see /ask/proposals/{id}/confirm). 502 ask_ai_model_failed or ask_ai_unfinished. Requires ask_ai, usage_analytics and analytics:read.

Authentication: adminSession

Parameters

Name In Type Description
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • question (string, required, max length 2000)
    • model (string, required)
    • team (string, max length 128) — T186.004 S3b, with evaluation_tracing: the team m7 ai’s model calls are billed to, as helper calls (helper_kind ask_ai) under that team’s policy; one the session is a member of, or of its organization for an organization admin, or any stored team for the global administrator role (403 team_forbidden otherwise). Omitted: the session’s only team, or none for a session with several or none.
    • history (array of object, max items 10)
      • role (string, one of "user", "assistant")
      • content (string)

Responses

Status Description Body
200 Answer and the steps taken application/json: object
400 Invalid question, model or history —
404 Feature disabled —
429 ask_ai_busy: two questions of this user are already running —
502 Model call failed or never answered —

Response 200 fields:

  • application/json: object
    • answer (string, required)
    • model (string, required)
    • rounds (integer, required, min 1, max 9)
    • limit_reached (string, one of "rounds", "prompt_tokens")
    • usage (object, required)
      • prompt_tokens (integer)
      • completion_tokens (integer)
    • steps (array of object, required)
      • round (integer, required)
      • tool (string, required)
      • arguments (object, required)
      • status (integer, required)
      • error (string)
      • summary (string)
      • query (object) — usage_query only: the normalized query (from, to, group_by, bucket, timezone, metrics, filters, scope, scope_teams, order_by, order, limit)
    • proposals (array of AskAIProposal, max items 4) — T150, ask_ai_actions only: changes the model proposed in this answer. Nothing has run; each waits for its owner’s confirmation from the same session and expires 10 minutes after it was made.

POST /api/v1/admin/ask/proposals/{id}/confirm

Section titled “POST /api/v1/admin/ask/proposals/{id}/confirm”

POST /api/v1/admin/ask/proposals/{id}/confirm · operation confirmAskAIProposal

T150. Runs one m7 ai proposal, once, as the confirming user. Only the user who received it, from the same console session (bound to its CSRF secret; a bearer caller to its role and actor), can decide it; another user’s or session’s proposal answers 404. The claim is atomic on the database: a second confirmation, a replay or a concurrent click answers 409 proposal_decided, and a proposal past its expiry on the database clock 410 proposal_expired. The stored request (the server built it; the model never supplies a method, path or body) then runs through the existing admin route with this session, CSRF token and request ID <request_id>.ask-action, so that route authorizes it with the user’s live permissions and team scope, validates it, carries its version check and writes its own audit row; the claim itself is audited as ask_ai.<action>.confirm with this request’s ID. The answer is that route’s status and JSON (a created key’s secret appears here once, with no-store) plus proposal: id, action, state (executed or failed) and result_status; a 204 becomes 200. A failed change is not retried: ask again for a new proposal. Requires ask_ai, ask_ai_actions, usage_analytics and analytics:read, plus whatever the change’s own route requires.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^askp_[0-9a-f]{32}$
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Responses

Status Description Body
200 Ran; the change’s own answer plus proposal —
201 Ran and created a key or team; the change’s own answer plus proposal —
400 The change’s route refused the stored request (proposal state failed) —
403 CSRF check failed, or the change’s route refused this user (proposal state failed) —
404 Feature disabled, or no such proposal for this user and session —
409 proposal_decided, or the change’s route reported a version conflict (proposal state failed) —
410 proposal_expired —

POST /api/v1/admin/ask/proposals/{id}/cancel

Section titled “POST /api/v1/admin/ask/proposals/{id}/cancel”

POST /api/v1/admin/ask/proposals/{id}/cancel · operation cancelAskAIProposal

T150. Declines an m7 ai proposal: nothing runs, the proposal becomes cancelled and the decision is audited as ask_ai.<action>.cancel. An expired proposal can still be cancelled. The same owner and session binding as confirm; 409 proposal_decided once confirmed or cancelled. Requires ask_ai, ask_ai_actions, usage_analytics and analytics:read.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^askp_[0-9a-f]{32}$
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Responses

Status Description Body
200 Cancelled —
403 CSRF check failed —
404 Feature disabled, or no such proposal for this user and session —
409 proposal_decided —

GET /api/v1/admin/analytics · operation usageAnalytics

Inference usage by model, provider, principal, team, API key and operation. All six identity/routing filters compose before aggregation and comparison. Facets are top 20 groups, with explicit truncation metadata. token_reports counts events with at least one reported counter. Latency is end-to-end, not TTFT. Token counts are included when the upstream reports them; this report does not calculate cost; optional estimated valuation is exposed separately at /api/v1/admin/valuation. Scoped roles may query only one active membership at a time; an omitted team selects the first membership. When analytics_comparison is enabled, previous_summary uses the immediately preceding period of equal duration and the same filters. When analytics_status_breakdown is enabled, by_status groups HTTP response codes with the same filters. When evaluation_tracing is enabled, by_origin groups the calls by origin (app, evaluation, experiment, playground, helper, shadow) and by_helper_kind the helper calls by sub-kind, with the same filters, and origin (with helper_kind) narrows every figure to one of them. Requests, success, errors and latency count each client request once, without helper calls and fallback attempts (rows with parent_request_id), which are counted in tokens and in valuation.

Authentication: adminSession

Parameters

Name In Type Description
tags query string, max length 2048 Exact JSON object of at most four ASCII slug string pairs combined with AND before authorized aggregation/pagination. Historical values need not exist in current taxonomy. Single query value, at most 2 KiB, duplicate decoded keys rejected. Requires usage_tags; disabled returns 404 and projections omit stored tags.
end_user query string, min length 1, max length 128 Exact client-declared end user. Requires end_user_tracking; with the flag off the parameter is rejected. Applied in the shared usage predicate, so reports, comparisons, CSV, valuation and receipts agree.
origin query string, one of "app", "evaluation", "experiment", "playground", "helper", "shadow", "replay" T186.004: only the requests of one origin (how the request entered the gateway). Requires evaluation_tracing; with the flag off, or with another value, the parameter is rejected with 400 invalid_origin. A request log row with no origin (written before the flag, or with it off) is app. Applied in the shared usage predicate, so reports, valuation and the request log agree; day rollups are not used while it is set.
helper_kind query string, one of "guardrail", "classifier", "summary", "ask_ai", "cache_embedding", "tool_search", "vector_store", "model_test" T186.004 S3b: only the helper calls of one sub-kind (ask_ai is m7 ai). Requires origin=helper; anything else is rejected with 400 invalid_helper_kind. A fixed value, applied in the same shared usage predicate as origin.
tag_dimension query string, pattern ^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$ One exact historical tag name for optional top20 usage/valuation breakdown. Empty group means untagged. No global taxonomy discovery or completeness claim. Requires usage_tags.
from query string (date-time)
to query string (date-time)
principal query string
model query string
team query string
organization query string, pattern ^[a-z][a-z0-9_-]{1,63}$ Requires organizations. The requests recorded in one organization: each request counts for the organization it ran in, also after its team moved to another. A global role cannot combine it with team; an organization administrator may name only its own organization (403 otherwise), alone or with team; refused for team roles
provider query string, max length 256 Exact match; at most 256 UTF-8 bytes. Duplicate query values are rejected.
key_id query string, max length 256 Exact match; at most 256 UTF-8 bytes. Duplicate query values are rejected.
operation query string, max length 256 Exact match; at most 256 UTF-8 bytes. Duplicate query values are rejected.

Responses

Status Description Body
200 Aggregates and recent request metadata for a period of up to 90 days application/json: AnalyticsReport
400 Invalid input application/json: Error
401 Missing or invalid bearer key application/json: Error
404 Feature disabled application/json: Error

GET /api/v1/admin/analytics-store · operation analyticsStoreStatus

Optional analytics store (T019). engine is the analytics_store.engine value (clickhouse, the only engine today), absent while the block names none. state is not_configured (no analytics_store addresses), off (no purpose flag on, or the copy is off), copying (the copy is filling after an enable; reads use PostgreSQL), unreachable, behind (lag over max_lag; reads use PostgreSQL) or current. lag_seconds is now minus the start of the latest copy pass that found nothing more to copy: every event committed before it is in the analytics store; absent before the first complete pass. purposes are the analytics_store_usage and analytics_store_request_logs flags. Deployment-wide roles also get reachable, error_class, copy (cursor, pending_rows capped at 100000, open_gaps, pending_changes, copied_total, resets, last pass and last error class) and settings (engine, database, tls_mode, timeouts and copy bounds; never an address, environment name or file path); a team-scoped session gets only state, purposes and lag. Console permission analytics:read.

Authentication: adminSession

Responses

Status Description Body
200 Read store state application/json: object
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error
503 storage_unavailable —

Response 200 fields:

  • application/json: object
    • configured (boolean, required)
    • engine (string, one of "clickhouse")
    • state (string, required, one of "not_configured", "off", "copying", "unreachable", "behind", "current")
    • purposes (object, required)
      • analytics (boolean)
      • request_logs (boolean)
    • max_lag_seconds (number, required)
    • lag_seconds (number or null)
    • reachable (boolean)
    • error_class (string, pattern ^[a-z][a-z0-9_]{0,63}$)
    • copy (object)
      • enabled (boolean)
      • reset_pending (boolean)
      • cursor (integer)
      • caught_up_through (string (date-time))
      • lag_seconds (number)
      • last_pass_at (string (date-time))
      • last_error (string)
      • last_error_at (string (date-time))
      • copied_total (integer)
      • resets (integer)
      • pending_rows (integer, max 100000)
      • pending_rows_capped (boolean)
      • open_gaps (integer)
      • oldest_gap_seconds (number)
      • pending_changes (integer)
      • organization_backfill_pending (boolean) — Present and true while rows copied before migration 214 are copied again with their organization; state is then copying and reads use PostgreSQL.
    • settings (object)

GET /api/v1/admin/analytics/query · operation usageQuery

Structured usage query (T146): groups the usage history by any combination of dimensions and an optional calendar bucket in a time zone, with chosen metrics, exact filters, an order and a row limit. The server builds the SQL from fixed dimension and metric names, never from caller text, and runs it in a read-only transaction with a 5 s statement timeout (422 query_too_costly past it). Same data, permission (analytics:read), flag (usage_analytics), plan entitlements and 90-day range as the Analytics screen; reads raw usage events within retention, not rollups. Team-scoped roles see every team of their membership and nothing else: a team filter outside it is 403 team_forbidden. Dimensions and metrics require the flag that records or shows them: status and status_class (analytics_status_breakdown), end_user (end_user_tracking), session_id (session_tracking), organization (organizations), owner and owner_kind (identity_ownership), tag:<name> and tag.<name> filters (usage_tags), avg_ttfb_ms (request_timing); with feature plan entitlements a team role covers only teams whose plan includes those rights. Cost metrics require usage_valuation: cost_usd is the exact decimal sum of known valuations in USD and always comes with priced_requests and unpriced_requests, since unknown cost is never zero. Filters are repeated <dimension>=<value> parameters (up to 20 values each, 100 in all, 256 bytes each, no control characters), for example status=429&team=t1&team=t2. Response: query (the normalized query with scope all or teams), columns, rows (arrays in column order; bucket is the local wall-clock start with its offset, YYYY-MM-DDTHH:MM+hh:mm, in timezone), total_groups, truncated, source and, with cost, currency and cost_note.

Authentication: adminSession

Parameters

Name In Type Description
from query string (date-time) Default: 24 hours before to
to query string (date-time) Default: now; at most 90 days after from
group_by query string Comma-separated, up to 5 distinct: team, organization, model, requested_model, provider, key_id, principal, operation, status, status_class (2xx/4xx/5xx), error_code, guardrail, timeout_kind, cache_kind, service_tier, auto_route, pricing_status (complete, partial, inconsistent, unavailable; empty for a call that was not answered; with pricing_coverage, T186.021; not a dimension of evaluation results), end_user, session_id, owner (kind:id), customer_org, customer_team (org/team) and customer_member (org/member), the customer a trusted key named (customer_portal; over evaluation results stored in the analytics store customer_team answers 400), owner_kind (user, workload or empty), origin (evaluation_tracing; app for a row without one), helper_kind (evaluation_tracing; empty on every row but a helper call), prompt_id, prompt_revision and prompt_source (rendered, declared, system; prompt_tracking, T186.013; empty for a request that recorded no prompt; also dimensions of the judged request over evaluation results), prompt_label (prompt_labels, T186.013b; the label a request rendered by label resolved), tag:<name>. With evaluation_metrics, also the dimensions of evaluation results: evaluation, evaluator_id, assessment (pass, fail, none), evaluation_value (the label of a boolean or categorical result), evaluation_source, evaluator_version, evaluation_scope, metric_type, experiment_run (the run of an experiment result, empty for live traffic; naming it keeps experiment results in the query); naming one, or an evaluation metric, makes the query read evaluation results, where every other dimension is the judged request’s and origin is the result’s own (app or experiment). Omitted: one total row.
bucket query string, one of "minute", "hour", "day", "week", "month" minute covers at most 48 hours
timezone query string, default "UTC", max length 64 UTC or an IANA Area/Location zone for the buckets, such as America/Sao_Paulo; POSIX-style names (UTC+3, EST5EDT, Etc/GMT+3) are refused because PostgreSQL inverts their sign; 400 invalid_timezone when refused or unknown
metrics query string Comma-separated: requests, calls (every row, helper calls and fallback attempts included; requests, success, errors, error_rate and latency count client requests only), success, errors, error_rate, input_tokens, output_tokens, total_tokens, cached_input_tokens, token_reports, cost_usd, priced_requests, unpriced_requests, p50_cost_usd, p95_cost_usd, p99_cost_usd, max_cost_usd, avg_cost_usd (the known cost of one request as exact USD decimals, each percentile the cost of an actual request; cost_request_insights, 400 feature_disabled without it), avg_latency_ms, p50_latency_ms, p95_latency_ms, p99_latency_ms, avg_ttfb_ms. Default: requests, errors, input_tokens, output_tokens, p95_latency_ms, plus cost_usd with usage_valuation. Over evaluation results (evaluation_metrics): evaluations, evaluation_pass, evaluation_fail, pass_rate (pass / (pass + fail), null without either), mean_score, feedback_count, judge_cost_usd, evaluation_errors, evaluation_skipped; default evaluations, pass_rate; evaluations is always returned beside a rate or a mean; they cannot be mixed with the usage metrics (400).
order_by query string bucket, a grouped dimension or a requested metric. Default: bucket ascending with a bucket, else the first metric descending; order without order_by ranks by the first metric.
non_empty query string Comma-separated dimensions that must be set (not the empty value), such as guardrail or timeout_kind
order query string, one of "asc", "desc", default "desc"
limit query integer, default 100, min 1, max 500
compare query string, one of "previous" quality_kpi_cards (T186.021): previous also answers the same query (grouping, filters and order included) over the period of equal length just before the range, in previous. Requires the flag (400 feature_disabled); refused over evaluation results and for any other value (400 invalid_compare).

Responses

Status Description Body
200 The grouped table application/json: object
400 Invalid input application/json: Error
401 Missing or invalid bearer key application/json: Error
403 Team outside the session membership, or no team plan includes the operation —
404 Feature disabled application/json: Error
422 query_too_costly: the statement timeout ended the query —

Response 200 fields:

  • application/json: object
    • query (object, required)
    • columns (array of string, required)
    • rows (array of array of any, required)
    • total_groups (integer, required)
    • truncated (boolean, required)
    • source (string, required, one of "usage_events", "evaluation_results")
    • read_store (string) — evaluation_results only: database, or database+analytics_store when the analytics store holds part of the results; the counts of both are added before a rate is divided.
    • units (object) — evaluation_results only: what each column holds.
      • any other key: string
    • zero_filled (boolean) — evaluation_results only: a series ordered by bucket has every bucket of its range, the empty ones with zero counts and null rates.
    • note (string)
    • judge_cost_incomplete (integer) — With judge_cost_usd: runs whose cost is partial or unknown, not counted as zero.
    • currency (string, one of "USD")
    • cost_note (string)
    • previous (object) — compare=previous (quality_kpi_cards, T186.021): the same query over [from - (to - from), from).
      • from (string (date-time), required)
      • to (string (date-time), required)
      • columns (array of string, required)
      • rows (array of array of any, required)
      • total_groups (integer, required)
      • truncated (boolean, required)
    • display_currency (FXDisplay) — T168 fx_display, with cost_usd. When status is ok a cost_display column (converted, half to even at the currency’s minor units) follows the USD columns.

GET /api/v1/admin/analytics/views · operation analyticsViewList

T034.005. Requires usage_analytics, analytics_saved_views, storage and analytics:read. Lists the caller’s own views and the effective team shares it may read: global admin and viewer read shares of every team, user, team_admin and team_viewer only shares of their live teams. A share is effective only while its owner is the bootstrap administrator, a live global user, or a live user/team_admin/team_viewer member of that team and the team is not deleted; otherwise only the owner sees it (share_effective false). Own views first, then most recently updated; at most 200 items (truncated). No query parameters (400). A view holds no usage data: loading it runs GET /api/v1/admin/analytics with the reader’s own authorization. no-store.

Authentication: adminSession

Responses

Status Description Body
200 Visible views application/json: object
400 Invalid input application/json: Error
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error
503 Storage or live identity unavailable —

Response 200 fields:

  • application/json: object
    • items (array of AnalyticsView, required, max items 200)
    • truncated (boolean, required)
    • own_count (integer, required, min 0)
    • own_limit (50, required)
    • total_limit (10000, required)

POST /api/v1/admin/analytics/views · operation analyticsViewCreate

T034.005. Requires analytics_saved_views and analytics_views:save (admin, viewer, user, team_admin, team_viewer), same-origin CSRF. Stores a view owned by the session identity (the bootstrap administrator owns its own views; the shared viewer token cannot write, 403). With team feature plans, a team role writes only for teams whose plan includes usage_analytics. team shares it read-only with one team: any existing team for a global admin or viewer, one of the caller’s live teams for a scoped role (403 otherwise); omit it or send null for a private view. At most 50 views per owner and 10000 in total (409 view_capacity). Audited as analytics_view.create.

Authentication: adminSession

Parameters

Name In Type Description
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

Responses

Status Description Body
201 Stored view at version 1 application/json: AnalyticsView
400 Invalid input application/json: Error
401 Missing or invalid bearer key application/json: Error
403 Role, CSRF or share team not allowed —
404 Feature disabled application/json: Error
409 view_capacity: 50 per owner or 10000 in total —
413 Body over 32 KiB —
422 invalid_view or invalid_view_definition —
503 Storage unavailable —

GET /api/v1/admin/analytics/views/{id} · operation analyticsViewDetail

T034.005. One view the caller may read (see the list rule); anything else answers 404. No query parameters. no-store.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^av_[a-f0-9]{24}$

Responses

Status Description Body
200 View application/json: AnalyticsView
400 Invalid input application/json: Error
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled or view not visible —
503 Storage unavailable —

PUT /api/v1/admin/analytics/views/{id} · operation analyticsViewUpdate

T034.005. Owner only (403 for a readable foreign view, 404 for an unreadable one). Replaces name, description, team and definition as a whole: an omitted team makes the view private, which revokes the share at once. version must equal the stored version (409 version_conflict) and increments by one. Audited as analytics_view.update.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^av_[a-f0-9]{24}$
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

Responses

Status Description Body
200 Updated view application/json: AnalyticsView
400 Invalid input application/json: Error
401 Missing or invalid bearer key application/json: Error
403 Not the owner, CSRF or share team not allowed —
404 Feature disabled or view not visible —
409 version_conflict —
413 Body over 32 KiB —
422 invalid_view or invalid_view_definition —
503 Storage unavailable —

DELETE /api/v1/admin/analytics/views/{id} · operation analyticsViewDelete

T034.005. The owner, or a global admin for a view it can read (moderation), deletes the view at exactly one positive version query parameter (409 version_conflict when stale). Audited as analytics_view.delete.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^av_[a-f0-9]{24}$
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.
version query integer, required, min 1

Responses

Status Description Body
204 Deleted —
400 Invalid input application/json: Error
401 Missing or invalid bearer key application/json: Error
403 Neither the owner nor a global admin, or CSRF —
404 Feature disabled or view not visible —
409 version_conflict —
503 Storage unavailable —

GET /api/v1/admin/dashboards · operation listDashboards

Custom dashboards (T210, flag custom_dashboards). A dashboard is a named page of widgets with a time range. It stores no telemetry: each widget is answered through the route of its source with the reader’s own live authorization, so a shared dashboard never shows a reader more than the screens would. A dashboard is private, a team’s or an organization’s. The list holds the caller’s own dashboards, those of its teams (every team for a gateway-wide role) and those of the organizations of its teams, without their definitions; a team’s dashboard records the organization the team was in when it was shared, and a team that moved to another organization no longer reads it. Requires dashboards:read. access says what this session may do: save (dashboards:save in a named session; a shared token names nobody), and the teams and organization it may share with (dashboards:share: the teams it administers, its organization for an organization admin, any for the administrator).

Authentication: adminSession

Responses

Status Description Body
200 The dashboards this session sees application/json: object
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 custom_dashboards disabled (feature_disabled) —

Response 200 fields:

  • application/json: object
    • items (array of Dashboard, required, max items 500)
    • builtin (array of Dashboard) — The dashboards the product maintains whose features are on: dbb_traffic, dbb_cost (usage_valuation), dbb_latency, dbb_quality (evaluation_metrics), dbb_traces (span_store, trace_explorer)
    • truncated (boolean, required)
    • own_count (integer, required)
    • own_limit (integer, required) — dashboards.per_owner
    • total_limit (integer, required) — dashboards.total
    • access (object, required)
      • save (boolean, required)
      • share_all (boolean, required)
      • share_teams (array of string, required)
      • share_organization (string, required)
      • organizations (boolean, required) — The organizations feature is on: a dashboard may belong to an organization

POST /api/v1/admin/dashboards · operation createDashboard

Custom dashboards (T210, custom_dashboards). Stores a dashboard owned by the session identity, as version 1. visibility private (the default) takes dashboards:save; team with team, or organization with organization, also takes dashboards:share for that team or organization (403 otherwise). The definition is validated against the fixed names of the usage query and the trace chart: a metric over requests takes no dimension of evaluation results and an evaluation metric no pricing_status, the filters of a widget hold at most 94 values in all, a custom range does not end in the future, and a query of source traces must be one the language reads with room for the team term of a shared dashboard (422 invalid_dashboard_definition, naming the widget); whether a reader may use each name (a flag, a plan, a permission) is decided when the reader’s widget is answered. A dashboard may have no widgets. At most dashboards.per_owner dashboards per owner (default 50) and dashboards.total in all (default 5000): 409 dashboard_capacity. Audited as dashboard.create.

Authentication: adminSession

Parameters

Name In Type Description
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

Responses

Status Description Body
201 The stored dashboard application/json: Dashboard
400 invalid_request —
401 Missing or invalid bearer key application/json: Error
403 role_forbidden: no dashboards:save, a shared token, or no dashboards:share for the team or organization; or a missing CSRF token —
404 custom_dashboards disabled (feature_disabled) —
409 dashboard_capacity —
422 invalid_dashboard or invalid_dashboard_definition —

GET /api/v1/admin/dashboards/settings · operation getDashboardSettings

Custom dashboards (T210, custom_dashboards). The dashboards block in effect, with where each value comes from (configuration or default), and the names a widget may use on this gateway now: the usage query’s metrics and dimensions whose flags are on, the evaluation metrics and dimensions with evaluation_metrics on, whether usage tags and the traces source are available. The block is part of the configuration file and is read at startup; the API and the console show it and do not change it. Requires dashboards:read.

Authentication: adminSession

Responses

Status Description Body
200 The settings in effect application/json: object
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 custom_dashboards disabled (feature_disabled) —

Response 200 fields:

  • application/json: object
    • dashboards (object, required)
      • per_owner (integer, required, min 1, max 500) — Default 50
      • total (integer, required, min 1, max 100000) — Default 5000
      • widgets_per_dashboard (integer, required, min 1, max 60) — Default 24
      • versions_kept (integer, required, min 1, max 500) — Default 50
      • library_per_owner (integer, min 1, max 1000) — Default 100
      • library_total (integer, min 1, max 100000) — Default 10000
    • sources (object, required)
      • any other key: string
    • applies (string, required, one of "restart")
    • widget (object, required)
      • types (array of string, required)
      • ranges (array of string, required)
      • buckets (array of string, required)
      • charts (array of string, required)
      • sizes (array of string, required)
      • experiments (boolean) — evaluation_metrics is on: the experiments source is available
      • series (integer, required) — Groups a time series draws: the largest by the widget’s metric (5)
      • usage (object, required)
        • metrics (array of string, required)
        • dimensions (array of string, required)
        • evaluation_metrics (array of string, required)
        • evaluation_dimensions (array of string, required)
        • tags (boolean, required) — usage_tags is on: tag:<name> groups and tag.<name> filters
      • traces (object, required)
        • available (boolean, required) — span_store and trace_explorer are on
        • query_language (boolean, required) — trace_query is on: OR, NOT, groups and lists in a widget’s query
        • scopes (array of string, required)
        • metrics (array of string, required)
        • group_by (array of string, required)

POST /api/v1/admin/dashboards/preview · operation previewDashboardWidget

Custom dashboards (T210, custom_dashboards). Answers a widget that is not saved yet, for the builder’s live preview. It stores nothing. The widget is the widget itself, never a link to the library, validated as on a save and answered as GET /dashboards/{id}/widgets/{widget}/data answers a stored one, with the caller’s own authorization; visibility with team or organization narrows it as it will once the dashboard is saved there (a team the caller may not read answers 403 team_forbidden). The range is range (1h, 6h, 24h, 7d, 30d, 90d; default 24h) or from and to. Requires dashboards:save.

Authentication: adminSession

Parameters

Name In Type Description
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • widget (DashboardWidget, required)
    • visibility (string, one of "private", "team", "organization", default "private")
    • team (string, max length 256)
    • organization (string, max length 256)
    • range (string, one of "1h", "6h", "24h", "7d", "30d", "90d")
    • from (string (date-time))
    • to (string (date-time))
    • timezone (string, max length 64)

Responses

Status Description Body
200 The widget’s data application/json: DashboardWidgetData
400 invalid_request, invalid_range or invalid_timezone —
401 Missing or invalid bearer key application/json: Error
403 role_forbidden (no dashboards:save, or the source’s own permission), team_forbidden, entitlement_forbidden; or a missing CSRF token —
404 custom_dashboards disabled (feature_disabled) —
409 widget_source_disabled: a feature the widget’s source, metric or dimension needs is off —
422 invalid_dashboard, invalid_dashboard_definition, widget_has_no_data (a Markdown widget), widget_query_refused or query_too_costly —
429 rate_limited —
503 storage_unavailable —

GET /api/v1/admin/dashboards/{id} · operation getDashboard

Custom dashboards (T210, custom_dashboards). One dashboard the session sees, with its definition. A dashboard of another owner, team or organization answers 404, never 403. The ETag is the version. Requires dashboards:read.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^(db_[a-f0-9]{24}|dbb_[a-z]{2,24})$ A stored dashboard, or for a read a built-in one (an update or a delete of a built-in one answers 400)

Responses

Status Description Body
200 The dashboard application/json: Dashboard
400 invalid_id —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 dashboard_not_found, or custom_dashboards disabled (feature_disabled) —

PUT /api/v1/admin/dashboards/{id} · operation updateDashboard

Custom dashboards (T210, custom_dashboards). Replaces a dashboard when version is the stored one (409 version_conflict otherwise) and writes the save as a new version; the oldest versions past dashboards.versions_kept (default 50) are dropped. A save that changes where the dashboard lives (its visibility, team or organization) removes the earlier versions: they were saved for another audience. A private dashboard is edited by its owner; a shared one by whoever holds dashboards:share for its team or organization, and placing it elsewhere takes dashboards:share for the target too. A dashboard becomes private only for its own author. Audited as dashboard.update.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^(db_[a-f0-9]{24}|dbb_[a-z]{2,24})$ A stored dashboard, or for a read a built-in one (an update or a delete of a built-in one answers 400)
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

Responses

Status Description Body
200 The stored dashboard application/json: Dashboard
400 invalid_request or invalid_id —
401 Missing or invalid bearer key application/json: Error
403 role_forbidden; or a missing CSRF token —
404 dashboard_not_found, or custom_dashboards disabled (feature_disabled) —
409 version_conflict —
422 invalid_dashboard or invalid_dashboard_definition —

DELETE /api/v1/admin/dashboards/{id} · operation deleteDashboard

Custom dashboards (T210, custom_dashboards). Removes a dashboard at version, with its versions. Its owner may always remove it; so may whoever holds dashboards:share for the team or organization it is shared with. Audited as dashboard.delete.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^(db_[a-f0-9]{24}|dbb_[a-z]{2,24})$ A stored dashboard, or for a read a built-in one (an update or a delete of a built-in one answers 400)
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.
version query integer, required, min 1 The version the caller read: a dashboard changed since is not removed (409)

Responses

Status Description Body
204 Removed —
400 invalid_request or invalid_id —
401 Missing or invalid bearer key application/json: Error
403 role_forbidden; or a missing CSRF token —
404 dashboard_not_found, or custom_dashboards disabled (feature_disabled) —
409 version_conflict —

GET /api/v1/admin/dashboards/{id}/versions

Section titled “GET /api/v1/admin/dashboards/{id}/versions”

GET /api/v1/admin/dashboards/{id}/versions · operation listDashboardVersions

Custom dashboards (T210, custom_dashboards). The kept versions of a dashboard the session sees, newest first, without their definitions. Every create, update and restore is one; kept is dashboards.versions_kept. Requires dashboards:read.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^db_[a-f0-9]{24}$

Responses

Status Description Body
200 The kept versions application/json: object
400 invalid_id —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 dashboard_not_found, or custom_dashboards disabled (feature_disabled) —

Response 200 fields:

  • application/json: object

GET /api/v1/admin/dashboards/{id}/versions/{version}

Section titled “GET /api/v1/admin/dashboards/{id}/versions/{version}”

GET /api/v1/admin/dashboards/{id}/versions/{version} · operation getDashboardVersion

Custom dashboards (T210, custom_dashboards). One kept version with its definition: the name, description and widgets as that save left them. Requires dashboards:read.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^db_[a-f0-9]{24}$
version path integer, required, min 1

Responses

Status Description Body
200 The version application/json: DashboardVersion
400 invalid_id —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 dashboard_not_found (the dashboard, or a version dropped past dashboards.versions_kept), or custom_dashboards disabled (feature_disabled) —

POST /api/v1/admin/dashboards/{id}/versions/{version}/restore

Section titled “POST /api/v1/admin/dashboards/{id}/versions/{version}/restore”

POST /api/v1/admin/dashboards/{id}/versions/{version}/restore · operation restoreDashboardVersion

Custom dashboards (T210, custom_dashboards). Saves the name, description and definition of a kept version again as the newest version (restored_from names it); where the dashboard lives does not change. The body’s version is the dashboard’s current version, as on an update. The same rights as an update. A version that the widget bound in effect no longer admits answers 422. Audited as dashboard.restore.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^db_[a-f0-9]{24}$
version path integer, required, min 1
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • version (integer, required, min 1) — The dashboard’s current version

Responses

Status Description Body
200 The dashboard as restored application/json: Dashboard
400 invalid_request or invalid_id —
401 Missing or invalid bearer key application/json: Error
403 role_forbidden; or a missing CSRF token —
404 dashboard_not_found, or custom_dashboards disabled (feature_disabled) —
409 version_conflict —
422 invalid_dashboard_definition —

GET /api/v1/admin/dashboards/{id}/widgets/{widget}/data

Section titled “GET /api/v1/admin/dashboards/{id}/widgets/{widget}/data”

GET /api/v1/admin/dashboards/{id}/widgets/{widget}/data · operation getDashboardWidgetData

Custom dashboards (T210, custom_dashboards). The data of one widget of a dashboard the session sees. The gateway answers it with the reads a screen would make, as the caller: GET /analytics/query for a widget of source usage, GET /traces/chart (without the gateway’s own calls) for one of source traces. So the permission of that route (analytics:read, logs:read), the feature flags, the team plan and the team scope apply as they do on the screen, and the figures are the ones those routes return; reads lists them. A team’s dashboard reads that team alone and an organization’s dashboard that organization, by one rule on every source (the organization filter of the usage query; the organization term of the query language): the rows recorded in the organization, and the rows recording none whose team is in it now; in both cases only as far as the caller may read them. A widget that links the library is answered as the library widget it links (404 library_widget_not_found when the link no longer holds). A table answers columns, rows and units. A widget’s own filter on the dashboard’s team or organization narrows within it (one that names another matches nothing). A time series with a breakdown draws the 5 largest groups by its metric (source usage: groups_total says how many there are; source traces: more_groups says there are more); a usage series has every bucket of the range, zero for a count and null for any other metric, and never more than 100 buckets (the interval widens instead); a single figure that is not a count is null when the range has no requests. Without from and to, or range, the dashboard’s own range applies. Requires dashboards:read.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^(db_[a-f0-9]{24}|dbb_[a-z]{2,24})$
widget path string, required, pattern ^w_[a-z0-9]{4,24}$
range query string, one of "1h", "6h", "24h", "7d", "30d", "90d" A range ending now, in place of the dashboard’s own
from query string (date-time) Start of the range (RFC 3339), with to; at most 90 days before it
to query string (date-time) End of the range (RFC 3339, exclusive), with from; not in the future
timezone query string, max length 64 IANA zone of calendar buckets; default the dashboard’s, else UTC
version query integer, min 1 Read the widget as this kept version had it

Responses

Status Description Body
200 The widget’s data application/json: DashboardWidgetData
400 invalid_request, invalid_id, invalid_range or invalid_timezone —
401 Missing or invalid bearer key application/json: Error
403 role_forbidden (no dashboards:read, or the source’s own permission), team_forbidden or entitlement_forbidden —
404 dashboard_not_found, widget_not_found, library_widget_not_found, or custom_dashboards disabled (feature_disabled) —
409 widget_source_disabled: a feature the widget’s source, metric or dimension needs is off —
422 widget_has_no_data (a Markdown widget), widget_query_refused or query_too_costly —
429 rate_limited —
503 storage_unavailable —

POST /api/v1/admin/dashboards/{id}/copy · operation copyDashboard

Custom dashboards (T210b, custom_dashboards). Makes a new dashboard, owned by the caller, from one the session sees, a built-in one included. The copy takes the source’s definition and, unless the body gives one, its description; it is placed where the body says (private by default; team or organization takes dashboards:share for it) and starts at version 1 with its own versions. The widget bound in effect applies as on any save. A link to the library is kept where the copy’s audience reads its library widget, replaced by the widget itself where only the source’s does, and left out when it no longer holds. Audited as dashboard.create.

Authentication: adminSession

Parameters

Name In Type Description
id path string, required, pattern ^(db_[a-f0-9]{24}|dbb_[a-z]{2,24})$
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

  • application/json: object
    • name (string, required, min length 1, max length 120)
    • description (string, max length 500)
    • visibility (string, one of "private", "team", "organization", default "private")
    • team (string, max length 256)
    • organization (string, max length 256)

Responses

Status Description Body
201 The copy application/json: Dashboard
400 invalid_request or invalid_id —
401 Missing or invalid bearer key application/json: Error
403 role_forbidden; or a missing CSRF token —
404 dashboard_not_found, or custom_dashboards disabled (feature_disabled) —
409 dashboard_capacity —
422 invalid_dashboard or invalid_dashboard_definition —

GET /api/v1/admin/dashboard-widgets · operation listDashboardLibraryWidgets

The widget library (T210b, custom_dashboards). A library widget is a widget kept by itself, private, of a team or of an organization, that dashboards link by ID instead of copying: a dashboard that links one shows it as it is when the dashboard is read. The list holds the caller’s own library widgets, those of its teams and those of the organizations of its teams, by the visibility rules of dashboards. Requires dashboards:read.

Authentication: adminSession

Responses

Status Description Body
200 The library widgets this session sees application/json: object
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 custom_dashboards disabled (feature_disabled) —

Response 200 fields:

  • application/json: object
    • items (array of DashboardLibraryWidget, required, max items 500)
    • truncated (boolean, required)
    • own_limit (integer, required) — dashboards.library_per_owner
    • total_limit (integer, required) — dashboards.library_total

POST /api/v1/admin/dashboard-widgets · operation createDashboardLibraryWidget

The widget library (T210b, custom_dashboards). Keeps a widget in the library, owned by the caller. widget is what it shows, validated as a dashboard’s widget and without id, size or library (a dashboard that links it gives it its place and size); its title is the library widget’s name. visibility private (the default) takes dashboards:save; team or organization also dashboards:share for it. At most dashboards.library_per_owner per owner (default 100) and dashboards.library_total in all (default 10000): 409 library_capacity. Audited as dashboard_widget.create.

Authentication: adminSession

Parameters

Name In Type Description
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

Responses

Status Description Body
201 The stored library widget application/json: DashboardLibraryWidget
400 invalid_request —
401 Missing or invalid bearer key application/json: Error
403 role_forbidden; or a missing CSRF token —
404 custom_dashboards disabled (feature_disabled) —
409 library_capacity —
422 invalid_dashboard or invalid_dashboard_definition —

GET /api/v1/admin/dashboard-widgets/{widget}

Section titled “GET /api/v1/admin/dashboard-widgets/{widget}”

GET /api/v1/admin/dashboard-widgets/{widget} · operation getDashboardLibraryWidget

The widget library (T210b, custom_dashboards). One library widget the session sees; another owner’s, team’s or organization’s answers 404. Requires dashboards:read.

Authentication: adminSession

Parameters

Name In Type Description
widget path string, required, pattern ^lw_[a-f0-9]{24}$

Responses

Status Description Body
200 The library widget application/json: DashboardLibraryWidget
400 invalid_id —
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 library_widget_not_found, or custom_dashboards disabled (feature_disabled) —

PUT /api/v1/admin/dashboard-widgets/{widget}

Section titled “PUT /api/v1/admin/dashboard-widgets/{widget}”

PUT /api/v1/admin/dashboard-widgets/{widget} · operation updateDashboardLibraryWidget

The widget library (T210b, custom_dashboards). Replaces a library widget when version is the stored one (409 version_conflict otherwise). Every dashboard that links it shows the new one from then on. The rights are those of a dashboard’s update: its owner while it is private, whoever holds dashboards:share for its team or organization once shared; a dashboard whose audience the widget no longer covers says so in the widget’s place. Audited as dashboard_widget.update.

Authentication: adminSession

Parameters

Name In Type Description
widget path string, required, pattern ^lw_[a-f0-9]{24}$
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Request body (required)

Responses

Status Description Body
200 The stored library widget application/json: DashboardLibraryWidget
400 invalid_request or invalid_id —
401 Missing or invalid bearer key application/json: Error
403 role_forbidden; or a missing CSRF token —
404 library_widget_not_found, or custom_dashboards disabled (feature_disabled) —
409 version_conflict —
422 invalid_dashboard or invalid_dashboard_definition —

DELETE /api/v1/admin/dashboard-widgets/{widget}

Section titled “DELETE /api/v1/admin/dashboard-widgets/{widget}”

DELETE /api/v1/admin/dashboard-widgets/{widget} · operation deleteDashboardLibraryWidget

The widget library (T210b, custom_dashboards). Removes a library widget at version. A dashboard that links it answers 404 library_widget_not_found for that widget and is otherwise unchanged. Audited as dashboard_widget.delete.

Authentication: adminSession

Parameters

Name In Type Description
widget path string, required, pattern ^lw_[a-f0-9]{24}$
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.
version query integer, required, min 1 The version the caller read: a library widget changed since is not removed (409)

Responses

Status Description Body
204 Removed —
400 invalid_request or invalid_id —
401 Missing or invalid bearer key application/json: Error
403 role_forbidden; or a missing CSRF token —
404 library_widget_not_found, or custom_dashboards disabled (feature_disabled) —
409 version_conflict —

GET /api/v1/admin/analytics/stages · operation analyticsStageCoverage

T168 (stage_denominators, requires usage_analytics): how many inference requests reached each stage in the range, installation-wide, refusals before persistence included. received: reached the gateway; authenticated: a key was identified; admitted: a provider send started or the cache answered; responded: an admitted request answered 2xx; persisted: its usage event was written; valued: that event carries a priced valuation; reconciled: its budget reservation settled from a proven measurement. Counts are added in memory and flushed every flush_seconds, so the latest minute is still filling. coverage is count / received (null without received requests). Requires analytics:read and a global role: a team-scoped session answers 403.

Authentication: adminSession

Parameters

Name In Type Description
from query string (date-time) Start, RFC 3339, truncated to the minute (default: 24 hours before to)
to query string (date-time) End, exclusive, truncated to the minute (default: the next minute); at most 31 days after from

Responses

Status Description Body
200 Stage counts application/json: object
400 Invalid input application/json: Error
401 Missing or invalid bearer key application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

Response 200 fields:

  • application/json: object
    • from (string (date-time), required)
    • to (string (date-time), required)
    • flush_seconds (integer, required)
    • stages (array of object, required)
      • stage (string, required, one of "received", "authenticated", "admitted", "responded", "persisted", "valued", "reconciled")
      • count (integer, required, min 0)
      • coverage (number or null, required, min 0)

GET /api/v1/admin/analytics/rollups · operation analyticsRollups

Daily usage aggregates from rollups rebuilt every five minutes for today and yesterday (analytics_rollups). Days never built are listed in missing_days, never reported as zero; built_at is the oldest build in the range. Team-scoped sessions see only their team.

Authentication: adminSession

Parameters

Name In Type Description
from query string (date) First UTC day (default: 6 days ago)
to query string (date) Last UTC day (default: today); at most 90 days
team query string Only this team’s daily aggregates.

Responses

Status Description Body
200 Daily rollups application/json: object
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error

Response 200 fields:

  • application/json: object
    • days (array of object, required)
      • day (string (date), required)
      • requests (integer, required)
      • errors (integer, required)
      • input_tokens (integer, required)
      • output_tokens (integer, required)
      • duration_ms_sum (integer, required)
    • by_model (array of object, required)
      • model (string, required)
      • requests (integer, required)
      • input_tokens (integer, required)
      • output_tokens (integer, required)
    • built_at (string (date-time))
    • missing_days (array of string (date), required)

POST /api/v1/admin/analytics/rollups/rebuild

Section titled “POST /api/v1/admin/analytics/rollups/rebuild”

POST /api/v1/admin/analytics/rollups/rebuild · operation rebuildAnalyticsRollups

Rebuild whole UTC days from persisted events (late events and retention deletions included). Replicas serialize on an advisory lock. The call rebuilds the range in one transaction and answers 204. It answers 202 when days were left to the background rebuild instead: a day too large to aggregate in one statement, which is built in slices, or a range that did not fit the two minutes of the call. Those days need no second request; each keeps its earlier rollup until its rebuild is done, and GET /api/v1/admin/analytics/rollups shows built_at move when it is. Admin only (analytics:rebuild).

Authentication: adminSession

Parameters

Name In Type Description
from query string (date) First UTC day to rebuild, YYYY-MM-DD.
to query string (date) Last UTC day to rebuild, YYYY-MM-DD.
X-CSRF-Token header string, required Token returned by admin login/session; required with the same-origin session cookie for writes.

Responses

Status Description Body
202 Days of the range were queued for the background rebuild; nothing else is needed from the caller application/json: object
204 Every day of the range was rebuilt by this call —
400 Invalid input application/json: Error
403 Model not allowed application/json: Error
404 Feature disabled application/json: Error
503 storage_unavailable: the rebuild failed and no day was queued —

Response 202 fields:

  • application/json: object
    • queued (boolean, required, one of true)
    • from (string (date), required) — First UTC day of the requested range.
    • to (string (date), required) — Last UTC day of the requested range.
    • days (integer, required, min 1) — Days of the range that were queued. The other days of the range, if any, were rebuilt by this call.

GET /api/v1/admin/analytics/export · operation exportUsageAnalytics

Requires analytics_export and analytics:read. Same authorized filters as analytics, at most 90 days. CSV exports the summary and at most 20 groups per dimension, not a full event dump. Formula cells are neutralized; missing usage remains unknown. No financial totals.

Authentication: adminSession

Parameters

Name In Type Description
tags query string, max length 2048 Exact JSON object of at most four ASCII slug string pairs combined with AND before authorized aggregation/pagination. Historical values need not exist in current taxonomy. Single query value, at most 2 KiB, duplicate decoded keys rejected. Requires usage_tags; disabled returns 404 and projections omit stored tags.
end_user query string, min length 1, max length 128 Exact client-declared end user. Requires end_user_tracking; with the flag off the parameter is rejected. Applied in the shared usage predicate, so reports, comparisons, CSV, valuation and receipts agree.
tag_dimension query string, pattern ^[A-Za-z0-9][A-Za-z0-9_.-]{0,63}$ One exact historical tag name for optional top20 usage/valuation breakdown. Empty group means untagged. No global taxonomy discovery or completeness claim. Requires usage_tags.
from query string (date-time)
to query string (date-time)
principal query string
model query string
team query string
provider query string, max length 256 Exact match; at most 256 UTF-8 bytes. Duplicate query values are rejected.
key_id query string, max length 256 Exact match; at most 256 UTF-8 bytes. Duplicate query values are rejected.
operation query string, max length 256 Exact match; at most 256 UTF-8 bytes. Duplicate query values are rejected.

Responses

Status Description Body
200 Bounded authorized analytics CSV text/csv: string
400 Invalid request or interval beyond 90 days —
401 Authentication required —
403 Resource or team forbidden —
404 Feature disabled or resource unavailable —
503 Storage or operation capacity unavailable —

m7gtw[email protected]