Skip to main content
A segment is a named, filtered view of a model: the records matching a filter, optionally sorted, limited, and scoped to specific columns. Segments are what you point batches, exports, and change feeds at. You define one with defineSegment.

Define a segment

segments/us-icp.ts
The server derives the segment’s own slug from its name (which defaults to the title-cased code slug), and the segment is state-tracked and adopted by name — so re-deploying the same definition reattaches rather than duplicates.
To reference a segment that already exists in the workspace instead of defining it, use segmentRef("<segment-uuid>") — see Referencing existing resources.

Use a segment

Run a play across a segment as a batch, or export its records:
segment fetch and segment download take --model-uuid, not --segment-uuid — they query a model with segment-style filters.

Next steps

Plays

Trigger automations over the rows a segment tracks.

Querying data

SQL over the models behind your segments.