Audiences (management API)
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.
| Method | Path | What it does | Permission |
|---|---|---|---|
GET | /v1/manage/audiences | List audiences | Read |
POST | /v1/manage/audiences | Create an audience | Full |
GET | /v1/manage/audiences/{audience} | Get an audience | Read |
PATCH | /v1/manage/audiences/{audience} | Change an audience | Full |
DELETE | /v1/manage/audiences/{audience} | Delete an audience | Full |
GET | /v1/manage/audiences/{audience}/count | Count an audience’s members | Read |
POST | /v1/manage/audiences/{audience}/activate | Turn an audience on | Full |
POST | /v1/manage/audiences/{audience}/deactivate | Turn an audience off | Full |
POST | /v1/manage/audiences/{audience}/restore | Restore a deleted audience | Full |
List audiences
Section titled “List audiences”/v1/manage/audiencesPermission: 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | No | How many to return, 1 to 100 (default 50). |
cursor | string | No | From 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:
| Field | Type | Description |
|---|---|---|
id | string | The audience’s id. Any endpoint taking {audience} also takes its name. |
name | string | |
description | string or null | |
rules | array of object | |
rules[].field | string | |
rules[].operator | string | |
rules[].value | string | |
rules_in_words | array of string | |
ignored_rules | number | Stored rules that can’t be matched as written (from before the rules were checked); they’re skipped. |
active | boolean | Off: it matches nobody. |
used_by | object | Banners and messages shown to it; while any do, it can’t be deleted. |
used_by.banners | array of object | |
used_by.messages | array of object | |
created | string | |
updated_at | string |
Create an audience
Section titled “Create an audience”/v1/manage/audiencesPermission: 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:
| Parameter | Type | Required | Description |
|---|---|---|---|
dry_run | true, false | No | true: check and preview the change without making it (the same as dry_run in the body). |
Request body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | A name, such as “Repeat buyers in the US”. |
description | string or null | No | A note for your team. |
rules | array of object or string | Yes | The 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.
| Field | Type | Description |
|---|---|---|
id | string | The audience’s id. Any endpoint taking {audience} also takes its name. |
name | string | |
description | string or null | |
rules | array of object | |
rules[].field | string | |
rules[].operator | string | |
rules[].value | string | |
rules_in_words | array of string | |
ignored_rules | number | Stored rules that can’t be matched as written (from before the rules were checked); they’re skipped. |
active | boolean | Off: it matches nobody. |
used_by | object | Banners and messages shown to it; while any do, it can’t be deleted. |
used_by.banners | array of object | |
used_by.messages | array of object | |
created | string | |
updated_at | string |
Get an audience
Section titled “Get an audience”/v1/manage/audiences/{audience}Permission: Read.
One audience, with every field a change takes, by the same names.
Path parameters:
| Parameter | Description |
|---|---|
audience | The audience: its id or name. URL-encode a name. |
Response 200: the result in data.
| Field | Type | Description |
|---|---|---|
id | string | The audience’s id. Any endpoint taking {audience} also takes its name. |
name | string | |
description | string or null | |
rules | array of object | |
rules[].field | string | |
rules[].operator | string | |
rules[].value | string | |
rules_in_words | array of string | |
ignored_rules | number | Stored rules that can’t be matched as written (from before the rules were checked); they’re skipped. |
active | boolean | Off: it matches nobody. |
used_by | object | Banners and messages shown to it; while any do, it can’t be deleted. |
used_by.banners | array of object | |
used_by.messages | array of object | |
created | string | |
updated_at | string |
Change an audience
Section titled “Change an audience”/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:
| Parameter | Description |
|---|---|
audience | The audience: its id or name. URL-encode a name. |
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
dry_run | true, false | No | true: check and preview the change without making it (the same as dry_run in the body). |
Request body (JSON):
| Field | Type | Required | Description |
|---|---|---|---|
name | string | No | |
description | string or null | No | Empty or null clears it. |
rules | array of object or string | No | The new rules, replacing all of them. |
active | boolean | No | false: it matches nobody (banners and messages using it show to no one) until it’s on again. |
expected_updated_at | string | No | The 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.
| Field | Type | Description |
|---|---|---|
id | string | The audience’s id. Any endpoint taking {audience} also takes its name. |
name | string | |
description | string or null | |
rules | array of object | |
rules[].field | string | |
rules[].operator | string | |
rules[].value | string | |
rules_in_words | array of string | |
ignored_rules | number | Stored rules that can’t be matched as written (from before the rules were checked); they’re skipped. |
active | boolean | Off: it matches nobody. |
used_by | object | Banners and messages shown to it; while any do, it can’t be deleted. |
used_by.banners | array of object | |
used_by.messages | array of object | |
created | string | |
updated_at | string |
Delete an audience
Section titled “Delete an audience”/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:
| Parameter | Description |
|---|---|
audience | The audience: its id or name. URL-encode a name. |
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
dry_run | true, false | No | true: 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.
| Field | Type | Description |
|---|---|---|
deleted | true | |
id | string | |
name | string | |
trash_id | string | |
restorable_until | string |
Count an audience’s members
Section titled “Count an audience’s members”/v1/manage/audiences/{audience}/countPermission: 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:
| Parameter | Description |
|---|---|
audience | The audience: its id or name. URL-encode a name. |
Response 200: the result in data.
| Field | Type | Description |
|---|---|---|
count | number or null | Null when counting took longer than two seconds: ask again shortly. |
window_days | number | |
cached | boolean | |
timed_out | boolean | |
note | string |
Turn an audience on
Section titled “Turn an audience on”/v1/manage/audiences/{audience}/activatePermission: 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:
| Parameter | Description |
|---|---|
audience | The audience: its id or name. URL-encode a name. |
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
dry_run | true, false | No | true: 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.
| Field | Type | Description |
|---|---|---|
id | string | The audience’s id. Any endpoint taking {audience} also takes its name. |
name | string | |
description | string or null | |
rules | array of object | |
rules[].field | string | |
rules[].operator | string | |
rules[].value | string | |
rules_in_words | array of string | |
ignored_rules | number | Stored rules that can’t be matched as written (from before the rules were checked); they’re skipped. |
active | boolean | Off: it matches nobody. |
used_by | object | Banners and messages shown to it; while any do, it can’t be deleted. |
used_by.banners | array of object | |
used_by.messages | array of object | |
created | string | |
updated_at | string |
Turn an audience off
Section titled “Turn an audience off”/v1/manage/audiences/{audience}/deactivatePermission: 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:
| Parameter | Description |
|---|---|
audience | The audience: its id or name. URL-encode a name. |
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
dry_run | true, false | No | true: 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.
| Field | Type | Description |
|---|---|---|
id | string | The audience’s id. Any endpoint taking {audience} also takes its name. |
name | string | |
description | string or null | |
rules | array of object | |
rules[].field | string | |
rules[].operator | string | |
rules[].value | string | |
rules_in_words | array of string | |
ignored_rules | number | Stored rules that can’t be matched as written (from before the rules were checked); they’re skipped. |
active | boolean | Off: it matches nobody. |
used_by | object | Banners and messages shown to it; while any do, it can’t be deleted. |
used_by.banners | array of object | |
used_by.messages | array of object | |
created | string | |
updated_at | string |
Restore a deleted audience
Section titled “Restore a deleted audience”/v1/manage/audiences/{audience}/restorePermission: 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:
| Parameter | Description |
|---|---|
audience | The audience: its id or name. URL-encode a name. |
Query parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
dry_run | true, false | No | true: 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.
| Field | Type | Description |
|---|---|---|
id | string | The audience’s id. Any endpoint taking {audience} also takes its name. |
name | string | |
description | string or null | |
rules | array of object | |
rules[].field | string | |
rules[].operator | string | |
rules[].value | string | |
rules_in_words | array of string | |
ignored_rules | number | Stored rules that can’t be matched as written (from before the rules were checked); they’re skipped. |
active | boolean | Off: it matches nobody. |
used_by | object | Banners and messages shown to it; while any do, it can’t be deleted. |
used_by.banners | array of object | |
used_by.messages | array of object | |
created | string | |
updated_at | string |