Features

Segments

Create dynamic audience segments

Overview

Dynamic segments filter your contacts based on a set of rules. Segments are evaluated in real time, so the list of matching contacts always reflects the current state of your data. Use segments to target specific audiences for campaigns, A/B tests, or one-off sends.

List Segments

Retrieve all segments along with their rule definitions.

GET/api/segments

Returns all segments with their rule definitions and contact counts.

Response

json
[
  {
    "id": 1,
    "name": "Active Enterprise",
    "rules": [
      { "field": "status", "operator": "equals", "value": "active" },
      { "field": "company", "operator": "contains", "value": "Inc" }
    ],
    "contacts_count": 142
  },
  {
    "id": 2,
    "name": "Recent Signups",
    "rules": [
      { "field": "created_at", "operator": "after", "value": "2026-01-01" }
    ],
    "contacts_count": 58
  }
]

Create Segment

Create a new segment by providing a name and an array of filter rules. Rules are combined with AND logic, meaning contacts must match all conditions to be included.

POST/api/segments

Create a new dynamic segment with filter rules.

Parameters

NameTypeDescription
name*stringDisplay name for the segment
rules*arrayJSON array of filter conditions

Request

json
{
  "name": "Active Enterprise",
  "rules": [
    { "field": "status", "operator": "equals", "value": "active" },
    { "field": "company", "operator": "contains", "value": "Inc" }
  ]
}

Response

json
{
  "id": 3,
  "name": "Active Enterprise",
  "rules": [
    { "field": "status", "operator": "equals", "value": "active" },
    { "field": "company", "operator": "contains", "value": "Inc" }
  ],
  "contacts_count": 142
}

Get Segment Contacts

Retrieve the list of contacts that currently match a segment's rules.

GET/api/segments/contacts?segment_id=1

Returns all contacts that match the segment's filter rules.

Parameters

NameTypeDescription
segment_id*numberID of the segment to query

Response

json
[
  {
    "id": 12,
    "email": "alice@acme-inc.com",
    "name": "Alice Chen",
    "company": "Acme Inc",
    "status": "active"
  },
  {
    "id": 34,
    "email": "bob@globex-inc.com",
    "name": "Bob Martin",
    "company": "Globex Inc",
    "status": "active"
  }
]

Rule Format

Each rule is a JSON object with three fields: field, operator, and value. Multiple rules are combined with AND logic.

Example rules
[
  {
    "field": "status",
    "operator": "equals",
    "value": "active"
  },
  {
    "field": "company",
    "operator": "contains",
    "value": "Inc"
  }
]

Supported operators include equals, not_equals,contains, not_contains,starts_with, before, and after. The available fields correspond to contact properties such as status, company,email, name, and created_at.