---
title: "Create a paused campaign plan"
description: "PubNio API ads.createCampaignPlan: create a paused campaign plan. 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.

# Create a paused campaign plan

Create a paused campaign plan with [`POST /api/v1/ads/campaigns`](https://pubnio.com/api/v1/docs#tag/ads/POST/api/v1/ads/campaigns). Requires an API key with the `ads_manage` scope or a signed-in workspace member.

## Request

Validates one workspace plan, then creates one paused campaign per target account. Returns one operation per target. The same Idempotency-Key and intent return the same plan; a different intent returns 409. Spend is not activated by this call.

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

| Body field         | Type                           | Required |
| ------------------ | ------------------------------ | -------- |
| `name`             | string                         | Yes      |
| `objective`        | one of 10 strings              | Yes      |
| `budget`           | AdBudget                       | No       |
| `schedule`         | AdSchedule                     | No       |
| `targets`          | array of AdCampaignPlanTarget  | Yes      |
| `adGroups`         | array of AdCampaignPlanAdGroup | Yes      |
| `providerSettings` | object                         | No       |

## Response

- HTTP 202: `AdCampaignPlanAccepted` with `planId`, `status`, `targets`.
  - `status`: `queued`, `creating`, `partial`, `succeeded`, `failed`, `unresolved`

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

## Examples

### TypeScript

```ts
const accepted = await workspace.ads.createCampaignPlan({
  name: "Spring sale",
  objective: "traffic",
  targets: [{ accountId }],
  adGroups: [
    {
      name: "Returning visitors",
      ads: [{ name: "Spring sale ad", creative: { headline: "Spring sale" } }],
    },
  ],
});
```

### Python

```python
accepted = workspace.ads.create_campaign_plan(
    name="Spring sale",
    objective="traffic",
    targets=[{"accountId": account_id}],
    ad_groups=[
        {
            "name": "Returning visitors",
            "ads": [
                {
                    "name": "Spring sale ad",
                    "creative": {
                        "headline": "Spring sale",
                        "destinationUrl": "https://example.com/spring",
                    },
                },
            ],
        },
    ],
)
```

### cURL

```sh
curl -X POST "https://pubnio.com/api/v1/ads/campaigns?workspaceId=$WORKSPACE_ID" \
  -H "Authorization: Bearer $PUBNIO_API_KEY" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name":"Spring sale","objective":"traffic","targets":[{"accountId":"'"$ACCOUNT_ID"'"}],"adGroups":[{"name":"Returning visitors","ads":[{"name":"Spring sale ad","creative":{"headline":"Spring sale","destinationUrl":"https://example.com/spring"}}]}]}'
```

### CLI

```sh
pnio ads create-campaign-plan --file campaign-plan.json
```

### MCP execute

```js
async () => {
  const accountId = "<accountId>";
  // 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/campaigns",
    query: { workspaceId: codemode.workspaceId },
    headers: { "Idempotency-Key": idempotencyKey },
    body: {
      name: "Spring sale",
      objective: "traffic",
      targets: [{ accountId: accountId }],
      adGroups: [
        {
          name: "Returning visitors",
          ads: [
            {
              name: "Spring sale ad",
              creative: {
                headline: "Spring sale",
                destinationUrl: "https://example.com/spring",
              },
            },
          ],
        },
      ],
    },
  });
  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

- Field lengths and ranges are in the [OpenAPI document](https://pubnio.com/api/v1/openapi).

## Related

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

Source: https://pubnio.com/docs/reference/ads-create-campaign-plan/index.mdx
