---
title: "Update an ad group budget"
description: "PubNio API ads.setAdGroupBudget: update an ad group budget. 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 an ad group budget

Update an ad group budget with [`POST /api/v1/ads/accounts/{accountId}/ad-groups/{adGroupId}/budget`](https://pubnio.com/api/v1/docs#tag/ads/POST/api/v1/ads/accounts/{accountId}/ad-groups/{adGroupId}/budget). Requires a signed-in workspace owner, in the web app or the CLI; API keys are not accepted and MCP cannot call it.

## Request

Requires the current expectedRevision and the account currency. The spend guard uses the campaign total across its ad groups. The provider call updates the budget and reads the ad group back.

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

| Body field         | Type     | Required |
| ------------------ | -------- | -------- |
| `budget`           | AdBudget | Yes      |
| `expectedRevision` | integer  | Yes      |

## Response

- HTTP 202: `AdOperation` with `id`, `accountId`, `kind`, `status`, `step`, `input`, `result`, `issues`, `attempts`, `canRetry`, `nextAction`, `createdAt`, `updatedAt`, `startedAt`, `completedAt`.
  - `kind`: `boost.create`, `campaign.create`, `campaign.activate`, `campaign.pause`, `campaign.archive`, `ad_group.status`, `ad_group.create`, `ad.status`, `ad.attach`, `creative.create`, `campaign.duplicate`, `budget.update`
  - `status`: `queued`, `preflight`, `creating`, `recording`, `reviewing`, `activating`, `succeeded`, `partial`, `failed`, `unresolved`, `cancelled`
  - `step`: `queued`, `preflight`, `create`, `record`, `review`, `activate`, `finish`

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

## Examples

### TypeScript

```ts
const operation = await workspace.ads.setAdGroupBudget(accountId, adGroupId, {
  budget: { amountMinor: 2000, currency: "USD", kind: "daily" },
  expectedRevision: 2,
});
```

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 POST "https://pubnio.com/api/v1/ads/accounts/$ACCOUNT_ID/ad-groups/$AD_GROUP_ID/budget?workspaceId=$WORKSPACE_ID" \
  -H "Authorization: Bearer $PUBNIO_TOKEN" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -H "Content-Type: application/json" \
  -d '{"budget":{"amountMinor":2000,"currency":"USD","kind":"daily"},"expectedRevision":2}'
```

### CLI

```sh
pnio ads set-ad-group-budget "$ACCOUNT_ID" "$AD_GROUP_ID" --expected-revision 2 --file budget.json
```

### MCP execute

```js
async () => {
  const accountId = "<accountId>";
  const adGroupId = "<adGroupId>";
  // One key per intent; reuse it only to retry this same request.
  const idempotencyKey = crypto.randomUUID();
  const response = await codemode.request({
    method: "POST",
    path: `/api/v1/ads/accounts/${accountId}/ad-groups/${adGroupId}/budget`,
    query: { workspaceId: codemode.workspaceId },
    headers: { "Idempotency-Key": idempotencyKey },
    body: {
      budget: { amountMinor: 2000, currency: "USD", kind: "daily" },
      expectedRevision: 2,
    },
  });
  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

Required. A retry with the same `Idempotency-Key` returns the first result for 24 hours. Make one key per intent, such as `crypto.randomUUID()` or Python's `uuid4()`, and reuse it only to retry the same request. The TypeScript SDK makes a key for each call unless you pass `idempotencyKey`. See [Idempotency](https://pubnio.com/docs/concepts/idempotency/).

## 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-set-ad-group-budget/index.mdx
