lads_delete_campaign_group
LinkedIn Ads write high risk
Part of the LinkedIn Campaign Manager Agent.
What it does
Deletes a campaign group. DRAFT groups are hard-deleted via HTTP DELETE; non-DRAFT groups CANNOT be hard-deleted — they are moved to PENDING_DELETION via PATCH (and later become read-only REMOVED if they hold spend data). At preview Scalix reads the group, picks hard-delete (DRAFT) vs soft-delete (PENDING_DELETION) from its current status, and includes affected_campaigns (the campaigns in the group, which the change reaches: count, active count, a complete flag, and id/name/status of up to 50) with the preview_id (a group already PENDING_DELETION or REMOVED gets changed: false and no preview_id); the preview includes a warning that the delete cannot be undone, and commit is irreversible and cascades to child campaigns. Accuracy notes: deletion cascades to children (they stop serving); REMOVED entities stay fetchable for billing/performance history; this is irreversible.
When to use it
Use only when the user explicitly wants to remove a group permanently. First read the group's status: DRAFT -> hard DELETE; anything else -> PENDING_DELETION (soft, remains as REMOVED for billing). Always preview the affected child campaigns and the irreversibility, and capture a reason.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
account_id | string | yes | Numeric ad account ID (digits only). |
campaign_group_id | string | yes | Numeric campaign group ID (digits only). |
reason | string | no | Reason for deletion, recorded in the audit log. |
preview_id | string | no | Omit 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
Irreversible: require explicit confirmation and log the reason. Deletion stops delivery for all child campaigns. Use HTTP DELETE only for DRAFT; non-DRAFT must go to PENDING_DELETION (never attempt DELETE on a serving group). Strict per-account isolation.
Reminder
Confirm and log; deletion is permanent and cascades to every campaign in the group.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
INVALID_ARGUMENT | Tried to HTTP DELETE a non-DRAFT group (must use PENDING_DELETION), or invalid status transition. | Read status via lads_get_campaign_group; route DRAFT->DELETE, else PATCH PENDING_DELETION. Surface the message. | no |
FIELD_NOT_EDITABLE | Cannot delete an ENTERPRISE default (backfilled) group. | Do not delete default groups; surface the platform message. | no |
PERMISSION_DENIED | Missing rw_ads / insufficient role / out of scope (403). | Confirm CAMPAIGN_MANAGER+ and rw_ads. | no |
CUSTOMER_NOT_FOUND | Group/account not found or out of scope (404). | Verify IDs. | no |
PREVIEW_EXPIRED | preview_id unknown/expired. | Re-preview before committing. | no |
TOKEN_REVOKED | Token expired/revoked (401). | needs_reauth — refresh once and retry; else reconnect. | yes |
RESOURCE_EXHAUSTED | Rate/quota limit (429). | Backoff 5/10/20s cap 60s. | yes |
PLATFORM_UNAVAILABLE | LinkedIn 5xx. | Retry with backoff; both ops are idempotent. | yes |
Edge cases
- DRAFT -> immediate hard DELETE; non-DRAFT -> PENDING_DELETION (later REMOVED if it has spend data).
- REMOVED groups remain fetchable for billing/performance — deletion is not erasure.
- Already PENDING_DELETION/REMOVED -> success with changed: false and the current status; no preview_id is issued and nothing is sent.
- Deletion cascades: all child campaigns stop serving — preview must list them.
- On an ENTERPRISE account LinkedIn refuses changes to the default (backfilled) group through the API, so it cannot be deleted here; Scalix does not check this at preview.
- Both DELETE and PATCH return 204 and are idempotent -> safe retry after transient 5xx.
- Status changed after preview -> re-preview (hard-vs-soft routing may flip).