List dynamic Segments

Search Documentation

Search across all developer documentation

segments

List dynamic Segments

GET /v1/segments
Auth required api.segments.view

Returns the org's dynamic Segments, newest-first. A Segment's membership is the live truth value of its SendQL source — there is no explicit add/remove. member_count and last_evaluated_at reflect the most recent reconcile. The response includes the source text. Create, update, delete and status changes are POST/PUT/DELETE /v1/segments and PUT /v1/segments/{id}/status under api.segments.manage.

Query parameters

limit integer optional

Page size (1–200). Default 50.

cursor string optional

Opaque cursor returned from the previous page.

Responses

Errors follow the RFC 7807 problem format — see the error reference.

200 Cursor-paginated list of Segments, newest-first application/json
data array<object> required

Each entry in data:

id string<uuid> required
name string required
key string required

Org-unique slug, stable across renames.

description string required
source string required

The SendQL predicate that defines membership.

profile_version integer required

SendQL profile version the source was compiled under.

eval_class string enum required

How membership is reconciled: incremental (re-evaluated on an attribute change), sweep (periodic full re-evaluation, for time-relative or event predicates), or both.

One of: incremental, sweep, both

status string enum required

invalid means the predicate no longer compiles (e.g. a referenced attribute was deleted); fix the predicate with PUT /v1/segments/{id} to re-activate. archived is a retired segment — deactivated but preserved.

One of: active, paused, invalid, archived

member_count integer<int64> | null required

Cached count of current members from the last reconcile, and null when the segment has never been evaluated. Null is not zero: zero means the predicate matched nobody, null means nothing has asked yet. A newly created segment is null only until its first evaluation completes — see evaluation.

evaluation string enum optional

Present only on a write response. complete means the save evaluated the membership before returning and member_count is that answer; queued means the evaluation exceeded its budget or failed, a background reconcile was enqueued, and member_count is null until it finishes. Absent on reads.

One of: complete, queued

eval_warning string optional

A standing "evaluation disrupted" warning, present when an attribute the predicate references was mutated disruptively (renamed or retyped via the management API). The segment keeps evaluating best-effort; the warning clears when the predicate is re-saved. Absent when the segment is healthy.

eval_warning_at string<date-time> optional

Time the standing eval_warning was raised; absent when none.

last_evaluated_at string<date-time> optional

Time of the last reconcile; absent until the first evaluation.

content_hash string optional

The optimistic-concurrency token over the segment's author-editable definition. Send it back as expected_content_hash on PUT /v1/segments/{id} and the edit is refused (409) rather than clobbering a concurrent one. Absent on a row that predates the column, until its next managed write recomputes it.

warnings array<string> optional

Non-blocking findings from the SendQL analyzer for the definition just saved — present only on a write response. A segment with warnings is saved, not rejected.

requires array<object> optional

Everything this definition still depends on, with each dependency's state. Present on the write responses and on the detail read (the polling surface); absent on the collection read. An empty array means nothing is outstanding — see V1Requirement.

Each entry in requires:

kind string enum required

The namespace key is looked up in. Branch on this; never parse detail.

One of: template, segment, list, topic, identity, channel, attribute, activity_property, asset

key string required

The identifier as the definition names it — a template name, a segment id or key, a from-address. Empty for a requirement about the ABSENCE of a reference: a send with no topic at all names no topic.

status string enum required

ok — resolves and is usable now. missing — nothing in this organization answers to that key. Correct the reference, or create the thing. not_ready — it exists, in a state that cannot be used yet. Usually a wait, and retrying the identical request is the move. Treating this as missing sends you hunting for a typo that is not there.

One of: ok, missing, not_ready

detail string required

The state, in the words that say which state — deploy_state=pending, member_count=null (evaluation queued). For display and logs; do not parse it.

fix string required

The call that clears this requirement, as an HTTP route where there is one and as a plain instruction where there is not (a template deploy is waited for, not called). Empty on an ok entry.

created_at string<date-time> required
updated_at string<date-time> required
pagination object required

Fields of pagination:

has_more boolean required
next_cursor string | null optional
401 Missing, malformed, or unknown API key application/problem+json
403 Key lacks the required scope or plan limit violated application/problem+json
422 A query parameter, path value or body field failed validation. The body is a validation_failed Problem. When the refusal is about a reference — a segment key, template slug, topic or attribute name the organization does not have — it additionally carries validation_code, field, line/column, missing, candidates and next_step, so a client can correct the call without a second round of guessing. See ValidationProblem. application/problem+json
429 Per-org rate limit exceeded application/problem+json
500 Unexpected server-side failure. The code is internal_error. The request_id field can be quoted to SendOps support to investigate. application/problem+json