Duplicate a campaign tree as paused with POST /api/v1/ads/accounts/{accountId}/campaigns/{campaignId}/duplicate. Requires an API key with the ads_manage scope or a signed-in workspace member.
Request
Owner, member, or ads_manage key. Copies the source campaign, ad groups, ads, and creative references into a new paused PubNio-managed tree. Separate creatives are reused; embedded copy is carried in the ad. Nothing is activated.
| Parameter | In | Type | Required |
|---|---|---|---|
accountId |
path | UUID | Yes |
campaignId |
path | UUID | Yes |
workspaceId |
query | UUID | Yes |
| Body field | Type | Required |
|---|---|---|
name |
string | No |
Response
- HTTP 202:
AdOperationwithid,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.updatestatus:queued,preflight,creating,recording,reviewing,activating,succeeded,partial,failed,unresolved,cancelledstep:queued,preflight,create,record,review,activate,finish
The OpenAPI document has each field’s type.
Examples
const operation = await workspace.ads.duplicateCampaign(accountId, campaignId, {
name: "Spring sale (copy)",
});operation = workspace.ads.duplicate_campaign(
account_id,
campaign_id,
name="Spring sale (copy)",
)curl -X POST "https://pubnio.com/api/v1/ads/accounts/$ACCOUNT_ID/campaigns/$CAMPAIGN_ID/duplicate?workspaceId=$WORKSPACE_ID" \
-H "Authorization: Bearer $PUBNIO_API_KEY" \
-H "Idempotency-Key: $IDEMPOTENCY_KEY" \
-H "Content-Type: application/json" \
-d '{"name":"Spring sale (copy)"}'pnio ads duplicate-campaign "$ACCOUNT_ID" "$CAMPAIGN_ID" --name "Spring sale (copy)"async () => {
const accountId = "<accountId>";
const campaignId = "<campaignId>";
// 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}/campaigns/${campaignId}/duplicate`,
query: { workspaceId: codemode.workspaceId },
headers: { "Idempotency-Key": idempotencyKey },
body: { name: "Spring sale (copy)" },
});
return response.data;
};Errors
It declares no problem of its own.
It declares the problems every Ads operation and most operations 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.
Limits
- Field lengths and ranges are in the OpenAPI document.