Segments API
A segment is a saved audience definition — a filter over your contacts (attributes, custom fields, engagement history, loyalty traits) that campaigns, flows, and personalization can target. The saved-segment CRUD surface lives under the Contacts API; this page covers the top-level segment endpoints that operate on audiences without requiring you to save one first, plus AI-assisted segment discovery. Base path:/api/v1/segments (ad-hoc + AI endpoints below) and /api/v1/contacts/segments (saved-segment CRUD, membership, and its own GET /{id}/export.csv — see the Contacts API).
Authentication: API key (X-API-Key) or session JWT.
AI auto-suggest
Unlike the description-driven segment builder (POST /contacts/segments/autopilot, which turns a sentence like “everyone who clicked the pricing page but didn’t book a demo” into a filter), auto-suggest takes no input — it reads your org’s own CDP event volume (top event names, contact tags, engagement histogram) and proposes up to 5 segments you probably haven’t created yet, each with a name, a one-line pitch, a rationale, and a ready-to-use filter. Nothing is persisted — the operator picks a suggestion to pre-fill the create-segment dialog.
Ad-hoc CSV export
GET /contacts/segments/{id}/export.csv already streams a saved segment’s membership as CSV. POST /segments/export.csv covers the case where you haven’t saved a segment yet — you have a filter (the same filter shape the segment builder and auto-suggest use) and just want the matching contacts as a one-off download, without persisting a segment or waiting for membership to materialize.
Hard-capped at 50,000 rows per call (the optional limit in the body can set a lower cap). When the result set hits the cap, the response carries an X-Export-Truncated: true header so you know the file is partial — save the audience as a segment and use the paginated saved-segment export for a larger or recurring pull.
Clicked-link cohorts
POST /segments/from-clicks closes the loop from link engagement to audience: given a tracked short link (link_id) or every link in a campaign (campaign_id), it resolves the distinct contacts who clicked and materializes them as a static segment — no filter rules, just a point-in-time snapshot of “people who clicked this.” Useful for a targeted re-engagement send to exactly the people who showed interest.
Because click activity is a point-in-time event rather than a live trait, the resulting segment does not auto-refresh — generate a fresh cohort to capture a later window. The request body must contain at least one of link_id or campaign_id, and accepts an optional window_days (1–365), name, and description.
Examples
POST /segments/auto-suggest
Request (all fields are optional —limit defaults to 5 and is clamped to 8):
name, description (a one-line, operator-facing pitch), rationale (why it is high-value for your data), and filters (a filter tree you can persist as-is). Every suggestion is validated against your contacts before the response — suggestions that would match nothing are dropped, and llm_dropped_count tells you how many were filtered out.
422 AI_PARSE_FAILED when the model output is not parseable, 502 AI_SUGGEST_FAILED when the suggestion call itself fails, and 503 SERVICE_UNAVAILABLE when auto-suggest is not enabled on the deployment. Retry on 502; on 422 and 503, fall back to the manual segment builder.
POST /segments/export.csv
Request — any filter tree the segment builder accepts, plus an optional per-call row cap and download filename:Content-Type: text/csv, Content-Disposition: attachment; filename="na-customers-opted-in-2026-08-25.csv"). Phone and email columns honour the caller’s role and reveal-context exactly as the dashboard does — a caller without reveal permission receives masked values.
GET /contacts/segments/{id}/export.csv instead.
POST /segments/from-clicks
Request — scope the cohort bylink_id or campaign_id, optionally narrow to a recency window and name the segment:
Recipe: auto-suggest → saved segment → campaign target
The full loop, end to end:- Get suggestions.
POST /segments/auto-suggestand readdata.suggestions. Each suggestion’sfiltersis a ready-to-persist filter definition. - Pick one and persist it. Pass the suggestion’s
filtersto the saved-segment create endpoint with a name — membership materializes immediately on create, so the segment is usable without waiting for the refresh cycle:
- Use the returned segment id. Target it from a campaign audience, a flow trigger, or the personalization rule engine — anywhere a
segment_idis accepted. A saved segment auto-refreshes (unless you created it from a click cohort, which is a fixed snapshot), so step 2 is done once and steps 1–3 can be repeated whenever you want fresh suggestions.
filters body to POST /segments/export.csv and download the matching rows — that one-off export never persists anything.
SDK note
The Node SDK covers saved-segment CRUD (orbit.contacts.segments.list() / .create() / .get() over /contacts/segments). The three ad-hoc endpoints on this page — auto-suggest, ad-hoc export, and click cohorts — are invoked directly over HTTP as shown above; parse the CSV responses yourself or save the audience as a segment and use the SDK’s saved-segment surface.
See also
- Contacts API — saved-segment CRUD, membership, and paginated export
- Loyalty API — loyalty traits usable as segment filter conditions
- Links API — the short links
from-clicksresolves against