Skip to content

Update Spending Limits

PUT
/api-keys/{api_key_id}/spending-limits

Set the daily and monthly credit caps on a key. The token is unchanged.

ADMIN OR OWNER ONLY, and a key can NEVER change its own caps: a cap that the capped key could lift is not a cap. An organization key additionally follows the rotation rules (a creator still in the organization, keys of the same creator, scopes it holds). A full replace: null removes a window’s cap. Billable calls past a cap are refused with 402 until the window resets.

Authorizations

Parameters

Path Parameters

api_key_id
required

Key id from GET /api-keys.

string

Key id from GET /api-keys.

Header Parameters

X-Target-Org-Id
Any of:
string

Request Body required

Replace a key’s spending caps in place. A FULL replace: resend any value you want to keep.

A cap is in credits and bounds only the BILLABLE operations that key makes: once the key’s spend for the current UTC day (or month) would pass it, the next billable call is refused with 402. null removes that window’s cap.

object
daily_credit_cap
Any of:
integer
>= 1 <= 100000000
monthly_credit_cap
Any of:
integer
>= 1 <= 100000000
spend_alert_threshold_pct
Any of:
integer
>= 1 <= 100

Responses

200

Successful Response

object
data
required

One API key’s metadata (never the secret).

object
api_key_id
required
string
created_at
Any of:
integer
created_by
Any of:
string
daily_credit_cap
Any of:
integer
environment

Sandbox or live, derived from mode (additive; a test key reads live).

string
default: live
expires_at
Any of:
integer
ip_allowlist

CIDRs this key is restricted to. Empty = unrestricted.

Array<string>
is_agency

Whether this key is agency-scoped. Informational — this door cannot mint one.

boolean
is_legacy_unrestricted

True for a key minted before scopes existed. An empty scope list means unrestricted, not ‘no access’.

boolean
key_prefix
Any of:
string
last_used_at
Any of:
integer
mode
string
default: live
monthly_credit_cap
Any of:
integer
name
required
string
scopes
Array<string>
spend_alert_threshold_pct
Any of:
integer
pagination
Any of:
object
has_next
required

Whether there are more pages

boolean
limit
required

Items per page

integer
next_cursor
Any of:
string
notes
Any of:
Array<string>
page
required

Current page number (1-indexed)

integer
total
required

Total number of items

integer
total_available
Any of:
integer
total_is_lower_bound
Any of:
boolean

422

Validation Error

object
detail
Array<object>
object
loc
required
Array
msg
required
string
type
required
string