Segments
A segment is a group of profiles. Dynamic segments are described by a definition and recompute themselves; static segments are a list you maintain. The same definition format also powers contact search.
The definition format
A definition is groups of conditions. Conditions inside a group combine with the group's logic; groups combine with the top-level logic (default AND).
{
"logic": "OR",
"groups": [
{ "logic": "AND", "conditions": [
{ "field": "country", "operator": "equals", "value": "DE" },
{ "field": "lifetimeRevenue", "operator": "greater_than", "value": 500 }
] },
{ "logic": "AND", "conditions": [
{ "field": "country", "operator": "is_one_of", "value": ["AT", "CH"] }
] }
]
}- 1 to 5 groups, 1 to 20 conditions per group.
- A condition may itself be a group,
{ "logic": "OR", "conditions": [ … ] }, one level deep, holding field and event conditions. - An invalid definition is a
400withmessage: "Invalid segment definition"andissuesnaming each problem, for example an unknown field together with the valid ones.
Field conditions
{ "field": <key>, "operator": <operator>, "value": <value> }. The field is any key from GET /contacts/fields (see Attributes), plus the built-in email, externalId, firstName, lastName, country, consentStatus, createdAt and randomBucket. Which operators apply depends on the field's type:
text, categorical | equals, not_equals, contains (part of the text, any case), is_one_of, is_not_one_of, is_empty, is_not_empty |
number | equals, not_equals, greater_than, greater_than_or_equal, less_than, less_than_or_equal, is_one_of, is_not_one_of, is_empty, is_not_empty |
boolean | equals, not_equals, is_empty, is_not_empty |
date | less_than, less_than_or_equal, equals, greater_than_or_equal, greater_than (a day such as 2026-11-21, or a date and time), within_last, not_within_last, before_relative (a relative value, below), is_empty, is_not_empty |
list | equals (has the value), not_equals (does not have it), is_one_of (has any), is_not_one_of (has none), contains_all (has every one), is_empty, is_not_empty |
is_one_of,is_not_one_ofandcontains_alltake a non-empty array;is_emptyandis_not_emptytake no value; everything else takes one value, a number for number fields.- A day compares as a whole day on your workspace clock:
less_than2026-11-21 is up to 20 November,less_than_or_equalincludes 21 November,equalsis 21 November only,greater_than_or_equalstarts on 21 November andgreater_thanstarts on 22 November.beforestill meansless_than, and anaftermeansgreater_than_or_equal. A date and time without an offset is workspace time and compares as that moment. - Relative dates are
{ "amount": 90, "unit": "days" }, withdays,weeks(7 days) ormonths(30 days) and an amount of 1 to 3650.{ "field": "lastOrderAt", "operator": "not_within_last", "value": { "amount": 90, "unit": "days" } }is everyone without an order in the last 90 days, including those who never ordered. not_equalsalso matches profiles that have no value at all.
Event conditions
Matches profiles that had at least one event of a type, or with negate: true none at all:
{
"kind": "event",
"eventType": "order_completed",
"negate": true,
"dateRange": { "type": "relative", "value": 30, "unit": "days" },
"where": [ { "property": "channel", "operator": "equals", "value": "web" } ]
}dateRange(optional) is{ "type": "relative", "value": 30, "unit": "days" }(the number isvaluehere, not theamountof a field condition) or{ "type": "absolute", "start": "2026-06-01", "end": "2026-06-30" }. Days are days on your workspace clock, and both days are included in full. A bound with a time is that moment (workspace time without an offset). WithoutdateRangeany time counts.where(optional, up to 5) filters on the event's properties by dotted path:equals,not_equals,greater_than,greater_than_or_equal,less_than,less_than_or_equal,contains,is_one_of,is_set,is_not_set.after(optional) places the event relative to one of the profile's own dates:{ "field": "createdAt", "from": { "amount": 1, "unit": "months" }, "to": { "amount": 2, "unit": "months" } }is an event one to two months after the profile was created.
Static segment references
{ "kind": "segment", "segmentId": "…" } matches the members of one of your static segments, combinable with any other condition in its group. Dynamic and archived segments cannot be referenced.
Counting and listing who matches
/segments/preview{ "definition": { "groups": [ … ] }, "limit": 20 }
# 200 →
{
"count": 1840,
"sample": [ { "id": "3f2a…", "email": "ada@example.com", "firstName": "Ada", … } ],
"definition": { … },
"explanation": [ "…one line per condition, in words…" ]
}Tries a definition without saving anything: how many profiles match, a sample (limit 1–100, default 20), the definition as it was read, and the conditions in words. To page through every match, use POST /contacts/search with the same definition.
Reading your segments
/segmentsEvery segment, archived ones included, newest first: id, name, status (active or archived), kind (dynamic or static), folder, currentVersion, createdAt, and profileCount with its countState (counted, pending or failed). A dynamic segment's count can be pending; GET /segments/counts computes the pending ones and returns { id, profileCount, countState, countedAt, countError } per segment.
/segments/:idOne segment with its current definition, the explanation in words, the live count, a sample of ten members and its version history. A reference to an archived segment keeps working, and its line in explanation ends in (archived), for example in segment "VIPs" (archived). The same applies to POST /segments/preview. To list all members, pass the definition to POST /contacts/search. For a static segment, search for { "kind": "segment", "segmentId": "<its id>" }. A search that references an archived static segment, directly or inside another segment's definition, is a 400; restore the segment in the app first.
Static segment members
/segments/:id/members{ "add": ["3f2a…", "9b1c…"], "remove": ["77de…"] }
# 200 → { "segmentId": "…", "added": 2, "removed": 1, "memberCount": 312 }Adds and removes members of a static segment by OpenHouse contact id, up to 500 of each per call; batch larger changes. added and removed count what actually changed: adding a member twice or removing a non-member is not an error, and ids that are not your contacts are ignored. A dynamic segment is a 400, because its membership follows its definition. Every call is written to your audit log.