VocalDocscontracts 1.65.0

Read the Organization's spend this month against its spend cap

GET /v1/usage/spend

PropertyValue
Operationget_spend_summary
GroupUsage
Scopeusage:read
Route classread
IdempotencyNo Idempotency-Key
AuditNot audited: A metadata read; Usage events and the spend counter carry identifiers, units and amounts, never content.
Released in1.23.0
Phase 0 hostServed (the hosted api pins 1.65.0)

Answers the Organization's spend counter of the current UTC calendar month, its spend_cap_micros, what remains and the previous month's total (1.23.0, FR-usage-4, FR-dispatch-6). The counter counts live usage only, so every caller reads the same figures whatever the environment of its key. The api reads the counter as admission does and never rates at read time.

Request

Set VOCAL_API to the base URL of your API and VOCAL_API_KEY to an API key with the usage:read scope (Authentication and keys). Replace each placeholder, such as agt_... or <name>, with your own value.

curl "$VOCAL_API/v1/usage/spend" \
  -H "Authorization: Bearer $VOCAL_API_KEY"

Responses

StatusContent typeShapeError codes
200application/jsonSpendSummary
400application/jsonErrorEnvelopeinvalid_request
401application/jsonErrorEnvelopeunauthenticated
403application/jsonErrorEnvelopeforbidden
429application/jsonErrorEnveloperate_limited
500application/jsonErrorEnvelopeinternal_error

Fields of the 200 answer

The shape is SpendSummary.

FieldTypeRequiredDescription
object"spend_summary"yes
period_startstring (date)yesThe first day of the current UTC calendar month, which the counter covers up to the first day of the next (1.23.0).
previous_period_spend_microsintegeryesThe counter of the previous UTC calendar month as it closed, in whole micro-USD (1.23.0); 0 when that month counted nothing. It is the month's spend, not a statement or an invoice.
remaining_microsinteger or nullyesThe cap less the spend, never below 0; null when there is no cap (1.23.0). At 0 admission refuses new Calls with spend_cap_reached, while Calls in progress continue and are counted at their finalize.
spend_cap_microsSpendCapMicros or nullyesThe monthly spend cap the counter is compared with; null when the Organization has none (1.23.0).
spend_microsintegeryesThe Organization's spend counter for the current month in whole micro-USD (1.23.0): the rated amounts of the live Usage events written this month, read from the counter as admission reads it; 0 before the month's first finalized live Call.
updated_atTimestamp or nullyesWhen a finalize last advanced the counter of the current month; null before the month's first finalized live Call (1.23.0).