Most segments are best authored in the Spotzee UI — operators iterate quickly, preview membership, and version their work. Use the API when the rules themselves are derived from your code or config: a generated cohort per pricing plan, a per-region segment driven by a feature-flag rollout, or a backfill that needs to recreate dozens of segments at once.Documentation Index
Fetch the complete documentation index at: https://docs.spotzee.com/llms.txt
Use this file to discover all available pages before exploring further.
Today the API exposes segments as dynamic lists. There is no separate
/segments endpoint — a segment is a list with type: "dynamic" and a rule tree. Static lists (explicit member add/remove) use the same endpoints with type: "static".What you’ll build
A script that creates a dynamic list with a rule tree, then walks its members.Prerequisites
You’ll need ask_ project key with write access. See Authentication.
Walkthrough
Decide what membership means
A segment is a boolean rule that yields true or false for any contact. Common shapes:
- Attribute filter —
data.plan = "professional" - Behavioural filter — contacts who triggered
order_placedin the last 30 days - Combined —
plan = "professional"AND triggeredorder_placedin the last 30 days
Build the rule tree
Spotzee rules are nested groups. The top level is a group with an operator (Leaf shapes:
and / or) and a list of children. Each child is either another group or a leaf comparing a field to a value.type | What it does |
|---|---|
user | Compares a field on the contact (email, external_id, data.<key>) to a value |
event | Filters by an event name with optional frequency window |
Create the list
POST /lists with type: "dynamic":id. Save it — that’s how you’ll reference the segment from journeys, campaigns, and member-listing endpoints.Walk the members
Members are computed asynchronously — give Spotzee a moment after creation, then page the list:See Pagination for the cursor pattern.
Pitfalls to avoid
- Don’t filter on fields you haven’t populated yet. A rule on
data.planreturns zero members until at least one contact has that field. Sync your contacts first (Sync contacts), then build segments. - Don’t bury the rule in too many layers. Spotzee accepts deeply nested groups, but a rule that spans more than two
and/orlayers is hard for operators to read in the UI.
Reference
- API surface — see Main API → Lists
- Sync contacts first — see Sync contacts from your CRM
- Pagination — see Pagination
- Conceptual overview — see Segments