SCALIX help

← All tools

lads_batch_update_campaigns

LinkedIn Ads write high risk

Part of the LinkedIn Campaign Manager Agent.

What it does

Batch-update multiple campaigns in ONE ad account: POST /rest/adAccounts/{id}/adCampaigns with X-RestLi-Method: BATCH_PARTIAL_UPDATE (per-element {patch:{$set:{...}}}). Used for bulk status changes (PAUSED/ACTIVE/ARCHIVED), budget/bid edits, schedule changes — all elements must share one account. Preview->approve->execute->log MANDATORY: show before/after for every campaign, get explicit approval, then apply; re-check anti-discrimination if targeting changes (Scalix applies LinkedIn's EU political-intent rule, and its age and gender rules, at preview to every row that activates a campaign or changes its targeting or intent); bulk activation requires the same approval as single. Returns a per-element batch response with per-row status — surface partial failures. A row's status is checked at preview against LinkedIn's campaign statuses; to delete, use lads_delete_campaign (LinkedIn deletes a DRAFT campaign only by HTTP DELETE, which this batch never sends). Two-phase (parity with Google, ADR-028/029): the first call (no preview_id) reads the listed campaigns from LinkedIn (a missing id is refused), builds the request locally and returns a preview_id — nothing is changed on LinkedIn; 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 pause/activate or edit budgets/bids/schedules across many campaigns at once for one client. Present before/after for each, get approval, then apply. Do NOT bulk-activate without approval, change targeting into protected attributes, or mix accounts.

Inputs

NameTypeRequiredDescription
accountstringyesSingle sponsored account for ALL elements; normalize to urn:li:sponsoredAccount:{id}. Within bearer scope.
updatesarrayyesList of per-campaign updates. Each element identifies the campaign with campaign_id (or id/campaign; bare id or urn) PLUS either flat fields the tool wraps in patch.$set, OR a prebuilt patch:{$set:{...}} passed through as-is apart from its runSchedule and targetingCriteria. Common fields: status (ACTIVE/PAUSED/ARCHIVED; a value outside LinkedIn's campaign statuses is refused at preview, naming the row), dailyBudget/totalBudget {amount, currencyCode}, unitCost (bid), runSchedule {start, end} in epoch ms (start is required whenever runSchedule is set, since LinkedIn replaces the whole schedule; a row with no start, or with a bound that is not epoch ms such as an ISO date, is refused at preview, naming it), targetingCriteria (LinkedIn's form only, as lads_create_campaign's targeting_criteria; a row with any other shape, such as the retired includedTargetingFacets form, is refused at preview, naming it). All elements same account.
reasonstringnoAudit reason for the change (logged; required for status changes per guardrail).
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

The preview includes each campaign's new values (preview.request.entities) but not its current ones: read those (lads_get_campaign / lads_get_campaign_budget) and show before/after for every campaign before asking for approval; apply only approved changes. Bulk activation needs explicit approval (no auto-activate). If targeting changes, re-check anti-discrimination (no protected attributes; age off for recruitment) and politicalIntent on EU targeting (EU TTPA; no geo-block). Strict per-account isolation across all elements.

Reminder

Show before/after, apply only approved edits, log the reason, re-check anti-discrimination/politicalIntent on targeting changes, and never touch out-of-scope accounts.

Errors

Error classMeansWhat to doRetry
PARTIAL_FAILURESome campaigns updated, others failed (per-element status).Return per-element results; report failures; retry only failed elements.no
POLICY_VIOLATIONA targeting change introduces protected-attribute targeting or undeclared politicalIntent on EU targeting.Reject the offending edits; correct targeting/political declaration first.no
INVALID_ARGUMENTInvalid status transition or bad patch field (400) — surface message.Follow lifecycle rules (DRAFT->DELETE; non-DRAFT->PENDING_DELETION); fix patch.no
PERMISSION_DENIEDNo rw_ads write access or element references another account (403).Ensure single scoped account + write role; re-auth if needed (needs_reauth).no
NOT_FOUNDA campaign id in the batch does not exist (404 per row).Confirm campaign ids; drop invalid ones.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; alert at 75% quota; respect Retry-After.yes

Edge cases

  • Mixed accounts -> rejected; all elements one account.
  • Partial success: report per-row; do not claim success unless all applied.
  • Invalid lifecycle transition (e.g. a CANCELED campaign set ACTIVE; LinkedIn cancels permanently) -> per-row 400.
  • Editing a shared/total budget affects multiple campaigns' pacing -> warn.
  • Bulk status->ACTIVE is an activation event requiring approval and re-preview if anything changed.
  • Budget amounts are decimal currency + currencyCode (not micros).