# update_workspace_spending

Source: https://modulify.ai/docs/api/workspaces/update-workspace-spending

Sets or removes the monthly spending caps of a workspace and its spending alerts, changing only what you send.

- Title: Change the spending caps and alerts
- Scope: `workspaces:write`
- Access: Makes changes
- Endpoint: `POST /v1/update_workspace_spending`

Only the workspace owner can call this, the same as in **Spending** > **Settings**. Only what you send changes, and the answer is the same as `get_workspace_spending`.

`caps` sets caps in whole credits a calendar month, from 0 to 1,000,000, for `total` (everything the workspace spends), `ai` (the AI of every site together) and `emails` (the extra emails every site buys together). `removeCaps` removes the caps it names, and takes precedence over `caps`. Lowering `total` below what the workspace already spent this month stops chat from starting new turns at once, so the tool tells the client to confirm with you before it lowers a cap. Raising or removing a cap lets AI and email sending that a cap paused start again on their own.

`alertPercents` picks the points of each cap and of the budget that send the owner an email, any of 50, 75 and 90. An empty list keeps only the email a cap sends when it is reached. `budget` sets a monthly amount that only sends emails, and `lowBalance` the balance under which the owner hears about it; `removeBudget` and `removeLowBalance` turn them off. A point that was already passed when you save does not send an email.

Auto top-up charges the owner's card, so it can only be turned on or changed in the app. See [Spending caps and alerts](https://modulify.ai/docs/plans/spending).

## Request

Call it with a `POST` to `https://api.modulify.ai/v1/update_workspace_spending`, sending the inputs below as a JSON object. The token needs the `workspaces:write` scope.

It makes changes, so send an [Idempotency-Key](https://modulify.ai/docs/api/idempotency) header whenever you might retry it. A retry with the same key gets the first answer back instead of running again.

```bash
curl -X POST https://api.modulify.ai/v1/update_workspace_spending \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"workspaceId":"WORKSPACE_ID"}'
```

Over MCP, the same method is the [update_workspace_spending tool](https://modulify.ai/docs/mcp/workspaces/update-workspace-spending).

## Inputs

| Input | Type | Required | Description |
| --- | --- | --- | --- |
| `workspaceId` | string | Yes | The workspace id. |
| `caps` | object | No | The caps to set: `total`, `ai` and `emails`, each a whole number of credits a calendar month. |
| `removeCaps` | array of strings | No | The caps to remove, any of `total`, `ai` and `emails`. It takes precedence over `caps`. |
| `alertPercents` | array of integers | No | The points of each cap and budget, in percent, that send the owner an email. |
| `budget` | integer | No | A monthly amount in credits that only sends emails. |
| `removeBudget` | boolean | No | True to remove the budget. |
| `lowBalance` | integer | No | The balance in credits under which the owner gets an email. |
| `removeLowBalance` | boolean | No | True to stop the low balance email. |

## Response

Every call answers with the [JSON envelope](https://modulify.ai/docs/api/requests-and-responses#the-response) of `success`, `message`, `data`, `code` and `version`. `data` holds the result described above, and on a method that returns a total, `count` carries it. The [response headers](https://modulify.ai/docs/api/requests-and-responses#headers-on-every-method-call) carry the call's `X-Request-Id` and what is left of your per-minute budget in `X-RateLimit-Limit`, `X-RateLimit-Remaining` and `X-RateLimit-Reset`. [Errors](https://modulify.ai/docs/api/errors) explains every status code a call can answer with.