SCALIX help

← All tools

lads_batch_create_campaigns

LinkedIn Ads write high risk

Part of the LinkedIn Campaign Manager Agent.

What it does

Batch-create multiple campaigns in ONE ad account in a single request: POST /rest/adAccounts/{id}/adCampaigns with header X-RestLi-Method: BATCH_CREATE and body {elements:[campaign,...]}. All campaigns MUST belong to the same ad account. Each element carries objectiveType, costType (CPM/CPC/CPV), budgets (dailyBudget/totalBudget {amount, currencyCode}; amounts are DECIMAL currency, NOT micros), optimizationTargetType/bid, creativeSelection, targeting, runSchedule, and politicalIntent. Preview->approve->execute->log is MANDATORY (LinkedIn has NO validate_only): build all, CREATE EVERY campaign in DRAFT/PAUSED, show a plain-English per-campaign summary, get explicit approval, then PATCH each status->ACTIVE. Returns a per-element batch response (location/id/status 201 or per-row error) — surface partial failures; never assume all-or-nothing. Re-preview on any modification. Two-phase (parity with Google, ADR-028/029): the first call (no preview_id) builds the request locally and returns a preview_id — nothing is changed on LinkedIn (it reads each row's campaign group and, when needed, the targeted locations' names); re-call with that preview_id and identical arguments to COMMIT (single-use, 30-min; a changed/forged/replayed token fails closed).

When to use it

Use to stand up several campaigns at once for the same client account efficiently. Build them all, create PAUSED, present a per-campaign preview, and only after explicit approval PATCH them ACTIVE. Do NOT auto-activate, mix accounts, omit politicalIntent on EU targeting, or use protected-attribute targeting.

Inputs

NameTypeRequiredDescription
accountstringyesSingle sponsored account for ALL elements; normalize to urn:li:sponsoredAccount:{id}. Within bearer scope.
campaignsarrayyesList of campaign objects (same account). Each needs name, campaignGroup, type, costType (CPM/CPC/CPV), unitCost, dailyBudget and/or totalBudget {amount(decimal string), currencyCode}, locale, offsiteDeliveryEnabled, politicalIntent (NOT_POLITICAL or NOT_DECLARED; POLITICAL is refused, and NOT_DECLARED is refused on EU targeting) and runSchedule.start (epoch ms; an ISO date is refused); a row missing any is refused at preview, naming it. Optional: objectiveType (singular, as lads_create_campaign's objective_type; a row without one takes its group's, and each row's group is read), optimizationTargetType, creativeSelection, targetingCriteria, runSchedule.end. Age or gender targeting on a JOB_APPLICANT or TALENT_LEAD row is refused, as in lads_create_campaign. targetingCriteria takes LinkedIn's form only, as lads_create_campaign's targeting_criteria ({include: {and: [{or: {<facet URN>: [<value URNs>]}}]}, exclude: {or: {<facet URN>: [<value URNs>]}}}); a row with any other shape, such as the retired includedTargetingFacets form, is refused at preview, naming it. Force status=DRAFT/PAUSED at create.
auto_activatebooleannoMust be false/omitted; activation is a separate approved PATCH step. Never auto-activate without explicit approval.
preview_idstringnoOmit it to preview: nothing is applied, and the call returns a preview_id bound to this exact request. Pass it only after the user approves that preview in a later message, with the same arguments (leave out validate_only, and add any confirmation flag the preview names). Single-use, expires in 30 minutes; changed arguments need a fresh preview.

Safeguards

A change in two steps. The first call previews and changes nothing; Claude shows you the preview and applies it only after you approve, within 30 minutes and with the same arguments. Every applied change goes to the audit log. How changes are approved.

Policy

Create paused, then activate only what the user approved (LinkedIn has no validate-only). Declare politicalIntent honestly on every element: POLITICAL is refused (LinkedIn does not allow political ads), and an EU-targeted element must be NOT_POLITICAL, confirmed by the user against LinkedIn's EU statement (EU TTPA) — the old EU Message/Conversation-Ads geo-block was LIFTED ~Oct 2024 and is NOT enforced; messaging instead needs a working opt-out + real sender. For employment/housing/education/credit objectives enforce anti-discrimination targeting (no protected attributes; age off for recruitment). Strict per-account isolation — every element must be the bearer's scoped account.

Reminder

Create all paused and activate only on approval; enforce politicalIntent + anti-discrimination rules on every element; never touch an account outside the bearer's scope.

Errors

Error classMeansWhat to doRetry
PARTIAL_FAILURESome campaigns created (201), others failed (per-element error with index).Return per-element results; report which failed and why; retry only failed elements after fixing.no
POLICY_VIOLATIONElement uses protected-attribute targeting on a restricted objective, or omits required politicalIntent on EU targeting.Strip protected attributes; set politicalIntent honestly; do not create offending elements.no
INVALID_ARGUMENTBad enum, budget, or schedule on an element (400) — surface LinkedIn message.Fix the offending field per the surfaced message; amounts are decimal currency with currencyCode (not micros).no
PERMISSION_DENIEDNo rw_ads write access to the account (403), or an element references another account.Ensure all elements are the scoped account; verify write role; re-auth if needed (needs_reauth).no
TOKEN_REVOKEDToken expired/revoked (401).Refresh and retry once; else re-auth.yes
RESOURCE_EXHAUSTEDRate/daily limit (429).Backoff 5/10/20s cap 60s; chunk the batch; alert at 75% quota; respect Retry-After.yes

Edge cases

  • Mixed accounts in one batch -> rejected; all elements must share one ad account.
  • Partial failure: some 201, some error -> never report success unless all succeeded; surface per-row.
  • Created campaigns are PAUSED/DRAFT and not serving until the separate approved activation PATCH.
  • Budget amounts are decimal currency (e.g. '50.00') with currencyCode — NOT micros (unlike Google).
  • Shared/total budget across grouped campaigns affects pacing — warn if budgets overlap.
  • EU-targeted campaign missing politicalIntent -> set it honestly before create (TTPA), rather than a geo-block.
  • Modification after preview -> must re-preview before activation.