Aggregate token usage across authorized Projects
GET /api/v1/analytics/token-usage
Specify projectId for a single Project. A Session must specify organizationId to aggregate across Projects. Organization-scoped credentials may omit both. Includes only Projects with whole-Project analytics permission and a live permitted role. Environment-only or Agent-only credentials use the Environment analytics endpoint. Filters apply before aggregation and pagination. Token totals are exact decimal strings; missing counters are reported separately. No historical backfill or pricing is inferred.
Parameters
query
| Name | Type | Required | Description |
|---|---|---|---|
projectId | string | optional | Filters results to the specified Project. Applies to Aggregate token usage across authorized Projects. |
organizationId | string | optional | Selects the organization for the aggregate report. Required for sessions when projectId is omitted. Omit when selecting a single Project. |
from | string | required | Sets the inclusive start of the Analytics time window. Applies to Aggregate token usage across authorized Projects. |
to | string | required | Sets the exclusive end of the Analytics time window. Applies to Aggregate token usage across authorized Projects. |
provider | "anthropic" | "google" | "openai" | "azure-openai" | "amazon-bedrock" | "google-vertex" | "deepseek" | "fireworks" | optional | Filters recorded invocations to the exact provider. |
requestedModel | string | optional | Filters recorded invocations to the exact requested model identifier. |
groupBy | "project" | "environment" | "model" | "provider" | "none" | optional | Groups authorized Projects by Project alone, by Environment, by provider, or by requested/response model. None returns a combined total. |
granularity | "hour" | "day" | "none" | optional | Uses UTC hourly or daily buckets, or none for the entire interval. |
limit | integer | optional | Sets the maximum number of resources returned in this page. Applies to Aggregate token usage across authorized Projects. |
offset | integer | optional | Skips ordered breakdown rows. Summary and included Project IDs cover the whole authorized query, independent of pagination. |
Responses
| Status | Description | Body |
|---|---|---|
200 | Response for status 200 | application/json — object — summary: object (required); rows: array<object> (required); nextOffset: integer | null (required); coverage: object (required); projectIds: array<string> (required) |
400 | The request is malformed or cannot be processed. | application/json — PublicApiError — error: object (required) |
401 | Authentication failed. The Authorization header is missing, or the credential is invalid or expired. | application/json — PublicApiError — error: object (required) |
403 | Access denied. The authenticated user does not have permission to perform this action. | application/json — PublicApiError — error: object (required) |
404 | Resource not found. | application/json — PublicApiError — error: object (required) |
409 | Request conflicts with current state of the resource, including safe deployment conflict classifications. | application/json — PublicApiError — error: object (required) |
422 | Request validation failed. Check the request body, query parameters, or path parameters. | application/json — PublicApiError — error: object (required) |
429 | Too many requests. | application/json — PublicApiError — error: object (required) |
500 | The server could not complete the request. | application/json — PublicApiError — error: object (required) |
503 | Service temporarily unavailable (e.g. execution capacity exhausted). The response carries a Retry-After header; retry with backoff. | application/json — PublicApiError — error: object (required) |