Skip to navigation

Get usage and spend

Returns your organization’s billed API usage as dense time buckets of line items. Every line item carries the billed dollar amount; products billed per item also carry billed_units (unit, quantity, and unit price, where quantity × unit_price = cost_total). Usage-priced products (billed by metered provider usage) report cost_total only.

Buckets cover the requested range completely — a bucket with no line items means no billed usage in that window. Line items are unique per bucket on (product, dimensions, api_key.id, unit price). Usage billed without an API key (requests authenticated as a user session) is included with api_key absent, so totals always reconcile with your invoices. product and endpoint are stable identifiers safe to aggregate on; description is display text and may be reworded at any time.

Usage data may lag live traffic by a few minutes, and responses may be cached briefly, so this endpoint is for reporting rather than real-time monitoring.

Requires an API key whose owner is an organization admin. Keys owned by other members receive a 404.

Authentication

Api-Keystring

API key for access control. Use in the header with the name "Api-Key"

Query parameters

start_timedatetimeRequired

Start of the reporting range (RFC 3339). Snapped down to the containing bucket boundary (UTC).

end_timedatetimeOptional

End of the reporting range (RFC 3339), exclusive. Snapped up to the next bucket boundary (UTC). Defaults to now.

bucket_widthenumOptionalDefaults to 1d

Bucket granularity. 1d allows ranges up to 92 days per request; 1h allows up to 168 hours. Page through longer histories by moving start_time back across successive requests.

Allowed values:
sourceslist of enumsOptionalDefaults to ["api","app"]

Which billing sources to include. api is usage from API requests; app is web-app usage, attributed to the member who generated it. Defaults to both, so report totals reconcile with invoices.

Allowed values:

Response

Bucketed usage for the requested range.
bucketslist of objects
Dense, chronological buckets covering the requested range.

Errors

400
Bad Request Error
401
Unauthorized Error
404
Not Found Error
429
Too Many Requests Error