Skip to content

Audiences (management API)

View as Markdown

Audiences are groups of people that banners and messages can target. Reading needs Read; every change needs the Full permission, as the Audiences page needs an Admin. Audiences are on paid plans. For what each setting does, see the user guide.

Every path also works under /v1/manage/appspaces/{appspace}, which you need when an OAuth token reaches more than one Appspace. See the management API overview for signing in, errors, dry runs and paging.

MethodPathWhat it doesPermission
GET/v1/manage/audiencesList audiencesRead
POST/v1/manage/audiencesCreate an audienceFull
GET/v1/manage/audiences/{audience}Get an audienceRead
PATCH/v1/manage/audiences/{audience}Change an audienceFull
DELETE/v1/manage/audiences/{audience}Delete an audienceFull
GET/v1/manage/audiences/{audience}/countCount an audience’s membersRead
POST/v1/manage/audiences/{audience}/activateTurn an audience onFull
POST/v1/manage/audiences/{audience}/deactivateTurn an audience offFull
POST/v1/manage/audiences/{audience}/restoreRestore a deleted audienceFull
GET/v1/manage/audiences

Permission: Read.

The Appspace’s audiences, oldest first, paged with cursor: each with its rules (and in words), whether it’s on, and the banners and messages shown to it.

Query parameters:

ParameterTypeRequiredDescription
limitintegerNoHow many to return, 1 to 100 (default 50).
cursorstringNoFrom the previous page’s next_cursor, to get the page after it.

Response 200: a page of results in data, and next_cursor for the next page (see Paging). Each item:

FieldTypeDescription
idstringThe audience’s id. Any endpoint taking {audience} also takes its name.
namestring
descriptionstring or null
rulesarray of object
rules[].fieldstring
rules[].operatorstring
rules[].valuestring
rules_in_wordsarray of string
ignored_rulesnumberStored rules that can’t be matched as written (from before the rules were checked); they’re skipped.
activebooleanOff: it matches nobody.
used_byobjectBanners and messages shown to it; while any do, it can’t be deleted.
used_by.bannersarray of object
used_by.messagesarray of object
createdstring
updated_atstring
POST/v1/manage/audiences

Permission: Full. Changes something: takes dry_run and Idempotency-Key, and needs the Standard plan or above.

A name and 1 to 20 rules, all of which a person must meet; each rule’s field, operator and value are checked as the dashboard checks them, and a wrong one is named. A paid plan. Send Idempotency-Key so a retry never makes two. With dry_run, nothing changes: the answer is { dry_run: true, before, after, changes, warnings }.

Query parameters:

ParameterTypeRequiredDescription
dry_runtrue, falseNotrue: check and preview the change without making it (the same as dry_run in the body).

Request body (JSON):

FieldTypeRequiredDescription
namestringYesA name, such as “Repeat buyers in the US”.
descriptionstring or nullNoA note for your team.
rulesarray of object or stringYesThe rules, all of which a person must meet (1 to 20). Also a JSON string of the same list.

Response 201: the result in data, with warnings. With dry_run, a preview instead.

FieldTypeDescription
idstringThe audience’s id. Any endpoint taking {audience} also takes its name.
namestring
descriptionstring or null
rulesarray of object
rules[].fieldstring
rules[].operatorstring
rules[].valuestring
rules_in_wordsarray of string
ignored_rulesnumberStored rules that can’t be matched as written (from before the rules were checked); they’re skipped.
activebooleanOff: it matches nobody.
used_byobjectBanners and messages shown to it; while any do, it can’t be deleted.
used_by.bannersarray of object
used_by.messagesarray of object
createdstring
updated_atstring
GET/v1/manage/audiences/{audience}

Permission: Read.

One audience, with every field a change takes, by the same names.

Path parameters:

ParameterDescription
audienceThe audience: its id or name. URL-encode a name.

Response 200: the result in data.

FieldTypeDescription
idstringThe audience’s id. Any endpoint taking {audience} also takes its name.
namestring
descriptionstring or null
rulesarray of object
rules[].fieldstring
rules[].operatorstring
rules[].valuestring
rules_in_wordsarray of string
ignored_rulesnumberStored rules that can’t be matched as written (from before the rules were checked); they’re skipped.
activebooleanOff: it matches nobody.
used_byobjectBanners and messages shown to it; while any do, it can’t be deleted.
used_by.bannersarray of object
used_by.messagesarray of object
createdstring
updated_atstring
PATCH/v1/manage/audiences/{audience}

Permission: Full. Changes something: takes dry_run and Idempotency-Key, and needs the Standard plan or above.

Its name, description or rules (all of them, replaced); only what is sent changes. Banners and messages shown to it follow the new rules at once. With dry_run, nothing changes: the answer is { dry_run: true, before, after, changes, warnings }.

Path parameters:

ParameterDescription
audienceThe audience: its id or name. URL-encode a name.

Query parameters:

ParameterTypeRequiredDescription
dry_runtrue, falseNotrue: check and preview the change without making it (the same as dry_run in the body).

Request body (JSON):

FieldTypeRequiredDescription
namestringNo
descriptionstring or nullNoEmpty or null clears it.
rulesarray of object or stringNoThe new rules, replacing all of them.
activebooleanNofalse: it matches nobody (banners and messages using it show to no one) until it’s on again.
expected_updated_atstringNoThe updated_at you read. If the thing has changed since, nothing is saved and the answer is 412 precondition_failed: read it again and retry.

Response 200: the result in data, with warnings. With dry_run, a preview instead.

FieldTypeDescription
idstringThe audience’s id. Any endpoint taking {audience} also takes its name.
namestring
descriptionstring or null
rulesarray of object
rules[].fieldstring
rules[].operatorstring
rules[].valuestring
rules_in_wordsarray of string
ignored_rulesnumberStored rules that can’t be matched as written (from before the rules were checked); they’re skipped.
activebooleanOff: it matches nobody.
used_byobjectBanners and messages shown to it; while any do, it can’t be deleted.
used_by.bannersarray of object
used_by.messagesarray of object
createdstring
updated_atstring
DELETE/v1/manage/audiences/{audience}

Permission: Full. Changes something: takes dry_run and Idempotency-Key, and needs the Standard plan or above.

Refused with 409 while banners or messages are shown to it (they’d show to nobody); details.used_by lists them. Otherwise it goes to the trash for 30 days. With dry_run, nothing changes: the answer is { dry_run: true, before, after, changes, warnings }.

Path parameters:

ParameterDescription
audienceThe audience: its id or name. URL-encode a name.

Query parameters:

ParameterTypeRequiredDescription
dry_runtrue, falseNotrue: check and preview the change without making it (the same as dry_run in the body).

Response 200: the result in data, with warnings. With dry_run, a preview instead.

FieldTypeDescription
deletedtrue
idstring
namestring
trash_idstring
restorable_untilstring
GET/v1/manage/audiences/{audience}/count

Permission: Read.

How many identified people (a user ID) match in the last 30 days, as the Audiences page shows it: from its cache when it can, otherwise counted, waiting at most two seconds.

Path parameters:

ParameterDescription
audienceThe audience: its id or name. URL-encode a name.

Response 200: the result in data.

FieldTypeDescription
countnumber or nullNull when counting took longer than two seconds: ask again shortly.
window_daysnumber
cachedboolean
timed_outboolean
notestring
POST/v1/manage/audiences/{audience}/activate

Permission: Full. Changes something: takes dry_run and Idempotency-Key, and needs the Standard plan or above.

It matches people again. With dry_run, nothing changes: the answer is { dry_run: true, before, after, changes, warnings }.

Path parameters:

ParameterDescription
audienceThe audience: its id or name. URL-encode a name.

Query parameters:

ParameterTypeRequiredDescription
dry_runtrue, falseNotrue: check and preview the change without making it (the same as dry_run in the body).

Response 200: the result in data, with warnings. With dry_run, a preview instead.

FieldTypeDescription
idstringThe audience’s id. Any endpoint taking {audience} also takes its name.
namestring
descriptionstring or null
rulesarray of object
rules[].fieldstring
rules[].operatorstring
rules[].valuestring
rules_in_wordsarray of string
ignored_rulesnumberStored rules that can’t be matched as written (from before the rules were checked); they’re skipped.
activebooleanOff: it matches nobody.
used_byobjectBanners and messages shown to it; while any do, it can’t be deleted.
used_by.bannersarray of object
used_by.messagesarray of object
createdstring
updated_atstring
POST/v1/manage/audiences/{audience}/deactivate

Permission: Full. Changes something: takes dry_run and Idempotency-Key, and needs the Standard plan or above.

It matches nobody: banners and messages shown to it reach no one until it’s on again. With dry_run, nothing changes: the answer is { dry_run: true, before, after, changes, warnings }.

Path parameters:

ParameterDescription
audienceThe audience: its id or name. URL-encode a name.

Query parameters:

ParameterTypeRequiredDescription
dry_runtrue, falseNotrue: check and preview the change without making it (the same as dry_run in the body).

Response 200: the result in data, with warnings. With dry_run, a preview instead.

FieldTypeDescription
idstringThe audience’s id. Any endpoint taking {audience} also takes its name.
namestring
descriptionstring or null
rulesarray of object
rules[].fieldstring
rules[].operatorstring
rules[].valuestring
rules_in_wordsarray of string
ignored_rulesnumberStored rules that can’t be matched as written (from before the rules were checked); they’re skipped.
activebooleanOff: it matches nobody.
used_byobjectBanners and messages shown to it; while any do, it can’t be deleted.
used_by.bannersarray of object
used_by.messagesarray of object
createdstring
updated_atstring
POST/v1/manage/audiences/{audience}/restore

Permission: Full. Changes something: takes dry_run and Idempotency-Key, and needs the Standard plan or above.

Brings back an audience deleted in the last 30 days, with the same id and rules. With dry_run, nothing changes: the answer is { dry_run: true, before, after, changes, warnings }.

Path parameters:

ParameterDescription
audienceThe audience: its id or name. URL-encode a name.

Query parameters:

ParameterTypeRequiredDescription
dry_runtrue, falseNotrue: check and preview the change without making it (the same as dry_run in the body).

Response 200: the result in data, with warnings. With dry_run, a preview instead.

FieldTypeDescription
idstringThe audience’s id. Any endpoint taking {audience} also takes its name.
namestring
descriptionstring or null
rulesarray of object
rules[].fieldstring
rules[].operatorstring
rules[].valuestring
rules_in_wordsarray of string
ignored_rulesnumberStored rules that can’t be matched as written (from before the rules were checked); they’re skipped.
activebooleanOff: it matches nobody.
used_byobjectBanners and messages shown to it; while any do, it can’t be deleted.
used_by.bannersarray of object
used_by.messagesarray of object
createdstring
updated_atstring
Was this page helpful?