Skip to content

Create a segment

A segment is a named, reusable query against the user base. Segments are the audience layer for push campaigns and can also be attached to promos.

Users → Segments (/users/segments).

FieldTypeNotes
Namestring, ≤80Human-readable, unique.
Descriptionstring, ≤500What this segment is for.
QueryJSONThe filter DSL: see below.
Cached sizeintLast-computed audience size (updated on estimate).
Cached atISO datetimeFreshness stamp.

Segments use a small AND/OR DSL over user + event attributes. Example: “Registered users in EG who purchased in the last 14 days AND haven’t hit their coin balance in 7 days”:

{
"and": [
{ "field": "status", "op": "eq", "value": "active" },
{ "field": "isGuest", "op": "eq", "value": false },
{ "field": "countryCode", "op": "eq", "value": "EG" },
{ "field": "purchasedInDays", "op": "lte", "value": 14 },
{ "field": "balanceMovementInDays", "op": "gt", "value": 7 }
]
}

Supported fields:

FieldTypeOps
statusenumeq, neq, in
isGuestbooleq
countryCodestringeq, in
languagestringeq, in
createdAtDaysint (days ago)lte, gte, between
lastSeenDaysintlte, gte
totalSpendCentsintlte, gte
balanceTotalintlte, gte
hasActiveSubscriptionbooleq
purchasedInDaysintlte, gte
unlockedInDaysintlte, gte
balanceMovementInDaysintlte, gte
pushCategoryOptedOutstringeq

Estimate button: runs the query with a SELECT COUNT and caches the result. Estimates are approximate (±5%) at scale; for exact numbers, run the segment against actual push send.

  • Push campaigns: pick a segment as the audience.
  • Promos: restrict a promo’s eligibility to a segment.
  • Analytics ad-hoc: filter dashboards by segment (planned).

Segments are evaluated at send time, not at creation time. If a segment says “users in EG”, a user who moves to another country stops matching by the next send.

Cached size is refreshed:

  • Manually on Estimate
  • Automatically before each push send (the composer shows the fresh number)
  • Query size limits: the DSL supports up to 20 filter nodes. Deeper is refused at validation.
  • Guest users: most segments implicitly filter to registered users. If you want a guest campaign, set isGuest=true explicitly.
  • Delete-in-use: segments referenced by an active push campaign or promo can’t be deleted. Unlink first.
ActionEndpoint
ListGET /v1/admin/segments
DetailGET /v1/admin/segments/:id
CreatePOST /v1/admin/segments
UpdatePUT /v1/admin/segments/:id
DeleteDELETE /v1/admin/segments/:id
Estimate sizePOST /v1/admin/segments/:id/estimate
Estimate ad-hocPOST /v1/admin/segments/estimate (pass query in body)

Full details in API: Engagement.