SCALIX help

← All tools

gads_link_shared_set_to_campaign

Google Ads write medium risk

Part of the Search Terms Agent.

What it does

Attach (or detach) a shared negative set to a campaign via CampaignSharedSet. PREVIEW->APPROVE->COMMIT: builds the CampaignSharedSet create (attach) or remove (detach) op, previews via validate_only=true naming the set and campaign and the broad effect (all negatives in the set apply to/stop applying to the campaign), waits for approval, commits with validate_only=false + partial_failure=true, returns the CampaignSharedSet resource_name + timestamp. NEGATIVE_KEYWORDS/NEGATIVE_PLACEMENTS sets attach at campaign level only. Returns {success, data, count, warnings}. PREVIEW SEMANTICS: the first call (no preview_id) is sent to the Google Ads API in validation mode — field, enum, policy and permission errors surface AT PREVIEW, nothing is changed, and the response returns a preview_id. To apply, show the preview to the user, get their approval, and re-call with that preview_id and IDENTICAL arguments within 30 minutes; changed arguments or an expired token fail closed to a fresh preview. validate_only=true forces another preview; validate_only=false alone never commits.

When to use it

Use to apply a reusable negative set to a campaign (or remove it). State that all negatives in the set immediately affect the campaign's traffic. Get explicit approval before linking.

Inputs

NameTypeRequiredDescription
customer_idstringyes10-digit CID, dashes stripped.
shared_set_idstringyesSharedSet ID/resource_name to attach/detach.
campaign_idstringyesCampaign to attach the set to (or detach from).
actionstringnoATTACH (default) or DETACH (enum-normalized); DETACH issues a remove on the CampaignSharedSet link.
validate_onlybooleannoOptional. true forces another preview even with a preview_id; false is DEPRECATED and no longer commits — only a valid preview_id applies the write.
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

Non-content-policy; require approval and log the actor. Attaching applies every negative in the set to the campaign at once — preview the breadth of suppression.

Reminder

Log the actor/reason for the link change; never expose tokens.

Errors

Error classMeansWhat to doRetry
CUSTOMER_NOT_FOUNDAccount not found/linked.Verify CID/authorization.no
TOKEN_REVOKEDAuthorization expired/revoked.needs_reauth.no
SHARED_SET_NOT_FOUNDShared set not found or removed.Verify the shared_set_id.no
CAMPAIGN_NOT_FOUNDCampaign not found.Verify the campaign_id.no
INVALID_ARGUMENTLink already exists, or the set type is not valid at campaign level for this campaign type.Surface Google's message; if already attached, treat as a no-op.no
MANAGER_ACCOUNT_NOT_SUPPORTEDCannot mutate on a manager (MCC) account.Target a child serving account.no
PERMISSION_DENIEDNo write access / out of bearer scope.Confirm role/scope.no
RESOURCE_EXHAUSTEDRate/quota limit (HTTP 429).Backoff 5/10/20s cap 60s; honor retryDelay.yes
INTERNAL_ERRORTransient 5xx.Retry once after backoff.yes

Edge cases

  • Set already linked to the campaign -> idempotent; report as already attached.
  • DETACH when not linked -> no-op; report not attached.
  • Linking a NEGATIVE_PLACEMENTS set to a Search campaign -> no-effect/invalid combo; warn.
  • validate_only clean still needs approval before commit.
  • Empty set linked -> succeeds but suppresses nothing yet; warn.
  • Expired token -> refresh once and retry.
  • shared_set.member_count is lazily maintained by Google and can read 0 while shared_criterion rows exist — count shared_criterion rows for truth, never member_count.
  • REMOVED shared sets drop out of status-filtered listings while their shared_criterion rows remain queryable — when auditing, include REMOVED status and SELECT shared_set.id on shared_criterion queries to attribute orphaned criteria.