---
title: "Update monthly spend cap"
description: "PubNio API billing.spendControls.update: update monthly spend cap. Request fields, examples in five clients, errors, and idempotency."
---

> Documentation Index
> Fetch the complete documentation index at: https://pubnio.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Update monthly spend cap

Update monthly spend cap with [`PATCH /api/v1/workspaces/{workspaceId}/billing/spend-controls`](https://pubnio.com/api/v1/docs#tag/billing/PATCH/api/v1/workspaces/{workspaceId}/billing/spend-controls). Requires a signed-in workspace owner, in the web app or the CLI; API keys are not accepted and MCP cannot call it.

## Request

| Parameter     | In   | Type | Required |
| ------------- | ---- | ---- | -------- |
| `workspaceId` | path | UUID | Yes      |

| Body field              | Type            | Required |
| ----------------------- | --------------- | -------- |
| `version`               | integer         | Yes      |
| `monthlySpendCapMicros` | integer or null | Yes      |

## Response

- HTTP 200: `WorkspaceBilling` with `workspaceId`, `plan`, `status`, `paymentStatus`, `interval`, `gateway`, `periodStart`, `periodEnd`, `cancelAtPeriodEnd`, `creditBalanceMicros`, `creditBalance`, `spendControls`, `currentPeriod`.
  - `plan`: `payg`, `pro`, `platform`, `enterprise`
  - `status`: `active`, `trialing`, `past_due`, `canceled`, `incomplete`, `unpaid`
  - `paymentStatus`: `ok`, `payment_required`, `insufficient_credit`, `spend_cap_reached`
  - `gateway`: `fake`, `stripe`

The [OpenAPI document](https://pubnio.com/api/v1/openapi) has each field's type.

## Examples

### TypeScript

```ts
const billing = await workspace.billing.updateSpendControls({
  version: 4,
  monthlySpendCapMicros: 50000000,
});
```

Create this client with a signed-in person's `accessToken`, not an `apiKey`.

### Python

The Python SDK authenticates with a workspace API key, which this operation does not accept, so it has no method for it.

### cURL

```sh
curl -X PATCH "https://pubnio.com/api/v1/workspaces/$WORKSPACE_ID/billing/spend-controls" \
  -H "Authorization: Bearer $PUBNIO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"version":4,"monthlySpendCapMicros":50000000}'
```

### CLI

```sh
pnio billing spend-cap --version 4 --file spend-controls.json
```

### MCP execute

```js
async () => {
  const response = await codemode.request({
    method: "PATCH",
    path: `/api/v1/workspaces/${codemode.workspaceId}/billing/spend-controls`,
    body: { version: 4, monthlySpendCapMicros: 50000000 },
  });
  return response.data;
};
```

## Errors

- [`invalid-billing-date-range`](https://pubnio.com/docs/problems/invalid-billing-date-range/): HTTP 400, Invalid billing date range
- [`billing-revision-conflict`](https://pubnio.com/docs/problems/billing-revision-conflict/): HTTP 409, Billing settings changed concurrently

It also declares the problems [most operations](https://pubnio.com/docs/reference/#shared-problems) declare.

## Idempotency

No key. The required `version` makes a stale retry fail instead of applying twice.

## Limits

- API keys and MCP cannot call it. A signed-in person runs it from the CLI after `pnio auth login` or in the web app.

## Related

- [Billing operations](https://pubnio.com/docs/reference/#billing)

Source: https://pubnio.com/docs/reference/billing-spend-controls-update/index.mdx
