Usage analytics (full)
GET /api/v1/billing/usage
Returns the authenticated account's usage records, pagination metadata, and totals computed over the same optional filters. Requires billing.read; per_page defaults to 50 and is capped at 100. to must not precede from, and the date range cannot exceed 366 days. This list uses offset pagination ordered by created_at DESC, then id DESC. Keep the same filters and per_page value for every page. If rows are added or deleted while paging, rows can repeat or be skipped. Restart at page 1 after the list has stopped changing for a fresh traversal; this endpoint does not provide a point-in-time snapshot. This operation is also available under the versioned path.
Authenticate with a portal session token.
Parameters
fromstring (date) querytostring (date) queryMust be on or after from.
providerstring queryLength: at most 64 characters. Pattern:^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$per_pageinteger queryDefault:50. Range: 1 to 100
Responses
200 Paginated usage records and totals over the same optional filters.
application/json object
paginationobject requiredcurrent_pageinteger requiredlast_pageinteger requiredper_pageinteger requiredRange: 1 to 100totalinteger required
recordsarray of object requiredEach item:
provider_cost_microsinteger requiredExact provider cost in USD micro-dollars; legacy cents-only rows are returned as the corresponding cents × 10,000.
markup_microsinteger requiredExact markup in USD micro-dollars; legacy cents-only rows are returned as the corresponding cents × 10,000.
total_cost_microsinteger requiredExact billed cost in USD micro-dollars; legacy cents-only rows are returned as the corresponding cents × 10,000.
has_receiptboolean requiredWhether a signed receipt is linked to this usage record.
cache_usageanyPer-type cache provider-cost detail, already included in provider_cost_micros and not added again to the billed total.
Any of
receipt_modestring or nullOptional mode from the linked receipt; absent when no receipt is linked.
receipt_tierstring or nullOptional privacy tier from the linked receipt; absent when no receipt is linked.
totalsobject requiredinput_tokensinteger requiredmarkup_centsinteger requiredoutput_tokensinteger requiredprovider_cost_centsinteger requiredscope_filteredboolean requiredtotal_cost_centsinteger requiredtotal_cost_dollarsnumber requiredprovider_cost_microsinteger requiredmarkup_microsinteger requiredtotal_cost_microsinteger requiredcache_usageCacheUsageBreakdown required
Generated sample
{
"pagination": {
"current_page": 0,
"last_page": 0,
"per_page": 1,
"total": 0
},
"records": [
{
"provider_cost_micros": 0,
"markup_micros": 0,
"total_cost_micros": 0,
"has_receipt": true,
"cache_usage": {
"read": {
"tokens": 0,
"rate_cents_per_million": 0,
"provider_cost_micros": 0,
"unpriced_tokens": 0
},
"write_5m": {
"tokens": 0,
"rate_cents_per_million": 0,
"provider_cost_micros": 0,
"unpriced_tokens": 0
},
"write_1h": {
"tokens": 0,
"rate_cents_per_million": 0,
"provider_cost_micros": 0,
"unpriced_tokens": 0
},
"write_30m": {
"tokens": 0,
"rate_cents_per_million": 0,
"provider_cost_micros": 0,
"unpriced_tokens": 0
},
"write_12h": {
"tokens": 0,
"rate_cents_per_million": 0,
"provider_cost_micros": 0,
"unpriced_tokens": 0
},
"write_total_tokens": 0,
"per_type_available": true,
"records_without_audit_detail": 0
},
"receipt_mode": "string",
"receipt_tier": "string"
}
],
"totals": {
"input_tokens": 0,
"markup_cents": 0,
"output_tokens": 0,
"provider_cost_cents": 0,
"scope_filtered": true,
"total_cost_cents": 0,
"total_cost_dollars": 0,
"provider_cost_micros": 0,
"markup_micros": 0,
"total_cost_micros": 0,
"cache_usage": {
"read": {
"tokens": 0,
"rate_cents_per_million": 0,
"provider_cost_micros": 0,
"unpriced_tokens": 0
},
"write_5m": {
"tokens": 0,
"rate_cents_per_million": 0,
"provider_cost_micros": 0,
"unpriced_tokens": 0
},
"write_1h": {
"tokens": 0,
"rate_cents_per_million": 0,
"provider_cost_micros": 0,
"unpriced_tokens": 0
},
"write_30m": {
"tokens": 0,
"rate_cents_per_million": 0,
"provider_cost_micros": 0,
"unpriced_tokens": 0
},
"write_12h": {
"tokens": 0,
"rate_cents_per_million": 0,
"provider_cost_micros": 0,
"unpriced_tokens": 0
},
"write_total_tokens": 0,
"per_type_available": true,
"records_without_audit_detail": 0
}
}
}401 Missing or invalid bearer token.
application/json object
Any keys are accepted.
403 The caller does not meet the route requirements: accepted Terms of Service and Privacy Policy.
application/json object
Any keys are accepted.
422 Invalid filters or a requested date range exceeding 366 days.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
429 The request was rate limited. API-generated responses are JSON;
Response headers
Retry-Afterstring headerSeconds to wait before retrying, when provided.
X-RateLimit-Scopestring headerIdentifies the scope of the request limit, when provided.
application/json GenericError
erroranyOne of
- string
- object
Any keys are accepted.
error_codestringcodestringmessagestringdetailstringstatusanyOne of
- string
- integer
errorsobjectAny keys are accepted.
text/html string