API reference · Usage
The cost report as CSV
/v1/orgs/{org_id}/usage/costs/export- TypeScript
client.usage.exportCostReport()- Python
client.usage.export_cost_report()- CLI
hayonix usage
The same report as getCostReport, downloaded as a CSV file: one row per bucket and group with the amount in nano-USD and in USD, then a final total row.
Project API key (Authorization: Bearer sk_…), or a console session. Requires the usage:read permission (a key's scope, or a role that includes it).
Examples
The samples read API_KEY and API_BASE_URL from the environment (see Setup). Values are examples.
# The org of your key: GET /v1/caller
ORG_ID=$(curl -sS "$API_BASE_URL/caller" -H "Authorization: Bearer $API_KEY" | jq -r .org_id)
curl -sS "$API_BASE_URL/orgs/$ORG_ID/usage/costs/export" \
-H "Authorization: Bearer $API_KEY"Request
| Header | Required | Description |
|---|---|---|
Authorization | yes | Bearer and your API key. The key implies its project. |
Path parameters
org_idstringYour organization. The SDKs and the CLI fill it in from the API key.
ID with prefix org_
Query parameters
startstring (date-time)Inclusive; default the start of the current month (UTC)
endstring (date-time)Exclusive; default the start of next month
bucketstringDefault day (UTC)
One of
dayhourgroup_bystringDefault product
One of
productline_itemprojectapi_keyproject_idstringID of the project
ID with prefix prj_
Response
200 text (text/csv) — CSV: bucket_start, group, amount_nano_usd, amount_usd
Errors
Errors use the standard envelope. What this operation can answer:
| Status | Type | When |
|---|---|---|
400 | invalid_request_error | A parameter or body field is missing or not allowed; param names it. |
401 | authentication_error | The key or session is missing, revoked or expired. |
403 | permission_error | The credential lacks the permission this needs, or the organization is suspended. |
429 | rate_limit_error rate_limited | Too many requests; retry after retry-after seconds. |