Skip to main content
POST
Create a segment

Authorizations

Authorization
string
header
required

Your project's secret key (pk_…, without the pub segment). Server-side only — never ship it to a browser. Get it from Settings → Projects in the dashboard.

Body

application/json
key
string
required

Stable machine key, unique within the project: lowercase letters, digits, hyphens, underscores; must not start with "seg_" (reserved for opaque ids).

Maximum string length: 64
Pattern: ^[a-z0-9](?:[a-z0-9_-]*[a-z0-9])?$
name
string
required
Maximum string length: 80
expression
object
required

Versioned, strictly validated audience rule. Example: { "version": 1, "root": { "kind": "all", "children": [ { "kind": "field", "field": { "kind": "trait", "key": "plan" }, "op": "eq", "value": "free" }, { "kind": "not", "child": { "kind": "event", "event": "used_csv_export" } } ] } }

Example:
description
string | null

The audience's intent.

Maximum string length: 1000
reason
string

Why this segment/version exists; stored on version 1.

Maximum string length: 500
agentRunId
string | null

Originating agent run in this project (400 if it belongs elsewhere).

Minimum string length: 1
idempotencyKey
string

Retry-safety token: the same project + key always returns the originally created segment.

Maximum string length: 128

Response

Idempotent replay — the segment this idempotencyKey originally created.

segment
object
required