Skip to main content
POST
create or update a budget

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json

The upsert request

key
string
required

The budget's key, chosen by you and unique within the project. Up to 128 letters, digits, and : / _ . @ -, starting with a letter or digit.

Pattern: ^[A-Za-z0-9][A-Za-z0-9:/_.@-]{0,127}$
Example:

"customer:acme"

unit
string
required

A currency code (shorthand for money:), credits:, or units:

Pattern: ^([A-Z]{3}|money:[A-Z]{3}|credits:[a-z0-9_-]{1,64}|units:[a-z0-9_-]{1,64})$
Example:

"USD"

limits
object[]
required

Up to 16 limits. Every hard limit must have room for a hold or charge. An empty list makes a budget that only counts.

Maximum array length: 16
closesAt
integer | null

When the budget closes, in epoch milliseconds. From then on authorize and charge return 409, record is accepted for 1 day more, and settle and release keep working. 30 days after closesAt, once nothing is left to settle or replay, the budget is deleted: get returns 404 and an upsert creates it anew. An upsert replaces the whole definition, so omitting closesAt or sending null leaves the budget open and clears any close time it had. A runtime key cannot close a budget in the past: an earlier closesAt takes effect now.

Required range: x >= 0
Example:

1798761599000

holds
object

Hold timing. Both TTLs must be between 1000 and 86400000 ms, and the default must not exceed the max. An omitted TTL takes its default on every upsert.

onUnavailable
enum<string>

Deny new work when Unprice cannot be reached. Defaults to deny.

Available options:
deny
Example:

"deny"

Response

The changes applied and the budget

changes
object[]
required

What this upsert changed; empty when it changed nothing

budget
object
required