Set or remove the spend cap of the organization, a project, or a project's end users

Sets a cap of scope `organisation`, `project`, `end_user_default` (each end user of the project that has no cap of its own) or `member` (one member of the organization, by identity account id: the sandboxes they made count); `amount_cents: null` removes it.

PUT/v1/spend_caps

Sets a cap of scope organisation, project, end_user_default (each end user of the project that has no cap of its own) or member (one member of the organization, by identity account id: the sandboxes they made count); amount_cents: null removes it. A higher cap is agreeing to pay more, so only a signed-in person whose role may read billing can call it, with a fresh second factor; an API key answers person_required, and so does a person whose second factor is not fresh. One end user's cap is PUT /v1/end_users/{end_user_id}/spend_cap.

For people only: a signed-in person with a fresh second factor makes this call. An API key is refused with person_required. The person's role must be one that may read billing.

Request

curl -X PUT "https://api.pod.mapier.ai/v1/spend_caps" \
  -H "Authorization: Bearer $POD_PERSON_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"scope":"organisation","target":"example","amount_cents":0}'

Parameters

NameInTypeRequiredWhat it is
Idempotency-KeyheaderstringNoMakes a repeat of this call safe for 24 hours.

Body

FieldTypeRequiredWhat it is
scope"organisation" | "project" | "end_user_default" | "member"Yes
targetstringYesThe organization for organisation; the project for project and end_user_default; the member's identity account id for member.
amount_centsinteger | nullYesThe cap a month, in the currency's minor unit. null removes it. From 0 to 100000000.
on_reach"refuse" | "sleep"NoOnce the month's spend reaches the cap: refuse new creates and wakes, or also put to sleep what is awake. Nothing is deleted.

Answer

200. The cap as it counts now; after a removal, with amount_cents null.

200
{
  "scope": "organisation",
  "target": "example",
  "amount_cents": null,
  "on_reach": "refuse",
  "currency": "example",
  "period": "example",
  "spent_cents": null,
  "spent_as_of": null,
  "reached": false,
  "set_by": null,
  "set_at": null
}
FieldTypeAlwaysWhat it is
scope"organisation" | "project" | "end_user" | "end_user_default" | "member"YesWhose spend the cap counts. end_user_default targets a project and counts for each of its end users that has no cap of its own. member targets one member by identity account id: the sandboxes they made, with a key they made or signed in.
targetstringYesThe organization, project or end user; the project for end_user_default; an identity account for member.
amount_centsinteger | nullYesThe cap a month, in the currency's minor unit; null once removed. From 0 to 100000000.
on_reach"refuse" | "sleep"YesOnce the month's spend reaches the cap: refuse new creates and wakes, or also put to sleep what is awake. Nothing is deleted.
currencystringYesISO 4217.
periodstringYesA calendar month in UTC.
spent_centsinteger | nullYesThis month's spend under the cap as last worked out, an estimate at Pod's rates; the invoice is the billing provider's. Null until first worked out, and for end_user_default, which each end user counts apart. At least 0.
spent_as_ofstring | nullYes
reachedbooleanYes
set_bystring | nullYesThe person or key that set it.
set_atstring | nullYes

Errors

The refusals this call is known for: invalid, person_required, forbidden, not_found. Any call can also answer unauthorized, rate_limited, unavailable or internal; the error list says what each means and when to send the call again.

In the SDKs

ClientCall
TypeScriptpod.spendCaps.set({ … })
Pythonpod.spend_caps.set({…})