Skip to content

Create a segment

POST
/v1/segments
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.

Media typeapplication/json
object
name
required

Display name for the segment.

string
>= 1 characters <= 120 characters
subtype

Segment subtype. Determines which additional attributes are required.

string
default: filter
Allowed values: filter matched
create_audience

When true, automatically creates a thin audience wrapper referencing this segment. Defaults: filter=true, matched=true.

boolean
filters

Filter subtype only. Flat filter array (legacy). Prefer filter_groups.

Array<object>

A single filter condition for audience discovery or job execution

object
field
required

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.

string
op
required

Comparison operator

string
Allowed values: = != < <= > >= IN NOT IN BETWEEN LIKE ARRAY_CONTAINS ARRAY_CONTAINS_ANY IS NULL IS NOT NULL
text_comparison

Optional STRING comparison mode for =, !=, IN, NOT IN, and LIKE, or ARRAY membership mode for ARRAY_CONTAINS and ARRAY_CONTAINS_ANY. Defaults to exact. Case-insensitive mode applies Unicode case folding to both the stored value and the supplied value.

string
Allowed values: exact case_insensitive
trim_whitespace

Optionally trim leading and trailing whitespace on both sides of a STRING or ARRAY comparison. Defaults to false; independent of text_comparison.

boolean
value
One of:
string
filter_groups

Filter subtype only. Grouped filter conditions.

Array<object>

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
id
required

Stable identifier (UUID or NanoID). Used to track groups across edits.

string
filters
required

One or more filter conditions. All conditions in this array are combined with AND. Provide at least one filter per group.

Array<object>

A single filter condition for audience discovery or job execution

object
field
required

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.

string
op
required

Comparison operator

string
Allowed values: = != < <= > >= IN NOT IN BETWEEN LIKE ARRAY_CONTAINS ARRAY_CONTAINS_ANY IS NULL IS NOT NULL
text_comparison

Optional STRING comparison mode for =, !=, IN, NOT IN, and LIKE, or ARRAY membership mode for ARRAY_CONTAINS and ARRAY_CONTAINS_ANY. Defaults to exact. Case-insensitive mode applies Unicode case folding to both the stored value and the supplied value.

string
Allowed values: exact case_insensitive
trim_whitespace

Optionally trim leading and trailing whitespace on both sides of a STRING or ARRAY comparison. Defaults to false; independent of text_comparison.

boolean
value
One of:
string
combinator
required

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.

string
Allowed values: AND OR
record_limit

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.

integer
>= 1 <= 1000000000
file_format

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.

string
default: csv
Allowed values: csv avro json jsonl
compression

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.

string
default: none
Allowed values: none gzip
match_level

Matched subtype only. Restricts identity resolution to the selected match levels. Defaults to all five levels.

Array<string>
Allowed values: I H D S A
spatial_mode

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.

string
default: residential
Allowed values: residential work auto
shard_count

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.

integer
default: 1 >= 1 <= 50
session_id

Optional chat session identifier used to reconnect progress for an asynchronously matched processing request.

string
visibility

Org (default) — visible to all org members. private — visible only to creator.

string
Allowed values: org private
hitl

Matched uploads only. Stage the upload for mapping analysis and confirmation instead of automatically resolving.

boolean
campaign_id

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.

string
webhook_url

Optional notification URL for matched processing completion or failure.

string format: uri
ephemeral

Filter only. Creates a temporary definition that can be explicitly saved or promoted through composition.

boolean
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
}

Segment created.

Media typeapplication/json
object
segment_id
required
string
name
required
string
subtype
required
string
Allowed values: filter matched
status
required
string
Allowed values: pending active failed archived expired
record_count
required
integer | null
expires_at
required

Date-only ISO string (90-day expiry) for a persistent segment; a full ISO datetime (short, hour-granular TTL) while ephemeral is true.

string
ephemeral

True for a scratch/auto-expiring filter-subtype segment. Absent/false reads as persistent.

boolean
created_at
required
string format: date-time
updated_at
required
string format: date-time
upload_url

Matched subtype only. 30-minute signed upload URL. Present when shard_count was 1 (the default) — absent when sharded, use upload_urls instead.

string | null
upload_urls

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.

Array<string> | null
compression

Matched subtype only. Input artifact compression.

string | null
Allowed values: none gzip
upload_expires_at

Matched subtype only. Expiry of upload_url/upload_urls.

string | null format: date-time
audience_id

If create_audience was true, the ID of the auto-created audience wrapper. Null otherwise.

string | null
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"
}

Invalid request — malformed body, missing required attribute, or failed validation. See error and message for details.

Media typeapplication/json
object
error
required

Stable machine-readable error code (e.g. INVALID_STATUS_TRANSITION, BILLING_INSUFFICIENT_BALANCE). Always present.

string
message

Human-readable explanation of the error.

string
code

Alternate machine-readable code — present on some endpoints as an alias for error for backward compatibility.

string
request_id

Opaque support/debug identifier when available.

string
next_step

Public action for correcting the request or retrying later.

string
issues
Array<object>
object
path
required

JSON path to the invalid filter field or value.

string
code
required
string
Allowed values: INVALID_FILTER_SHAPE UNKNOWN_FILTER_FIELD FIELD_NOT_FILTERABLE UNSUPPORTED_FILTER_OPERATOR UNSUPPORTED_TEXT_COMPARISON INVALID_FILTER_VALUE INVALID_ENUM_VALUE AMBIGUOUS_ENUM_VALUE
message
required
string
suggestions
Array<string>
key
additional properties
any
Examples
Examplevalidation_error
{
"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).

Media typeapplication/json
object
error
required

Stable machine-readable error code (e.g. INVALID_STATUS_TRANSITION, BILLING_INSUFFICIENT_BALANCE). Always present.

string
message

Human-readable explanation of the error.

string
code

Alternate machine-readable code — present on some endpoints as an alias for error for backward compatibility.

string
request_id

Opaque support/debug identifier when available.

string
next_step

Public action for correcting the request or retrying later.

string
issues
Array<object>
object
path
required

JSON path to the invalid filter field or value.

string
code
required
string
Allowed values: INVALID_FILTER_SHAPE UNKNOWN_FILTER_FIELD FIELD_NOT_FILTERABLE UNSUPPORTED_FILTER_OPERATOR UNSUPPORTED_TEXT_COMPARISON INVALID_FILTER_VALUE INVALID_ENUM_VALUE AMBIGUOUS_ENUM_VALUE
message
required
string
suggestions
Array<string>
key
additional properties
any
Examples
{
"error": "Unauthorized: Missing or invalid Authorization header"
}

Token is valid but lacks the required scope for this endpoint. Check the endpoint description for the required scope (discovery, purchase, or account).

Media typeapplication/json
object
error
required

Stable machine-readable error code (e.g. INVALID_STATUS_TRANSITION, BILLING_INSUFFICIENT_BALANCE). Always present.

string
message

Human-readable explanation of the error.

string
code

Alternate machine-readable code — present on some endpoints as an alias for error for backward compatibility.

string
request_id

Opaque support/debug identifier when available.

string
next_step

Public action for correcting the request or retrying later.

string
issues
Array<object>
object
path
required

JSON path to the invalid filter field or value.

string
code
required
string
Allowed values: INVALID_FILTER_SHAPE UNKNOWN_FILTER_FIELD FIELD_NOT_FILTERABLE UNSUPPORTED_FILTER_OPERATOR UNSUPPORTED_TEXT_COMPARISON INVALID_FILTER_VALUE INVALID_ENUM_VALUE AMBIGUOUS_ENUM_VALUE
message
required
string
suggestions
Array<string>
key
additional properties
any
Examples
Examplemissing_scope
{
"error": "SCOPE_REQUIRED",
"message": "This endpoint requires the creator scope."
}

An upstream billing provider rejected or could not complete the operation.

Media typeapplication/json
object
error
required

Stable machine-readable error code (e.g. INVALID_STATUS_TRANSITION, BILLING_INSUFFICIENT_BALANCE). Always present.

string
message

Human-readable explanation of the error.

string
code

Alternate machine-readable code — present on some endpoints as an alias for error for backward compatibility.

string
request_id

Opaque support/debug identifier when available.

string
next_step

Public action for correcting the request or retrying later.

string
issues
Array<object>
object
path
required

JSON path to the invalid filter field or value.

string
code
required
string
Allowed values: INVALID_FILTER_SHAPE UNKNOWN_FILTER_FIELD FIELD_NOT_FILTERABLE UNSUPPORTED_FILTER_OPERATOR UNSUPPORTED_TEXT_COMPARISON INVALID_FILTER_VALUE INVALID_ENUM_VALUE AMBIGUOUS_ENUM_VALUE
message
required
string
suggestions
Array<string>
key
additional properties
any
Example
{
"issues": [
{
"code": "INVALID_FILTER_SHAPE"
}
]
}