better/compute
API

usage

The hourly usage windows compute meters per allocation and hands to Better IAM billing, as the tenant can read them. Both methods decide `compute:usage:read` on `compute-tenant/{tenantId}`, or on `compute-project/{projectId}` when the call names a project, since windows carry their project as a tag. See [Billing and usage](/docs/guides/iam/billing-and-usage).

The hourly usage windows compute meters per allocation and hands to Better IAM billing, as the tenant can read them. Both methods decide compute:usage:read on compute-tenant/{tenantId}, or on compute-project/{projectId} when the call names a project, since windows carry their project as a tag. See Billing and usage.

All 2 methods are served by this release.

MethodKindAuthorizationPhaseStatus
listreadcompute:usage:read @ compute-tenant or compute:usage:read @ compute-projectv0.1registered
exportreadcompute:usage:read @ compute-tenant or compute:usage:read @ compute-projectv0.2registered

list

POST /api/compute/usage/list

Lists the tenant's usage windows ordered by window start, optionally for one project, one meter and a time range; returns a page with a cursor.

  • Each window carries its billing idempotency key (cmp:<allocationId>:<windowStartMs>), meter, quantity, bounds and tags, and, once the usage sink has handed it to IAM billing, recordedAt and the outcome (recorded, duplicate, reattributed or dead-lettered).

  • from and to (epoch milliseconds) select windows that end after from and start before to; to not after from is INVALID_INPUT.

  • limit is at most 500 (100 by default). A cursor this method did not return is INVALID_INPUT.

  • Kind: read

  • Authorization: compute:usage:read @ compute-tenant or compute:usage:read @ compute-project

  • Module: server

  • Phase: v0.1 (registered)

Input

FieldTypeRequiredConstraints
tenantIdstringyesat most 128 characters; matches ^[A-Za-z0-9._:-]{1,128}$
projectIdstringat most 64 characters; matches ^prj_[0-9a-hjkmnp-tv-z]{26,52}$
meterstringat most 128 characters; matches ^[a-z][a-z0-9_.-]{0,127}$
fromintegerat least 0
tointegerat least 0
limitinteger1-500; default 100
cursorstringat most 256 characters; matches ^[A-Za-z0-9_-]{1,256}$

export

POST /api/compute/usage/export

Exports every usage window of a time range as CSV (the default) or JSON Lines, with the window count and the summed quantity per meter.

  • from and to are required, and the range is at most 93 days; to not after from, or a longer range, is INVALID_INPUT.

  • One export returns at most 50,000 windows; when more match, truncated is true and the range or meter should be narrowed.

  • CSV has a header row and ISO 8601 timestamps; JSON Lines has one window object per line.

  • Kind: read

  • Authorization: compute:usage:read @ compute-tenant or compute:usage:read @ compute-project

  • Module: server

  • Phase: v0.2 (registered)

Input

FieldTypeRequiredConstraints
tenantIdstringyesat most 128 characters; matches ^[A-Za-z0-9._:-]{1,128}$
projectIdstringat most 64 characters; matches ^prj_[0-9a-hjkmnp-tv-z]{26,52}$
meterstringat most 128 characters; matches ^[a-z][a-z0-9_.-]{0,127}$
fromintegeryesat least 0
tointegeryesat least 0
formatone of csv, jsonl

Was this page helpful?

Better Compute is created by Sean Filimon

Last updated

On this page