Skip to content

Create an audience

POST
/content/management/v1/audiences
curl --request POST \
--url https://api.ebitex.io/content/management/v1/audiences \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "externalId": "example", "name": "example", "predicate": {} }'

Creates an audience from externalId, name and predicate. externalId is lowercase kebab-case, 3 to 64 characters, unique in the environment, and cannot be changed afterwards.

predicate is a JSON tree with a kind on every node: equals and notEquals (property, value), in (property, values), compare (property, op of lt, lte, gt or gte, and a numeric value), exists and notExists (property), and allOf and anyOf (predicates). For example:

{ "kind": "allOf", "predicates": [
  { "kind": "equals", "property": "country", "value": "US" },
  { "kind": "compare", "property": "visits", "op": "gte", "value": 3 }
] }

Comparison is strict: the string "3" never equals the number 3, and compare only matches numbers. A list-valued context property matches equals or in when any element does. A property that is absent or null fails every operator except notEquals and notExists.

Key: a management key with content.management.authoring.

Media typeapplication/json
object
externalId
required
string
name
required
string
predicate
required
object
Examplegenerated
{
"externalId": "example",
"name": "example",
"predicate": {}
}

201 Created with the new audience, shaped as in the list.

validation_failed: errors names each problem, such as an invalid or duplicate externalId, a missing name, or a predicate that is not a valid condition.

missing_api_key or invalid_api_key: no key was sent, or it is unknown, revoked or expired.

payment_required: the organization’s subscription needs attention.

permission_denied: the key’s role lacks content.audiences.manage.

scope_denied: the key lacks this route’s scope. tier_required: the Content Management API needs the Pro plan or above. ip_denied: the caller’s address is outside the key’s allowed ranges. app_not_available: Content is not enabled for the organization.

Rate limit or quota exceeded; Retry-After says how long to wait. too_many_failed_authentications: too many bad keys from this address.