Skip to content

Segments

Segments are flat predicate lists over traits and event history, recomputed synchronously on every write; transitions emit system.segment_entered/system.segment_exited system events that journeys trigger on. See the Segments guide for the predicate semantics. All mutations require org:admin.

Create a segment

Auth: Clerk session token.

Request body

{
"data": {
"name": "string",
"description": "string",
"definition": {
"match": "all",
"appId": "string",
"predicates": [
{
"kind": "trait",
"name": "string",
"op": "eq",
"value": {}
}
]
},
"environments": [
"development",
"production"
]
}
}
Field Type Required Constraints
data object yes
data.name string yes length 1–100
data.description string | null no
data.definition object yes
data.definition.match “all” | “any” no default "all"
data.definition.appId string | string[] | null no
data.definition.predicates array of variants yes items 1–∞
data.definition.predicates[] one of yes
data.definition.predicates[]〈trait〉 object yes
data.definition.predicates[]〈trait〉.kind “trait” yes
data.definition.predicates[]〈trait〉.name string yes length 1–200
data.definition.predicates[]〈trait〉.op “eq” | “neq” | “gt” | “gte” | “lt” | “lte” | “exists” | “notExists” | “contains” yes
data.definition.predicates[]〈trait〉.value any no
data.definition.predicates[]〈event〉 object yes
data.definition.predicates[]〈event〉.kind “event” yes
data.definition.predicates[]〈event〉.name string yes length 1–200
data.definition.predicates[]〈event〉.op “performed” | “notPerformed” yes
data.definition.predicates[]〈event〉.atLeast integer no default 1; 1 ≤ x ≤ ∞
data.definition.predicates[]〈event〉.withinDays integer no 1 ≤ x ≤ ∞
data.environments “development” | “production”[] no default ["development","production"]; items 1–∞

Response 201

{
"data": {
"id": "string",
"orgId": "string",
"name": "string",
"description": "string",
"definition": {
"match": "all",
"appId": "string",
"predicates": [
{
"kind": "trait",
"name": "string",
"op": "eq",
"value": {}
}
]
},
"environments": [
"development"
],
"createdAt": "2026-01-15T09:30:00.000Z",
"updatedAt": "2026-01-15T09:30:00.000Z",
"memberCount": 42
},
"meta": {
"requestId": "string",
"nextCursor": "string",
"hasMore": true
}
}
Field Type Required Constraints
data object yes
data.id string yes
data.orgId string yes
data.name string yes
data.description string | null yes
data.definition object yes
data.definition.match “all” | “any” yes default "all"
data.definition.appId string | string[] | null no
data.definition.predicates array of variants yes items 1–∞
data.definition.predicates[] one of yes
data.definition.predicates[]〈trait〉 object yes
data.definition.predicates[]〈trait〉.kind “trait” yes
data.definition.predicates[]〈trait〉.name string yes length 1–200
data.definition.predicates[]〈trait〉.op “eq” | “neq” | “gt” | “gte” | “lt” | “lte” | “exists” | “notExists” | “contains” yes
data.definition.predicates[]〈trait〉.value any no
data.definition.predicates[]〈event〉 object yes
data.definition.predicates[]〈event〉.kind “event” yes
data.definition.predicates[]〈event〉.name string yes length 1–200
data.definition.predicates[]〈event〉.op “performed” | “notPerformed” yes
data.definition.predicates[]〈event〉.atLeast integer yes default 1; 1 ≤ x ≤ ∞
data.definition.predicates[]〈event〉.withinDays integer no 1 ≤ x ≤ ∞
data.environments “development” | “production”[] yes items 1–∞
data.createdAt string (date-time) yes
data.updatedAt string (date-time) yes
data.memberCount integer yes 0 ≤ x ≤ ∞
meta object no
meta.requestId string no
meta.nextCursor string | null no
meta.hasMore boolean no

Errors follow the shared envelope and code table.

Preview a draft definition

Auth: Clerk session token.

Request body

{
"data": {
"match": "all",
"appId": "string",
"predicates": [
{
"kind": "trait",
"name": "string",
"op": "eq",
"value": {}
}
]
}
}
Field Type Required Constraints
data object yes
data.match “all” | “any” no default "all"
data.appId string | string[] | null no
data.predicates array of variants yes items 1–∞
data.predicates[] one of yes
data.predicates[]〈trait〉 object yes
data.predicates[]〈trait〉.kind “trait” yes
data.predicates[]〈trait〉.name string yes length 1–200
data.predicates[]〈trait〉.op “eq” | “neq” | “gt” | “gte” | “lt” | “lte” | “exists” | “notExists” | “contains” yes
data.predicates[]〈trait〉.value any no
data.predicates[]〈event〉 object yes
data.predicates[]〈event〉.kind “event” yes
data.predicates[]〈event〉.name string yes length 1–200
data.predicates[]〈event〉.op “performed” | “notPerformed” yes
data.predicates[]〈event〉.atLeast integer no default 1; 1 ≤ x ≤ ∞
data.predicates[]〈event〉.withinDays integer no 1 ≤ x ≤ ∞

Response 200

{
"data": {
"memberCount": 42,
"members": [
"string"
],
"scanned": 42,
"truncated": true
},
"meta": {
"requestId": "string",
"nextCursor": "string",
"hasMore": true
}
}
Field Type Required Constraints
data object yes
data.memberCount integer yes 0 ≤ x ≤ ∞
data.members string[] yes
data.scanned integer yes 0 ≤ x ≤ ∞
data.truncated boolean yes
meta object no
meta.requestId string no
meta.nextCursor string | null no
meta.hasMore boolean no

Errors follow the shared envelope and code table.

List segments

Auth: Clerk session token.

Query parameters

{
"cursor": "string",
"limit": 50,
"q": "string"
}
Field Type Required Constraints
cursor string no
limit integer no default 50; 1 ≤ x ≤ 100
q string no length 0–200

Response 200

{
"data": [
{
"id": "string",
"orgId": "string",
"name": "string",
"description": "string",
"definition": {
"match": "all",
"appId": "string",
"predicates": [
{
"kind": "trait",
"name": "string",
"op": "eq",
"value": {}
}
]
},
"environments": [
"development"
],
"createdAt": "2026-01-15T09:30:00.000Z",
"updatedAt": "2026-01-15T09:30:00.000Z"
}
],
"meta": {
"requestId": "string",
"nextCursor": "string",
"hasMore": true
}
}
Field Type Required Constraints
data object[] yes
data[] object yes
data[].id string yes
data[].orgId string yes
data[].name string yes
data[].description string | null yes
data[].definition object yes
data[].definition.match “all” | “any” yes default "all"
data[].definition.appId string | string[] | null no
data[].definition.predicates array of variants yes items 1–∞
data[].definition.predicates[] one of yes
data[].definition.predicates[]〈trait〉 object yes
data[].definition.predicates[]〈trait〉.kind “trait” yes
data[].definition.predicates[]〈trait〉.name string yes length 1–200
data[].definition.predicates[]〈trait〉.op “eq” | “neq” | “gt” | “gte” | “lt” | “lte” | “exists” | “notExists” | “contains” yes
data[].definition.predicates[]〈trait〉.value any no
data[].definition.predicates[]〈event〉 object yes
data[].definition.predicates[]〈event〉.kind “event” yes
data[].definition.predicates[]〈event〉.name string yes length 1–200
data[].definition.predicates[]〈event〉.op “performed” | “notPerformed” yes
data[].definition.predicates[]〈event〉.atLeast integer yes default 1; 1 ≤ x ≤ ∞
data[].definition.predicates[]〈event〉.withinDays integer no 1 ≤ x ≤ ∞
data[].environments “development” | “production”[] yes items 1–∞
data[].createdAt string (date-time) yes
data[].updatedAt string (date-time) yes
meta object no
meta.requestId string no
meta.nextCursor string | null no
meta.hasMore boolean no

Errors follow the shared envelope and code table.

Fetch one segment with its member count

Auth: Clerk session token.

Response 200

{
"data": {
"id": "string",
"orgId": "string",
"name": "string",
"description": "string",
"definition": {
"match": "all",
"appId": "string",
"predicates": [
{
"kind": "trait",
"name": "string",
"op": "eq",
"value": {}
}
]
},
"environments": [
"development"
],
"createdAt": "2026-01-15T09:30:00.000Z",
"updatedAt": "2026-01-15T09:30:00.000Z",
"memberCount": 42
},
"meta": {
"requestId": "string",
"nextCursor": "string",
"hasMore": true
}
}
Field Type Required Constraints
data object yes
data.id string yes
data.orgId string yes
data.name string yes
data.description string | null yes
data.definition object yes
data.definition.match “all” | “any” yes default "all"
data.definition.appId string | string[] | null no
data.definition.predicates array of variants yes items 1–∞
data.definition.predicates[] one of yes
data.definition.predicates[]〈trait〉 object yes
data.definition.predicates[]〈trait〉.kind “trait” yes
data.definition.predicates[]〈trait〉.name string yes length 1–200
data.definition.predicates[]〈trait〉.op “eq” | “neq” | “gt” | “gte” | “lt” | “lte” | “exists” | “notExists” | “contains” yes
data.definition.predicates[]〈trait〉.value any no
data.definition.predicates[]〈event〉 object yes
data.definition.predicates[]〈event〉.kind “event” yes
data.definition.predicates[]〈event〉.name string yes length 1–200
data.definition.predicates[]〈event〉.op “performed” | “notPerformed” yes
data.definition.predicates[]〈event〉.atLeast integer yes default 1; 1 ≤ x ≤ ∞
data.definition.predicates[]〈event〉.withinDays integer no 1 ≤ x ≤ ∞
data.environments “development” | “production”[] yes items 1–∞
data.createdAt string (date-time) yes
data.updatedAt string (date-time) yes
data.memberCount integer yes 0 ≤ x ≤ ∞
meta object no
meta.requestId string no
meta.nextCursor string | null no
meta.hasMore boolean no

Errors follow the shared envelope and code table.

Update a segment

Auth: Clerk session token.

Request body

{
"data": {
"name": "string",
"description": "string",
"definition": {
"match": "all",
"appId": "string",
"predicates": [
{
"kind": "trait",
"name": "string",
"op": "eq",
"value": {}
}
]
},
"environments": [
"development"
]
}
}
Field Type Required Constraints
data object yes
data.name string no length 1–100
data.description string | null no
data.definition object no
data.definition.match “all” | “any” no default "all"
data.definition.appId string | string[] | null no
data.definition.predicates array of variants yes items 1–∞
data.definition.predicates[] one of yes
data.definition.predicates[]〈trait〉 object yes
data.definition.predicates[]〈trait〉.kind “trait” yes
data.definition.predicates[]〈trait〉.name string yes length 1–200
data.definition.predicates[]〈trait〉.op “eq” | “neq” | “gt” | “gte” | “lt” | “lte” | “exists” | “notExists” | “contains” yes
data.definition.predicates[]〈trait〉.value any no
data.definition.predicates[]〈event〉 object yes
data.definition.predicates[]〈event〉.kind “event” yes
data.definition.predicates[]〈event〉.name string yes length 1–200
data.definition.predicates[]〈event〉.op “performed” | “notPerformed” yes
data.definition.predicates[]〈event〉.atLeast integer no default 1; 1 ≤ x ≤ ∞
data.definition.predicates[]〈event〉.withinDays integer no 1 ≤ x ≤ ∞
data.environments “development” | “production”[] no items 1–∞

Response 200

{
"data": {
"id": "string",
"orgId": "string",
"name": "string",
"description": "string",
"definition": {
"match": "all",
"appId": "string",
"predicates": [
{
"kind": "trait",
"name": "string",
"op": "eq",
"value": {}
}
]
},
"environments": [
"development"
],
"createdAt": "2026-01-15T09:30:00.000Z",
"updatedAt": "2026-01-15T09:30:00.000Z",
"memberCount": 42
},
"meta": {
"requestId": "string",
"nextCursor": "string",
"hasMore": true
}
}
Field Type Required Constraints
data object yes
data.id string yes
data.orgId string yes
data.name string yes
data.description string | null yes
data.definition object yes
data.definition.match “all” | “any” yes default "all"
data.definition.appId string | string[] | null no
data.definition.predicates array of variants yes items 1–∞
data.definition.predicates[] one of yes
data.definition.predicates[]〈trait〉 object yes
data.definition.predicates[]〈trait〉.kind “trait” yes
data.definition.predicates[]〈trait〉.name string yes length 1–200
data.definition.predicates[]〈trait〉.op “eq” | “neq” | “gt” | “gte” | “lt” | “lte” | “exists” | “notExists” | “contains” yes
data.definition.predicates[]〈trait〉.value any no
data.definition.predicates[]〈event〉 object yes
data.definition.predicates[]〈event〉.kind “event” yes
data.definition.predicates[]〈event〉.name string yes length 1–200
data.definition.predicates[]〈event〉.op “performed” | “notPerformed” yes
data.definition.predicates[]〈event〉.atLeast integer yes default 1; 1 ≤ x ≤ ∞
data.definition.predicates[]〈event〉.withinDays integer no 1 ≤ x ≤ ∞
data.environments “development” | “production”[] yes items 1–∞
data.createdAt string (date-time) yes
data.updatedAt string (date-time) yes
data.memberCount integer yes 0 ≤ x ≤ ∞
meta object no
meta.requestId string no
meta.nextCursor string | null no
meta.hasMore boolean no

Errors follow the shared envelope and code table.

Delete a segment

Auth: Clerk session token.

Response 200

{
"data": {
"deleted": true
},
"meta": {
"requestId": "string",
"nextCursor": "string",
"hasMore": true
}
}
Field Type Required Constraints
data object yes
data.deleted true yes
meta object no
meta.requestId string no
meta.nextCursor string | null no
meta.hasMore boolean no

Errors follow the shared envelope and code table.

List a segment’s members

Auth: Clerk session token.

Query parameters

{
"cursor": "string",
"limit": 50
}
Field Type Required Constraints
cursor string no
limit integer no default 50; 1 ≤ x ≤ 100

Response 200

{
"data": [
{
"segmentId": "string",
"orgId": "string",
"profileId": "string",
"enteredAt": "2026-01-15T09:30:00.000Z"
}
],
"meta": {
"requestId": "string",
"nextCursor": "string",
"hasMore": true
}
}
Field Type Required Constraints
data object[] yes
data[] object yes
data[].segmentId string yes
data[].orgId string yes
data[].profileId string yes
data[].enteredAt string (date-time) yes
meta object no
meta.requestId string no
meta.nextCursor string | null no
meta.hasMore boolean no

Errors follow the shared envelope and code table.