SCALIX help

← All tools

gads_create_custom_audience

Google Ads write medium risk

Part of the Google Ads Audience Agent.

What it does

Create a custom audience (CustomAudienceService) for targeting in Demand Gen, PMax, Display, and Video campaigns based on members (search keywords, full URLs, or Android app package names). type_=AUTO is recommended for new audiences (INTEREST/PURCHASE_INTENT are deprecated for new creation); SEARCH is also valid. Member type is auto-detected: starts with http(s):// -> URL; dotted token with no spaces and >=2 dots (e.g. com.example.app) -> APP; otherwise -> KEYWORD. This is a WRITE: it follows preview->approve->commit. Preview builds the CustomAudienceOperation and runs the mutate with validate_only=true (returns errors without creating, no metrics), shows a plain-English diff (name, type, members count/list), and returns a preview_id; commit — the same call plus that preview_id, made after the user approves in a later message — re-runs it for real and logs an immutable audit entry. Returns {audience_id, resource_name, members_added, status:ENABLED} on commit. Custom audiences hold no per-user data and produce no metrics here; size/eligibility is observed later via reporting. After creation, attach with gads_attach_audience_to_ad_group using audience_type=CUSTOM_AUDIENCE. 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

Use to build interest/intent audiences for Demand Gen, PMax, Display, or Video. Always preview with validate_only first and get explicit approval before committing — confirm the audience name and member list with the user, and never encode personal or protected-class data.

Inputs

NameTypeRequiredDescription
customer_idstringyes10-digit Google Ads CID; strip dashes (123-456-7890 -> 1234567890). Tenant-scoped server-side; never trust a client-supplied CID outside the bearer's authorized accounts.
namestringyesAudience name, e.g. 'Mars Travel Enthusiasts'. Must be unique within the account.
audience_typestringnoEnum-normalize to upper: AUTO (default, recommended) or SEARCH. INTEREST/PURCHASE_INTENT are deprecated for new audiences and are rejected -> map to AUTO.
membersarrayyesArray of strings; each is a keyword, full URL (with http/https), or Android package name. Must contain >=1 entry. Auto-typed; keep keywords concise.
descriptionstringnoOptional description; defaults to 'Custom audience: <name>'.
manager_idstringnoOptional MCC login-customer-id when operating through a manager; omit when the bearer's own account owns the CID.
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

Custom audiences must be built from interest/intent signals only — never upload or encode personal data, protected-class attributes (race, religion, health, sexual orientation), or content that targets sensitive categories. Do not use audiences to circumvent a disapproval (Circumventing Systems) or to target users in a way the ad's vertical prohibits (employment/housing/credit must not target protected attributes).

Reminder

No personal data in audience members; keywords/URLs/apps are interest signals, not identifiers — never retain member-derived data.

Errors

Error classMeansWhat to doRetry
INVALID_ARGUMENTGoogle rejected the audience definition (e.g., malformed member, unsupported type, duplicate name).Show the exact platform validation message from the validate_only preview and ask the user to correct the member list; do not guess a fix.no
NO_MEMBERSmembers must contain at least one keyword, URL, or app package name.Ask the user for at least one member before previewing.no
TOKEN_REVOKEDThe Google Ads OAuth token is expired or revoked.Refresh the access token and retry once; if still failing, prompt the user to reconnect Google Ads (needs_reauth).yes
CUSTOMER_NOT_FOUNDThe customer ID was not found or is not accessible by this connection.Verify the CID is within the authorized accounts; do not retry blindly.no
PERMISSION_DENIEDThe user lacks permission on this account or the bearer scope does not cover writes (out-of-bearer-scope).Confirm account access and that the connection has write scope; otherwise refuse.no
RESOURCE_EXHAUSTEDAPI rate/quota limit hit (HTTP 429).Exponential backoff 5s/10s/20s (cap 60s), honoring any retryDelay in the error, then retry.yes
RESOURCE_COUNT_LIMIT_EXCEEDEDThe account has reached its maximum number of custom audiences.Ask the user to remove unused audiences before creating new ones.no
INTERNAL_ERRORGoogle Ads returned a transient server error (5xx/INTERNAL).Retry after short backoff; if persistent, surface as a platform outage.yes

Edge cases

  • Preview (validate_only=true) returns no resource_name and creates nothing — never report success as if created until commit.
  • Mixed member list (keywords + URLs + apps) in one audience is valid; auto-typing classifies each.
  • A bare domain with one dot (example.com) is ambiguous — it is treated as KEYWORD unless prefixed with http(s):// to force URL.
  • preview_id TTL expiry (Redis-stored) -> instruct caller to re-preview; never commit a stale preview.
  • Expired token mid-call -> refresh once and retry; if refresh fails, return needs_reauth.
  • Custom audiences only serve on supported channels; attaching to a pure Search ad group has limited effect — note this.