---
title: "Replace an ad account's spend policy"
description: "PubNio API ads.updateSpendPolicy: replace an ad account's spend policy. 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.

# Replace an ad account's spend policy

Replace an ad account's spend policy with [`PUT /api/v1/ads/accounts/{accountId}/spend-policy`](https://pubnio.com/api/v1/docs#tag/ads/PUT/api/v1/ads/accounts/{accountId}/spend-policy). Requires a signed-in workspace owner, in the web app or the CLI; API keys are not accepted and MCP cannot call it.

## Request

Send every cap and the current expectedRevision. Caps use the account currency; a monthly cap is required before the first activation. A stale revision returns AdRevisionConflict.

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

| Body field                  | Type          | Required |
| --------------------------- | ------------- | -------- |
| `expectedRevision`          | integer       | Yes      |
| `monthlyCap`                | Money or null | Yes      |
| `dailyCap`                  | Money or null | Yes      |
| `maxCampaignDailyBudget`    | Money or null | Yes      |
| `maxCampaignLifetimeBudget` | Money or null | Yes      |

## Response

- HTTP 200: `AdSpendPolicy` with `accountId`, `currency`, `configured`, `monthlyCap`, `dailyCap`, `maxCampaignDailyBudget`, `maxCampaignLifetimeBudget`, `killSwitchActive`, `killSwitchAt`, `killSwitchReason`, `revision`, `updatedAt`.

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

## Examples

### TypeScript

```ts
const policy = await workspace.ads.updateSpendPolicy(accountId, {
  expectedRevision: 1,
  monthlyCap: { amountMinor: 100000, currency: "USD" },
  dailyCap: { amountMinor: 5000, currency: "USD" },
  maxCampaignDailyBudget: null,
  maxCampaignLifetimeBudget: null,
});
```

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 PUT "https://pubnio.com/api/v1/ads/accounts/$ACCOUNT_ID/spend-policy?workspaceId=$WORKSPACE_ID" \
  -H "Authorization: Bearer $PUBNIO_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"expectedRevision":1,"monthlyCap":{"amountMinor":100000,"currency":"USD"},"dailyCap":{"amountMinor":5000,"currency":"USD"},"maxCampaignDailyBudget":null,"maxCampaignLifetimeBudget":null}'
```

### CLI

```sh
pnio ads update-spend-policy "$ACCOUNT_ID" --expected-revision 1 --file spend-policy.json
```

### MCP execute

```js
async () => {
  const accountId = "<accountId>";
  const response = await codemode.request({
    method: "PUT",
    path: `/api/v1/ads/accounts/${accountId}/spend-policy`,
    query: { workspaceId: codemode.workspaceId },
    body: {
      expectedRevision: 1,
      monthlyCap: { amountMinor: 100000, currency: "USD" },
      dailyCap: { amountMinor: 5000, currency: "USD" },
      maxCampaignDailyBudget: null,
      maxCampaignLifetimeBudget: null,
    },
  });
  return response.data;
};
```

## Errors

It declares no problem of its own.

It declares the problems [every Ads operation](https://pubnio.com/docs/reference/#ads) and [most operations](https://pubnio.com/docs/reference/#shared-problems) declare.

## Idempotency

No key. The required `expectedRevision` 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

- [Ads operations](https://pubnio.com/docs/reference/#ads)

Source: https://pubnio.com/docs/reference/ads-update-spend-policy/index.mdx
