Update spend caps

Update spend caps

PATCH/api/v1/spend-caps

PATCH /spend-caps
curl -X PATCH 'https://www.unitpost.com/api/v1/spend-caps' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'User-Agent: my-app/1.0' \
  -H 'Content-Type: application/json' \
  -d '{ }'
Response · 200
{
  "object": "spend_caps",
  "sms_purchases": {
    "cap_cents": 0,
    "max_cents": 0,
    "spent_cents": 0,
    "period_start": "string",
    "period_end": "string"
  },
  "shared_plan": {
    "cap_cents": 0,
    "spent_cents": 0,
    "period_start": "string",
    "period_end": "string"
  }
}

Set, raise, lower or clear a monthly spend cap; only the caps you send change. sms_purchases.cap_cents is whole cents from 0 (API purchases off) to the platform maximum ($1,000 a month by default), or null to clear it, after which every API purchase is refused (403 api_spend_cap_not_set) until a cap is set again. A purchase over the cap is refused with 403 api_spend_cap_exceeded and nothing is charged; the dashboard buys past it. The capability is in no key preset, and only the workspace owner holds it and can give it to a key or an app; no other capability changes a cap. A workspace its organization pays for refuses it (403 billed_by_organization): its organization sets that cap with sms_purchases_cap_cents on PATCH /organizations/{id}/workspaces/{workspace_id}. shared_plan is read-only: a body naming it is 403 billed_by_organization and changes nothing (the organization sets that cap with PATCH /organizations/{id}/shared-plan/workspaces/{workspace_id}). Requires the spend_caps:write capability.

Request body1 field
FieldTypeDescription
sms_purchasesobject—
Response · 200 fields3 fields
FieldTypeDescription
objectrequiredstring—
sms_purchasesrequiredobjectSMS purchases by API (`POST /sms/quotes/{id}/confirm`). Purchases made in the dashboard never count.
shared_planobject | nullThe workspace's cap on its organization's shared plan, read-only: its organization sets it (`PATCH /organizations/{id}/shared-plan/workspaces/{workspace_id}`). Null when the workspace isn't on a shared plan.
200400401403404422

Search docs and guides

Search the docs and product guides.