Skip to content

Create a segment

POST
/v1/segments
curl --request POST \
--url https://dev-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 }'

Creates a typed cohort definition (segment). The subtype attribute controls which additional parameters are required and what the platform does next.

Subtypes:

  • filter (default) — Saves a named filter expression. Returns status: active immediately. Use filters/filter_groups for the criteria. Pass create_audience: true to also create a thin audience wrapper referencing this segment. Default: false — the segment is saved for later composition into an audience once iterative refinement is complete.

  • matched — Upload your own customer list for identity resolution. Returns status: pending + upload_url (30-min presigned GCS PUT URL) — or upload_urls (an array, one per shard) when shard_count > 1, in which case upload_url is absent. Input may be raw or gzip. With hitl unset/false (default): upload your file(s) and the platform runs column mapping and identity resolution automatically once every declared shard has been uploaded, transitioning to status: active when complete — no further calls required. With hitl: true: the upload is staged instead of resolving automatically — see the hitl field description below for the full preview/confirm/cancel sequence. When create_audience: true (default for matched), a thin audience wrapper is also created automatically.

  • similarity — Lookalike modelling. Provide seed_description (natural language ICP persona) or seed_segment_id (an existing segment) — not both — to launch a new workflow. Returns status: pending + workflow_run_id. Alternatively, provide generation_metadata_id (an existing icp_id) with no seed fields to attach that already-completed ICP run directly — no workflow is launched, status: active immediately. Default create_audience: false.

  • propensity — ML propensity scoring. Provide positive_class_segment_id (an existing segment whose members are the positive training class) to launch a new workflow. Returns status: pending + workflow_run_id. Alternatively, provide generation_metadata_id (an existing model_id) with no positive_class_segment_id to attach that already-completed model run directly — no workflow is launched, status: active immediately. Default create_audience: false.

Poll GET /v1/segments/{id} for status, or configure a webhook to receive segment.ready / segment.failed events. Requires ‘purchase’ scope.

For filter subtype: filters/filter_groups are validated against the live Field Catalog before the segment is created — an unknown field, a disallowed operator for that field, or an invalid enum value returns 400 INVALID_FILTER. If the Field Catalog itself is temporarily unreachable, returns 502 FILTER_CATALOG_UNAVAILABLE rather than creating an unvalidated segment.

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 similarity propensity
create_audience

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

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

The canonical attribute name (e.g. ‘age’, ‘state’)

string
op
required

Comparison operator

string
Allowed values: = != < <= > >= IN NOT IN BETWEEN LIKE ARRAY_CONTAINS ARRAY_CONTAINS_ANY IS NULL IS NOT NULL
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

The canonical attribute name (e.g. ‘age’, ‘state’)

string
op
required

Comparison operator

string
Allowed values: = != < <= > >= IN NOT IN BETWEEN LIKE ARRAY_CONTAINS ARRAY_CONTAINS_ANY IS NULL IS NOT NULL
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
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
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
seed_description

Similarity subtype only. Natural language description of the target ICP persona. Provide either seed_description or seed_segment_id, not both.

string
seed_segment_id

Similarity subtype only. ID of an existing segment to use as the lookalike seed. Provide either seed_description or seed_segment_id, not both.

string
positive_class_segment_id

Propensity subtype only. ID of an existing segment whose members represent the positive training class for ML model training.

string
generation_metadata_id

Similarity subtype: an existing icp_id. propensity subtype: an existing model_id. When provided without seed_description/seed_segment_id (similarity) or positive_class_segment_id (propensity), attaches that already-completed run to a new segment instead of launching a new workflow — status: active immediately, no workflow_run_id.

string
visibility

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

string
Allowed values: org private
hitl

Requires an explicit confirmation step before the automated pipeline proceeds. For similarity/propensity, the workflow pauses at a human-in-the-loop review gate. For matched, the uploaded file is staged instead of landing at the path that triggers automatic identity resolution — call POST /v1/match/{id}/analyze to preview column mappings against the staged file, then POST /v1/segments/{id}/mappings to confirm (moves the file into place and starts resolution) or POST /v1/segments/{id}/mappings/cancel to abort (the segment is left completely untouched). Defaults to false — omit for the existing automatic-resolution behavior.

boolean
campaign_id

Optional. If provided and create_audience is true, the created audience is automatically linked to this campaign.

string
webhook_url

Optional HTTPS URL to receive segment.ready or segment.failed events. Overrides the org-level webhook URL for this request only.

string format: uri
ephemeral

Filter subtype only. When true, creates a scratch/free/auto-expiring segment with a short, hour-granular TTL instead of the standard 90-day expiry. Excluded from GET /v1/segments by default (see include_ephemeral there). Promote it to persistent later via PATCH /v1/segments/{id} {ephemeral: false}, or implicitly by composing it into an audience. Defaults to false (persistent, today’s behavior).

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 similarity propensity
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
required

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-min presigned GCS PUT URL. Present when shard_count was 1 (the default) — absent when sharded, use upload_urls instead.

string | null
upload_urls

Matched subtype only. N presigned GCS PUT 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
workflow_run_id

Similarity/propensity subtypes. Workflow run ID for progress monitoring.

string | null
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",
"ephemeral": false,
"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
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
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
key
additional properties
any
Examples
Examplemissing_scope
{
"error": "SCOPE_REQUIRED",
"message": "This endpoint requires the purchase scope."
}

Field Catalog temporarily unreachable — filters could not be validated (code FILTER_CATALOG_UNAVAILABLE).