POST /api/v1/analytics/query runs a query against a versioned analytics
catalog model.
Request
The request body is strict JSON:
Member names are 1 to 64 characters. A member may appear once per list: a
repeat inside
metrics, dimensions, or order returns invalid_query.
start and end are inclusive local calendar dates in the requested IANA
timezone. Filters apply to dimensions only. Order terms must reference
selected metrics or dimensions. A totals query with no dimensions returns a
single row and rejects order with invalid_query.
For both analytics models, the agent_id filter accepts either the agent’s UUID
or its optional slug.
Slug resolution is point-in-time: a slug filter matches whichever agent currently
holds that slug, not the agent it identified when the filter was written. Because
agent_id always returns the agent UUID, pin the UUID instead of the slug for
filters that must stay stable across renames.
The response is a columnar table. columns describes each position in every
row. A selected dimension is followed by its companion fields, then selected
metrics. The catalog lists all valid members and companion behavior.
The
agent_runs grain is one agent run. Excluded sub-agents are not counted
separately. Its event clock is createdAt. This is a run view, not an
interaction view. It does not count individual messages, tool calls, or other
activity inside a run.
The agent_user_activity grain is one attribution record for an identified
person and an agent run. Its event clock is occurredAt, so the range
describes when a person started, was associated with, or interacted with a run.
Run-count metrics count unique person-and-run combinations. interaction_count
counts every recorded interaction. The catalog defines these
terms.
Totals queries with no dimensions always return one row and never paginate. A
grouped query ordered by dimensions may return an opaque cursor. A grouped
query ordered by a metric is a single-page top-N result and returns
cursor: null.
Non-additive metrics such as run_success_rate and unique_initiator_count add a
warning when selected. run_success_rate is completed divided by completed plus
failed, and is null when that denominator is zero. unique_initiator_count
ignores null identifiers. An automated starter counts when it has an identifier.
Examples
The examples below use the deterministic development dataset.queryId,
asOf, and opaque cursor values vary on each request.
Totals
Per-user
Attribution totals
Attribution records by person
Per-agent grouped
Filtered
Paginated
cursor.
Keep the other fields unchanged; cursors are signed to the organization and
the canonical query.