Segments
Create dynamic contact segments for targeted campaigns.
Segments are dynamic groups of contacts filtered by rules. Pass a segmentId when creating a campaign to target only matching contacts.
Segment object
{
"id": "seg_01HV...",
"name": "Pro plan users",
"filter": {
"and": [
{ "field": "data.plan", "op": "eq", "value": "pro" },
{ "field": "subscribed", "op": "eq", "value": true }
]
},
"contactCount": 1824,
"createdAt": "2026-02-01T10:00:00Z"
}Contact counts update asynchronously and may lag a few minutes.
Filter syntax
{
"and": [
{ "field": "tags", "op": "contains", "value": "beta" },
{ "field": "subscribed", "op": "eq", "value": true }
]
}Operators: eq · neq · contains · not_contains · gt · lt
Fields: any contact field — email, firstName, subscribed, tags, or nested data via dot notation (data.plan, data.signupSource).
List segments
Get a segment
Returns the segment with its current contactCount.
Using a segment in a campaign
Pass segmentId when creating or updating a campaign:
{
"name": "Pro plan campaign",
"subject": "New features for Pro users",
"from": "hello@yourdomain.com",
"body": "<p>Here is what is new...</p>",
"segmentId": "seg_01HV..."
}Segments are evaluated at send time. Contacts who match the filter after the campaign was created will still be included.

