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.
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
| Name | In | Type | Required | What it is |
|---|---|---|---|---|
Idempotency-Key | header | string | No | Makes a repeat of this call safe for 24 hours. |
Body
| Field | Type | Required | What it is |
|---|---|---|---|
scope | "organisation" | "project" | "end_user_default" | "member" | Yes | |
target | string | Yes | The organization for organisation; the project for project and end_user_default; the member's identity account id for member. |
amount_cents | integer | null | Yes | The cap a month, in the currency's minor unit. null removes it. From 0 to 100000000. |
on_reach | "refuse" | "sleep" | No | Once 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.
{
"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
}| Field | Type | Always | What it is |
|---|---|---|---|
scope | "organisation" | "project" | "end_user" | "end_user_default" | "member" | Yes | Whose 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. |
target | string | Yes | The organization, project or end user; the project for end_user_default; an identity account for member. |
amount_cents | integer | null | Yes | The cap a month, in the currency's minor unit; null once removed. From 0 to 100000000. |
on_reach | "refuse" | "sleep" | Yes | Once the month's spend reaches the cap: refuse new creates and wakes, or also put to sleep what is awake. Nothing is deleted. |
currency | string | Yes | ISO 4217. |
period | string | Yes | A calendar month in UTC. |
spent_cents | integer | null | Yes | This 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_of | string | null | Yes | |
reached | boolean | Yes | |
set_by | string | null | Yes | The person or key that set it. |
set_at | string | null | Yes |
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
| Client | Call |
|---|---|
| TypeScript | pod.spendCaps.set({ … }) |
| Python | pod.spend_caps.set({…}) |