Create a segment
const url = 'https://api.infiniteaudience.ai/v1/segments';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"name":"West Coast Adults 25-44","subtype":"filter","filter_groups":[{"id":"g1","filters":[{"field":"state","op":"IN","value":["CA","OR","WA"]}],"combinator":"AND"}],"create_audience":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.infiniteaudience.ai/v1/segments \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "name": "West Coast Adults 25-44", "subtype": "filter", "filter_groups": [ { "id": "g1", "filters": [ { "field": "state", "op": "IN", "value": [ "CA", "OR", "WA" ] } ], "combinator": "AND" } ], "create_audience": true }'Create a filter definition (synchronous active result) or matched identity-file upload (pending until processing completes). Requires ‘creator’ scope. Custom membership is published through the internal Data-team tool. Automated generation is currently unavailable; see POST /v1/segments/generate-custom. Legacy generation fields are rejected with 400 LEGACY_GENERATION_RETIRED before unknown-field stripping. Direct membership/table inputs return 400 CUSTOM_PUBLICATION_INTERNAL_ONLY. Filter inputs are checked against the governed audience field catalog. Record limits require bounded geography. create_audience defaults to false for filter and true for matched. Matched inputs support csv/json/jsonl/avro, same-format shards and gzip for csv/json/jsonl only. hitl=true stages uploads for mapping review; otherwise mapping/resolution proceeds automatically after all shards arrive.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
Display name for the segment.
Segment subtype. Determines which additional attributes are required.
When true, automatically creates a thin audience wrapper referencing this segment. Defaults: filter=true, matched=true.
Filter subtype only. Flat filter array (legacy). Prefer filter_groups.
A single filter condition for audience discovery or job execution
object
Canonical catalog field_name (e.g. age or state). ZIP5 also accepts zip, zip_code, or postal_code as input aliases; saved responses use zip5.
Comparison operator
Optional STRING comparison mode for =, !=, IN, NOT IN, and LIKE, or ARRAY
Optionally trim leading and trailing whitespace on both sides of a STRING or ARRAY
Filter subtype only. Grouped filter conditions.
A group of Filter conditions. All filters within a single group are always ANDed together — there is no per-group intra-operator. The combinator attribute is an inter-group operator: it controls how this group is joined to the immediately preceding group in the array. The combinator on the first group (index 0) is always ignored.
Example — (city = "NYC" AND state = "NY") OR (state = "CA"):
{ "id": "g1", "filters": [{"field":"city","op":"=","value":"NYC"},
{"field":"state","op":"=","value":"NY"}],
"combinator": "AND" },
{ "id": "g2", "filters": [{"field":"state","op":"=","value":"CA"}],
"combinator": "OR" }
] ```
Group g1's `combinator` is irrelevant (it is the first group). Group g2's `combinator: "OR"` means the result is `(g1) OR (g2)`.
object
Stable identifier (UUID or NanoID). Used to track groups across edits.
One or more filter conditions. All conditions in this array are combined with AND. Provide at least one filter per group.
A single filter condition for audience discovery or job execution
object
Canonical catalog field_name (e.g. age or state). ZIP5 also accepts zip, zip_code, or postal_code as input aliases; saved responses use zip5.
Comparison operator
Optional STRING comparison mode for =, !=, IN, NOT IN, and LIKE, or ARRAY
Optionally trim leading and trailing whitespace on both sides of a STRING or ARRAY
Inter-group operator. Joins this group to the previous group in the array. AND narrows the result; OR broadens it. Ignored on the first group (index 0) — that group has no predecessor to join.
Filter subtype only. Caps the segment at this many people. Requires a State, City, or ZIP Code filter that narrows every OR branch to at most 100 ZIP3 regions; otherwise returns 400 CAP_GEOGRAPHY_REQUIRED. Members are a stable, segment-seeded pseudo-random selection of the people matching the filters (the same people on every count, audience composition, quote, and delivery for a given data release). Audiences and deliveries built from the segment inherit the cap — there is no separate audience- or delivery-level cap. A delivery may export fewer rows than the cap after privacy suppression. When count_snapshot is supplied it is clamped to the cap.
Matched subtype only. Input file format. csv (default) treats every column as a single scalar value — multi-value/array attributes are not supported in csv. avro, json, and jsonl support native array columns for attributes that require them — json and jsonl are both parsed as newline-delimited JSON (one record object per line), not a single top-level JSON array.
Matched subtype only. gzip means the complete underlying format file is a gzip stream. Upload raw gzip bytes using the underlying format’s Content-Type and no Content-Encoding. gzip is not supported with file_format=avro (avro is already internally compressed) — rejected with 400 UNSUPPORTED_INPUT_COMPRESSION.
Matched subtype only. Restricts identity resolution to the selected match levels. Defaults to all five levels.
Matched subtype only. Phase 3 spatial trade-area profile; residential is the default, work selects workplace-oriented matching, and auto dynamically selects commuter expansion based on whether the input address is commercial.
Matched subtype only. Set > 1 for same-format shards. Every CSV shard must include the same header row, and all shards must share schema and compression. Returns upload_urls instead of upload_url.
Optional chat session identifier used to reconnect progress for an asynchronously matched processing request.
Org (default) — visible to all org members. private — visible only to creator.
Matched uploads only. Stage the upload for mapping analysis and confirmation instead of automatically resolving.
Campaign this segment is built for. Recorded as the segment’s origin_campaign_id and, with create_audience, links the wrapper audience to it. Optional — when omitted, a delegated chat/A2A session’s campaign is used, otherwise the segment has no campaign. An unknown id is a 400 INVALID_CAMPAIGN_ID and nothing is created.
Optional notification URL for matched processing completion or failure.
Filter only. Creates a temporary definition that can be explicitly saved or promoted through composition.
Examples
Filter segment
{ "name": "West Coast Adults 25-44", "subtype": "filter", "filter_groups": [ { "id": "g1", "filters": [ { "field": "state", "op": "IN", "value": [ "CA", "OR", "WA" ] } ], "combinator": "AND" } ], "create_audience": true}Matched segment (customer CSV upload)
{ "name": "Q3 CRM Upload", "subtype": "matched", "file_format": "csv", "create_audience": true}Responses
Section titled “Responses”Segment created.
object
Date-only ISO string (90-day expiry) for a persistent segment; a full ISO datetime (short, hour-granular TTL) while ephemeral is true.
True for a scratch/auto-expiring filter-subtype segment. Absent/false reads as persistent.
Matched subtype only. 30-minute signed upload URL. Present when shard_count was 1 (the default) — absent when sharded, use upload_urls instead.
Matched subtype only. N signed upload URLs (index-ordered). Present only when shard_count > 1 was requested — upload_url is absent. Every CSV shard must include the same header row.
Matched subtype only. Input artifact compression.
Matched subtype only. Expiry of upload_url/upload_urls.
If create_audience was true, the ID of the auto-created audience wrapper. Null otherwise.
Examples
Filter segment created
{ "segment_id": "seg_abc123", "name": "West Coast Adults 25-44", "subtype": "filter", "status": "active", "record_count": null, "expires_at": "2026-09-27", "audience_id": "aud_abc123", "created_at": "2026-06-22T18:00:00Z", "updated_at": "2026-06-22T18:00:00Z"}Matched segment created — ready for file upload
{ "segment_id": "seg_m789", "name": "Q3 CRM Upload", "subtype": "matched", "status": "pending", "record_count": null, "expires_at": "2026-09-27", "upload_url": "https://storage.googleapis.com/cf-uploads/enrichment-uploads/org_x/seg_m789/input.csv?X-Goog-Signature=...", "upload_expires_at": "2026-06-22T19:30:00.000Z", "audience_id": "aud_m789", "created_at": "2026-06-22T18:00:00Z", "updated_at": "2026-06-22T18:00:00Z"}Invalid request — malformed body, missing required attribute, or failed validation. See error and message for details.
object
Stable machine-readable error code (e.g. INVALID_STATUS_TRANSITION, BILLING_INSUFFICIENT_BALANCE). Always present.
Human-readable explanation of the error.
Alternate machine-readable code — present on some endpoints as an alias for error for backward compatibility.
Opaque support/debug identifier when available.
Public action for correcting the request or retrying later.
object
JSON path to the invalid filter field or value.
Examples
{ "error": "Bad Request", "code": "MISSING_SEGMENTS", "message": "segment_ids is required for filter audiences."}Missing or invalid Bearer token. Obtain one via POST /v1/auth/token. When a token was supplied but rejected, code distinguishes TOKEN_EXPIRED (the token’s lifetime has passed — request a new one via POST /v1/auth/token and retry) from TOKEN_INVALID (malformed or revoked — re-authenticate).
object
Stable machine-readable error code (e.g. INVALID_STATUS_TRANSITION, BILLING_INSUFFICIENT_BALANCE). Always present.
Human-readable explanation of the error.
Alternate machine-readable code — present on some endpoints as an alias for error for backward compatibility.
Opaque support/debug identifier when available.
Public action for correcting the request or retrying later.
object
JSON path to the invalid filter field or value.
Examples
{ "error": "Unauthorized: Missing or invalid Authorization header"}{ "error": "Unauthorized", "code": "TOKEN_EXPIRED", "message": "Your session has expired. Please sign in again."}Token is valid but lacks the required scope for this endpoint. Check the endpoint description for the required scope (discovery, purchase, or account).
object
Stable machine-readable error code (e.g. INVALID_STATUS_TRANSITION, BILLING_INSUFFICIENT_BALANCE). Always present.
Human-readable explanation of the error.
Alternate machine-readable code — present on some endpoints as an alias for error for backward compatibility.
Opaque support/debug identifier when available.
Public action for correcting the request or retrying later.
object
JSON path to the invalid filter field or value.
Examples
{ "error": "SCOPE_REQUIRED", "message": "This endpoint requires the creator scope."}An upstream billing provider rejected or could not complete the operation.
object
Stable machine-readable error code (e.g. INVALID_STATUS_TRANSITION, BILLING_INSUFFICIENT_BALANCE). Always present.
Human-readable explanation of the error.
Alternate machine-readable code — present on some endpoints as an alias for error for backward compatibility.
Opaque support/debug identifier when available.
Public action for correcting the request or retrying later.
object
JSON path to the invalid filter field or value.
Example
{ "issues": [ { "code": "INVALID_FILTER_SHAPE" } ]}