Skip to main content
The Audience Filter DSL is a structured query language used to define audience segments. Filters are passed as JSON objects when creating or updating audiences via the API. Every audience requires a filter group at the top level. Groups can contain conditions, nested groups, or both — enabling arbitrarily complex logic.

Filter Group Structure

A filter group combines conditions with a logical operator.
Every filter group must contain at least one condition or one nested group. An empty group will be rejected with the empty_filter_group error.

Condition Types

Each condition object must include a condition_type field that determines which fields and operators are valid.
Requests use the snake_case key condition_type. In API responses, condition objects are serialized with camelCase keys — conditionType, and (always present) listId. Optional keys joinOperator, secondaryOperator, secondaryValue, and secondaryUnit appear only when set.

1. Time Conditions

Filter contacts by time-based fields using relative or absolute time windows.
Valid Fields: Valid Operators: Valid Units: days, hours, minutes
The exists and not_exists operators do not require value or unit. All other operators require both.

2. Count Conditions

Filter contacts by numeric count fields such as send count, click count, or conversion count.
Valid Fields: Valid Operators:

3. Custom Field Conditions

Filter contacts by any custom field stored on the contact record. Custom fields are arbitrary key-value pairs you define when creating or updating contacts.
Valid Fields: Any custom field key that exists on your contacts. Valid Operators:

4. Carrier Conditions

Filter contacts by their mobile carrier.
Valid Fields: carrier Valid Operators:

5. Timezone Conditions

Filter contacts by their timezone.
Valid Fields: timezone Valid Operators: Timezone values use the IANA timezone database format (e.g., America/New_York, US/Pacific, Europe/London).

6. Revenue Conditions

Filter contacts by revenue data.
Valid Fields: Valid Operators:

7. Phone Numbers Conditions

Filter contacts by matching against an explicit list of phone numbers.
The field key must be present on a phone_numbers condition. Its value is not used for matching, but the underlying model requires the field — omitting it currently causes a 500 error rather than a validation error. Send any non-empty string (e.g. "phone").
Valid Fields: The field value is not used for matching, but field must be present (any non-empty string). Valid Operators: value must be a non-empty array of phone numbers. An empty or missing list is rejected with missing_phone_numbers_value.

Nesting Groups

Groups can be nested to create complex boolean logic. Each nested group has its own operator and set of conditions. Example: Find contacts who were sent a message AND clicked within 30 days, AND whose carrier is either T-Mobile OR AT&T.
This evaluates as:
You can nest groups multiple levels deep. There is no hard limit on nesting depth, but deeply nested filters will take longer to evaluate.

Validation Error Codes

If your filter is malformed, the API returns a 400 response with one of the following error codes:

Next Steps

Creating Audiences

Build audience segments in the UI

Create Audience

Create an audience via the API