Skip to main content
reservations is a convenience layer in the TypeScript SDK over the runs operations. It is not a separate API and has no endpoints of its own. Use it for the common shape: hold a maximum, run one piece of variable-cost work, settle what it actually cost.

What each call maps to

settle derives the end status from the settlement: completed when it is accepted or a duplicate, failed otherwise. It appends :settle to your idempotency key for the settlement call, so pass the same key you used to reserve.

The reservation object

string
The run ID. Identical to runId in the runs operations.
string
The customer the budget was held against.
integer
The amount held, in minor units. The same value runs.start reports as budgetAmountMinor.
string
Currency of the held amount.

Common mistakes

settle and release are methods on the reservation returned by reserve, not on the reservations resource. unprice.reservations.settle(...) does not exist.
  • Do not call runs.end after reservation.settle(). Settling already ended the run. A second end call is redundant and can conflict with the recorded status.
  • Do not mix the two styles on one run. If you need runs.consume for intermediate steps, or a status the helper does not produce, use the runs operations directly for that whole run.
  • Use release() for the abandoned path, not settle() with zero usage. release cancels the run and returns the full hold; a zero settlement records a real settlement of nothing.

When to use the runs operations instead

Reach past the helper when the work is multi-step or long-lived:

Start a run

Full control over workloadType, workloadId, traceId, and parentRunId.

Consume mid-run

Authorize a known amount partway through, before a billable step.

Settle usage

Account for usage while leaving the run open for more steps.

End a run

Close the run yourself and release the unused budget.