Skip to Content
API ReferenceAudiences

Audiences API

Audiences are named segmentation queries built on top of a parent entity model. They use a visual filter tree to define membership criteria based on properties, computed attributes, relationships, events, and other audiences.

Endpoints

MethodPathDescription
GET/api/v1/workspaces/{id}/audiencesList all audiences
POST/api/v1/workspaces/{id}/audiencesCreate an audience
GET/api/v1/workspaces/{id}/audiences/{audId}Get an audience
PUT/api/v1/workspaces/{id}/audiences/{audId}Update an audience
DELETE/api/v1/workspaces/{id}/audiences/{audId}Delete an audience
POST/api/v1/workspaces/{id}/audiences/{audId}/estimateEstimate audience size
GET/api/v1/workspaces/{id}/audiences/{audId}/previewPreview audience members
GET/api/v1/workspaces/{id}/models/{modelId}/audiencesList audiences by model
POST/api/v1/workspaces/{id}/models/{modelId}/estimate-filterEstimate filter count

List Audiences

GET /api/v1/workspaces/{id}/audiences

Returns all audiences in the workspace.

Response

[ { "id": "550e8400-e29b-41d4-a716-446655440000", "workspace_id": "660e8400-e29b-41d4-a716-446655440000", "parent_model_id": "770e8400-e29b-41d4-a716-446655440000", "name": "High-Value Customers", "description": "Customers with lifetime value over $1000", "filter_tree": { "type": "and", "children": [ { "type": "condition", "condition_type": "property", "column": "lifetime_value", "operator": "greater_than", "value": 1000 } ] }, "estimated_size": 4250, "estimated_at": "2024-01-15T15:00:00Z", "status": "active", "status_error": "", "identity_graph_id": null, "created_by": "880e8400-e29b-41d4-a716-446655440000", "created_at": "2024-01-15T09:30:00Z", "updated_at": "2024-01-15T09:30:00Z" } ]

Example

curl -X GET https://composable.zeotap.com/api/v1/workspaces/{id}/audiences \ -H "Authorization: Bearer <token>" \ -H "X-Workspace-ID: <workspace-id>"

Create Audience

POST /api/v1/workspaces/{id}/audiences

Creates a new audience with a filter tree definition.

Request Body

FieldTypeRequiredDescription
namestringYesDisplay name
descriptionstringNoDescription
parent_model_idstring (UUID)YesParent entity model the audience is built on
filter_treeobjectYesRecursive filter tree definition
identity_graph_idstring (UUID)NoIdentity graph for cross-model resolution

Filter Tree Structure

The filter tree is a recursive JSON structure that supports boolean logic (and, or, not) and multiple condition types.

Group Nodes

{ "type": "and", "children": [...] }
TypeDescription
andAll children must match
orAt least one child must match
notNegates the child condition

Property Condition

Filters on a column of the parent model.

{ "type": "condition", "condition_type": "property", "column": "lifetime_value", "operator": "greater_than", "value": 1000 }

Computed Attribute Condition

Filters on a computed attribute value. (The condition_type value remains trait for backwards compatibility.)

{ "type": "condition", "condition_type": "trait", "trait_id": "550e8400-e29b-41d4-a716-446655440000", "operator": "greater_than", "value": 5 }

Relation Condition

Filters based on related model records, with optional nested filters.

{ "type": "condition", "condition_type": "relation", "relationship_id": "660e8400-e29b-41d4-a716-446655440000", "quantifier": "any", "count_operator": "at_least", "count_value": 1, "filters": { "type": "and", "children": [ { "type": "condition", "condition_type": "property", "column": "category", "operator": "equals", "value": "electronics" } ] } }

Event Condition

Filters based on event occurrences with time windows.

{ "type": "condition", "condition_type": "event", "relationship_id": "770e8400-e29b-41d4-a716-446655440000", "count_operator": "at_least", "count_value": 3, "time_window": { "type": "within", "value": 30, "unit": "days" } }

Audience Condition

Filters based on membership in another audience.

{ "type": "condition", "condition_type": "audience", "audience_id": "880e8400-e29b-41d4-a716-446655440000", "operator": "is_member" }

Operators

OperatorApplicable TypesDescription
equalstext, numberExact match
not_equalstext, numberNot equal
greater_thannumber, timestampGreater than
less_thannumber, timestampLess than
greater_than_or_equalnumber, timestampGreater than or equal
less_than_or_equalnumber, timestampLess than or equal
containstextSubstring match
not_containstextDoes not contain
starts_withtextPrefix match
ends_withtextSuffix match
is_nullanyValue is null
is_not_nullanyValue is not null
intext, numberValue is in list
not_intext, numberValue is not in list
betweennumber, timestampValue is between two bounds
is_memberaudienceMember of audience
is_not_memberaudienceNot a member of audience

Count Operators (for relation/event conditions)

OperatorDescription
at_leastCount >= value
at_mostCount <= value
exactlyCount == value
betweenCount between value and value2

Time Window (for event conditions)

FieldTypeDescription
typestringwithin, not_within, before, after, between
valueintegerTime amount
unitstringhours, days, weeks, months

Full Example

curl -X POST https://composable.zeotap.com/api/v1/workspaces/{id}/audiences \ -H "Authorization: Bearer <token>" \ -H "X-Workspace-ID: <workspace-id>" \ -H "Content-Type: application/json" \ -d '{ "name": "High-Value Recent Buyers", "description": "Customers with LTV > $1000 who purchased in the last 30 days", "parent_model_id": "770e8400-e29b-41d4-a716-446655440000", "filter_tree": { "type": "and", "children": [ { "type": "condition", "condition_type": "property", "column": "lifetime_value", "operator": "greater_than", "value": 1000 }, { "type": "condition", "condition_type": "event", "relationship_id": "990e8400-e29b-41d4-a716-446655440000", "count_operator": "at_least", "count_value": 1, "time_window": { "type": "within", "value": 30, "unit": "days" } } ] } }'

Get Audience

GET /api/v1/workspaces/{id}/audiences/{audId}

Returns a single audience by ID.

Example

curl -X GET https://composable.zeotap.com/api/v1/workspaces/{id}/audiences/{audId} \ -H "Authorization: Bearer <token>" \ -H "X-Workspace-ID: <workspace-id>"

Update Audience

PUT /api/v1/workspaces/{id}/audiences/{audId}

Updates an existing audience definition.

Request Body

Same fields as create. Only include fields you want to change.


Delete Audience

DELETE /api/v1/workspaces/{id}/audiences/{audId}

Deletes an audience. Cannot be deleted if active syncs reference it.

Response

{ "status": "deleted" }

Estimate Audience Size

POST /api/v1/workspaces/{id}/audiences/{audId}/estimate

Runs the audience’s filter query against the warehouse to count matching records. The result is saved to the audience’s estimated_size and estimated_at fields.

Response

{ "estimated_size": 4250, "estimated_at": "2024-01-15T15:00:00Z" }

Example

curl -X POST https://composable.zeotap.com/api/v1/workspaces/{id}/audiences/{audId}/estimate \ -H "Authorization: Bearer <token>" \ -H "X-Workspace-ID: <workspace-id>"

Preview Audience Members

GET /api/v1/workspaces/{id}/audiences/{audId}/preview

Returns a sample of records that match the audience’s filter criteria.

Response

{ "columns": [ {"name": "customer_id", "type": "VARCHAR", "nullable": false}, {"name": "email", "type": "VARCHAR", "nullable": true} ], "rows": [ {"customer_id": "C001", "email": "alice@example.com"}, {"customer_id": "C002", "email": "bob@example.com"} ] }

List Audiences by Model

GET /api/v1/workspaces/{id}/models/{modelId}/audiences

Returns all audiences attached to a specific parent model.


Estimate Filter

POST /api/v1/workspaces/{id}/models/{modelId}/estimate-filter

Estimates the count of matching records for an ad-hoc filter tree without creating an audience. Useful for the audience builder UI to show real-time size estimates.

Request Body

FieldTypeRequiredDescription
filter_treeobjectYesFilter tree to evaluate

Response

{ "estimated_size": 3200 }

Audience Object

FieldTypeDescription
idstring (UUID)Unique identifier
workspace_idstring (UUID)Owning workspace
parent_model_idstring (UUID)Parent entity model
namestringDisplay name
descriptionstringDescription
filter_treeobjectRecursive filter tree definition
estimated_sizeinteger or nullLast estimated member count
estimated_atstring (ISO 8601) or nullWhen size was last estimated
statusstringdraft, active, archived, or error
status_errorstringError message when status is error
identity_graph_idstring (UUID) or nullOptional identity graph for cross-model resolution
created_bystring (UUID)Account that created the audience
created_atstring (ISO 8601)Creation timestamp
updated_atstring (ISO 8601)Last update timestamp
Last updated on