gads_add_campaign_negative_keyword
Google Ads write medium risk
Part of the Search Terms Agent.
What it does
Add campaign-level negative keywords (exact/phrase/broad) so the campaign stops serving on matching queries. Each becomes a campaign_criterion with KeywordInfo {text, match_type} and negative=true. Returns created resource_names and a readable list of the blocked terms with their match scope. Preview->approve->commit: builds ops, validate_only=true diff (campaign + each negative with its match-type and a plain-English note on what scope it blocks), explicit approval, then commit (with preview_id) sends validate_only=false server-side + partial_failure=true + audit log. Accuracy/safety: over-broad negatives can silently kill large swaths of traffic — the preview spells out match-scope (broad negative blocks a query containing ALL the words in any order; phrase blocks the phrase in order; exact blocks only the exact query). Match types are enum-normalized (EXACT|PHRASE|BROAD). Bulk add respects the 10,000-operation mutate cap. The preview shows each negative with its match type and a match-scope note. 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 to block irrelevant or wasteful queries at campaign level (e.g. from a search-term audit: 'add free, cheap, jobs as negatives'). Always preview the match-scope of each negative before committing — an over-broad negative can silently zero out traffic.
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
customer_id | string | yes | 10-digit CID, dashes/spaces stripped. Tenant context server-derived. |
campaign_id | string | yes | Numeric campaign ID. |
negatives | array<object> | yes | Each: {text (the keyword), match_type (EXACT|PHRASE|BROAD, enum-normalized uppercase; default BROAD)}. Strip surrounding brackets/quotes if the user pastes [exact] or "phrase" syntax and set match_type accordingly. negative=true is forced server-side. |
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
Negative keywords carry no content-policy risk, but must never be used to mask brand-bidding violations or to circumvent a disapproval. Apply only the terms the user approved; do not infer extra negatives without confirmation.
Reminder
Negatives can contain sensitive query fragments — treat as sensitive and don't retain beyond this request.
Errors
| Error class | Means | What to do | Retry |
|---|---|---|---|
CUSTOMER_NOT_FOUND | Customer ID not found or not linked. | Verify CID (dashes stripped); re-auth if stale. | no |
TOKEN_REVOKED | Authorization revoked / refresh token expired. | Trigger re-auth (needs_reauth); do not retry with the dead token. | no |
KEYWORD_HAS_INVALID_CHARS | A negative keyword contains disallowed characters or exceeds length/word limits. | Surface the exact platform message for that term; fix or drop it. Do not strip silently. | no |
INVALID_ARGUMENT | Operation rejected (e.g. invalid match_type enum). | Surface platform message; normalize match_type. | no |
PERMISSION_DENIED | Missing scope or read-only role. | Report missing scope / role; do not retry. | no |
MANAGER_ACCOUNT_WRITE | Target CID is a manager (MCC) account. | Ask which child serving account to target. | no |
RESOURCE_EXHAUSTED | Rate/quota limit (HTTP 429). | Backoff 5->10->20s cap 60s, honor retryDelay; retry. | yes |
TOO_MANY_MUTATE_OPERATIONS | Bulk request exceeds the 10,000-operation cap. | Chunk the negatives into <=10,000-op batches and submit sequentially. | yes |
PARTIAL_FAILURE | Some negatives failed, others succeeded. | Report per-term; retry only failures. | no |
PLATFORM_UNAVAILABLE | Google Ads 5xx / INTERNAL / DEADLINE_EXCEEDED. | Idempotent retry with backoff. | yes |
Edge cases
- Empty negatives -> success:false 'no keywords supplied'.
- Duplicate negative already on the campaign -> partial_failure 'already exists', report not fail.
- Broad negative is unordered-AND blocking; the preview must explain it blocks any query containing all the words -> call out high-traffic-loss risk.
- Bulk add >10,000 -> chunk to respect the mutate cap.
- Pasted [exact]/"phrase" syntax -> normalize brackets/quotes into match_type, don't keep the punctuation in text.
- Expired token -> refresh once, retry.
- Preview expired before approval -> re-run validate_only before commit.