Skip to content
Hayonix

API reference · Usage

The cost report as CSV

GET/v1/orgs/{org_id}/usage/costs/export
API keyusage:readOrganization
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

Headers
HeaderRequiredDescription
AuthorizationyesBearer and your API key. The key implies its project.

Path parameters

  • org_idstring

    Your 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

  • bucketstring

    Default day (UTC)

    One ofdayhour

  • group_bystring

    Default product

    One ofproductline_itemprojectapi_key

  • project_idstring

    ID 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:

Errors
StatusTypeWhen
400invalid_request_errorA parameter or body field is missing or not allowed; param names it.
401authentication_errorThe key or session is missing, revoked or expired.
403permission_errorThe credential lacks the permission this needs, or the organization is suspended.
429rate_limit_error rate_limitedToo many requests; retry after retry-after seconds.