SCALIX help

← All tools

gads_apply_label

Google Ads write low risk

Part of the Account Structure Agent.

What it does

Apply a label to one or more campaigns, ad groups, or ads (entity_type AD_GROUP_AD; alias AD) (CampaignLabelService / AdGroupLabelService / AdGroupAdLabelService) in bulk via create operations. entity_type selects the service. For ads, each target is {ad_group_id, ad_id}. WRITE with preview->approve->commit: preview = mutate validate_only=true + diff (label, entity_type, target count/IDs) + preview_id; commit = the same call plus that preview_id after the user approves in a later message (the server then runs the real mutate) + audit. Returns {label_id, entities_labeled, ids}. Bulk-capable; uses partial_failure on commit so already-labeled entities don't fail the batch. 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.

When to use it

Applying labels. Use to bulk-tag campaigns/ad groups/ads. Preview the target list, confirm the entity set, then commit. Good for grouping entities for later reporting or bulk actions.

Inputs

NameTypeRequiredDescription
customer_idstringyes10-digit CID; strip dashes.
label_idstringyesID of the label to apply (create via gads_create_label).
entity_typestringyesCAMPAIGN, AD_GROUP, or AD_GROUP_AD (alias: AD; case-insensitive) — selects the label link resource.
campaign_idsarraynoCampaign IDs (entity_type=CAMPAIGN).
ad_group_idsarraynoAd group IDs (entity_type=AD_GROUP).
ad_group_ad_idsarraynoFor entity_type=AD_GROUP_AD. Each item may be {ad_group_id, ad_id}, the string 'adGroupId~adId', or a full ad_group_ad resource_name (customers/<cid>/adGroupAds/<ag>~<ad>) - all three are accepted.
manager_idstringnoOptional MCC login-customer-id.
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

Labeling is organizational; do not use labels to mark or segment entities by protected-class targeting. No spend effect.

Reminder

Organizational only; no spend/targeting change and no sensitive segmentation.

Errors

Error classMeansWhat to doRetry
PARTIAL_FAILURESome entities were already labeled or invalid while others succeeded.Report failed indices (e.g., LABEL_ALREADY_APPLIED); the rest succeeded.no
VALIDATION_ERRORNo target IDs provided for the chosen entity_type.Provide the matching ID list for the entity_type.no
NOT_FOUNDLabel or target entity does not exist.Confirm label_id and entity IDs.no
TOKEN_REVOKEDOAuth token expired/revoked.Refresh and retry once; else prompt reconnect (needs_reauth).yes
PERMISSION_DENIEDNo access or out-of-bearer-scope write.Confirm access and write scope; else refuse.no
RESOURCE_EXHAUSTEDRate/quota exceeded (HTTP 429).Backoff 5/10/20s cap 60s, then retry.yes
INTERNAL_ERRORTransient Google server error (5xx).Retry after backoff.yes

Edge cases

  • Applying a label already on an entity -> per-row LABEL_ALREADY_APPLIED (partial failure), not a batch failure.
  • Bulk op count must stay within the 10,000 mutate-op cap; chunk larger lists.
  • entity_type=AD requires {ad_group_id, ad_id} pairs, not bare ad IDs.
  • Mismatched entity_type vs provided IDs -> VALIDATION_ERROR.
  • Preview changes nothing; preview_id TTL expiry -> re-preview; expired token -> refresh once and retry.