Rest API
Create or update an audience
POST /api/v1/audiences
Create a new audience, or update an existing one by passing its ruleId. An audience is a reusable visitor segment defined by a targeting rule, used to scope personalizations and AI behaviour.
Use cases
- Segmentation: Create audiences for visitor groups you want to target, e.g. returning visitors or visitors from a specific campaign
- Account setup: Provision standard audiences when configuring a new workspace
- Maintenance: Update the rule or name of an existing audience by passing its
ruleId
Notes
- Omit
ruleIdto create a new audience, pass it to update that audience - The
rulefield is a JSON string containing the targeting rule expression - Use the get audiences endpoint to inspect existing audiences and their rule format first
Parameters
Section titled “ Parameters ”Header Parameters
Section titled “Header Parameters ”Your API key from account settings.
The email address of your user.
The ID of your account. You can find this in the account settings.
The ID of the workspace you want to use.
Request Body required
Section titled “Request Body required ”object
ID of an existing audience to update. Omit to create a new audience.
Display name of the audience.
JSON string containing the targeting rule expression.
State of the audience.
Unit for the duration field.
Tags used to categorise and filter audiences.
Responses
Section titled “ Responses ”The created or updated audience.
object
object
The account ID that owns this audience.
The website this audience belongs to.
Unique identifier for this audience.
Display name of the audience.
Current state of the audience.
JSON string containing the targeting rule expression.
Unit for the duration field.
Unix timestamp (ms) when the audience was created.
Unix timestamp (ms) when the audience was last updated.
Whether the audience is disabled. Disabled audiences are excluded from evaluation.
Whether this audience can be modified.
Tags used to categorise and filter audiences.
Example
{ "audience": { "accountId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "websiteId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "ruleId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "name": "Returning visitors", "state": "live", "rule": "{\"and\":[{\"field\":\"visits\",\"operator\":\"greaterThan\",\"value\":\"1\"}]}", "duration": 30, "durationType": "days", "audienceTags": [ "lifecycle" ] }}Bad request - missing or invalid body.
Unauthorized - invalid API key.