gads_create_shared_negative_set
Google Ads write medium risk
Part of the Search Terms Agent.
What it does
Create a reusable shared negative set (SharedSet, type NEGATIVE_KEYWORDS or NEGATIVE_PLACEMENTS) that can be attached to multiple campaigns. PREVIEW->APPROVE->COMMIT: previews via validate_only=true showing the set name/type, waits for approval, commits with validate_only=false + partial_failure=true, returns the SharedSet resource_name + ID + timestamp. Creating the set does NOT add keywords (use gads_add_keywords_to_shared_set) or attach it to campaigns (use gads_link_shared_set_to_campaign). Returns {success, data:{shared_set_resource_name, shared_set_id}, 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 when the user wants account-level/reusable negatives across many campaigns instead of per-campaign negatives. After creating, prompt to add keywords and link campaigns. Confirm the set name/type before committing.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
customer_id | string | yes | 10-digit CID, dashes stripped. |
name | string | yes | Set name unique within the account (used to identify it later); trimmed. |
type | string | yes | Defaults to NEGATIVE_KEYWORDS; NEGATIVE_PLACEMENTS also valid (enum-normalized). |
validate_only | boolean | no | Optional. 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_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
Non-content-policy; require approval and log the actor. Shared negative sets must not be used to selectively suppress traffic in a way that masks a disapproved ad.
Reminder
Log the actor/reason for set creation; never expose tokens.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
CUSTOMER_NOT_FOUND | Account not found/linked. | Verify CID/authorization. | no |
TOKEN_REVOKED | Authorization expired/revoked. | needs_reauth. | no |
DUPLICATE_NAME | A shared set with this name already exists in the account. | Use a unique name or reuse the existing set ID. | no |
INVALID_ARGUMENT | Invalid name or unsupported type enum. | Surface Google's message; correct input. | no |
MANAGER_ACCOUNT_NOT_SUPPORTED | Cannot create shared sets on a manager (MCC) account. | Target a child serving account. | no |
PERMISSION_DENIED | No write access / out of bearer scope. | Confirm role/scope. | no |
RESOURCE_EXHAUSTED | Rate/quota limit (HTTP 429). | Backoff 5/10/20s cap 60s; honor retryDelay. | yes |
INTERNAL_ERROR | Transient 5xx. | Retry once after backoff. | yes |
Edge cases
- Set created empty -> success; warn that it has no keywords yet and isn't linked to any campaign.
- validate_only clean still needs approval before commit.
- Duplicate name -> error; suggest reusing the existing set.
- Idempotency: re-running create after success would make a second set — guard against accidental duplicates (check name first).
- Account shared-set count limits may apply -> surface Google's limit error.
- 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.