Skip to main content

Spend Controls

The SDK gives you six methods for working with spend caps: the limits your company sets on its own AI coding spend. These are the same caps the dashboard’s Money tab shows, readable and writable from code. This page covers:
  1. Listing caps
  2. Reading spend against the caps
  3. Reading coverage (“how many developers are protected?”)
  4. Creating a cap
  5. Updating a cap
  6. Deleting a cap
If you’re new to spend caps, start with the Spend Controls API reference for a plain-English explanation of scopes, modes, and how enforcement works.

Setup

The three read methods work with any secret key for your organization. The three write methods (create, update, delete) need a key that belongs to an owner or finance user. A key without that role gets the server’s own plain-English 403, surfaced as-is.

spendControls.list

Lists every cap policy for your organization. Each cap carries a sentence field: the cap written out as one plain sentence, built by the server.

Signature

Example


spendControls.spend

Returns your team’s internal coding-agent spend for the current day, week, or month window (computed in UTC on the server). Pass a developer’s customerExternalId (their email) to also get that developer’s number.

Signature

Example

spentUsd is null when there’s no priced usage in the window. A null means “nothing to total yet,” never a fake 0. Check unpricedEventCount: if it’s above zero, some events couldn’t be priced and the true spend is higher than spentUsd shows.

spendControls.coverage

Answers “N of M developers armed” over the trailing 7 days: how many developers’ machines have cap enforcement turned on, out of every developer seen at all.

Signature

Example

asOf is null when there’s been no recent activity. The server never makes up a timestamp.

spendControls.create

Creates a cap. Owner or finance key required.

Signature

Example

Every cap covers all AI tools; the SDK sends providerScope: "all" for you. A developer cap can never be set higher than the whole-team ceiling: the server rejects it with a plain message you can show as-is.

spendControls.update

Adjusts an existing cap’s amountUsd, period, mode, coolOffHours, or alertThresholds. Owner or finance key required. A cap’s identity (its scope and target) can’t be changed; delete and recreate instead.

Signature

Example


spendControls.delete

Deletes a cap. Owner or finance key required. The response echoes the removed cap’s sentence so you can confirm what was deleted.

Signature

Example


The types

Note the read types accept a wider scope vocabulary than create does. That’s deliberate: create takes org or dev only, while list can return older rows without breaking your types if the vocabulary ever widens.