Skip to content

Bulk create segments

POST
/v1/segments/bulk-create
curl --request POST \
--url https://dev-api.infiniteaudience.ai/v1/segments/bulk-create \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "segments": [ { "name": "example", "subtype": "filter", "filters": [ { "field": "example", "op": "=", "value": [ "example" ] } ], "filter_groups": [ { "id": "example", "filters": [ { "field": "example", "op": "=", "value": [ "example" ] } ], "combinator": "AND" } ], "count_snapshot": 1, "create_audience": false } ] }'

Create up to 25 filter-subtype segments in one request. Each segment is created independently (own versions/1 snapshot); failures are reported per item in errors and do not roll back successful items. Returns 201 when at least one segment was created, 400 (same body shape) when every item failed. Use POST /v1/segments individually for matched/similarity/propensity segments. Requires ‘purchase’ scope.

Each item’s filters/filter_groups are validated against the live Field Catalog before it’s created — an unknown field, a disallowed operator, or an invalid enum value fails that item only, reported in errors (same as any other per-item failure). If the Field Catalog itself is temporarily unreachable, the entire request fails with 502 FILTER_CATALOG_UNAVAILABLE rather than creating some segments unvalidated.

Media typeapplication/json
object
segments
required
Array<object>
>= 1 items <= 25 items
object
name
required

Display name for the segment.

string
>= 1 characters <= 120 characters
subtype

Only ‘filter’ is supported by bulk-create — any other value fails per-item with an entry in errors.

string
default: filter
Allowed values: filter matched similarity propensity
filters

Legacy flat filter list.

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 groups defining the segment criteria.

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
count_snapshot

Optional known record count to seed the segment with.

number
create_audience

When true, auto-creates a thin audience wrapper for this segment (returned as audience_id on the created segment).

boolean

At least one segment created. Check errors for partial failures.

Media typeapplication/json

Result of POST /v1/segments/bulk-create. Returned with 201 when at least one segment was created, and with 400 (same shape) when every item failed.

object
created
required

Number of segments successfully created.

integer
failed
required

Number of input items that could not be created.

integer
segments
required

Full segment documents for each successfully created segment.

Array
object
segment_id
required

Unique segment identifier

string
name
required

Display name of the segment

string
subtype
required

Segment subtype. Determines which additional attributes are present. filter = saved filter criteria; matched = customer list upload with identity resolution; similarity = lookalike model; propensity = ML scoring model.

string
Allowed values: filter matched similarity propensity
status
required

Pending = computation in progress (matched/similarity/propensity during creation); active = fully ready; failed = workflow or enrichment error (see error_message); archived = hidden from the default segment catalog and new audience compositions, but otherwise fully functional — audiences that already reference an archived segment are unaffected, and it can be restored with PATCH status:active at any time. Distinct from DELETE, which is not reversible and does change referencing audiences’ composition; expired = past 90-day TTL.

string
Allowed values: pending active failed archived expired
record_count
required

Total matched/qualified records. Null while pending or if count has not been run.

integer | null
expires_at
required

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

string
ephemeral
required

True for a scratch/free/auto-expiring filter-subtype segment. Absent/false reads as persistent. Promote to persistent via PATCH /v1/segments/{id} {ephemeral: false}, or implicitly by composing it into an audience.

boolean
promoted_at

ISO datetime the segment was promoted from ephemeral to persistent. Absent until promotion happens.

string
promoted_via

How the segment was promoted to persistent — explicit_save (a direct ephemeral: false PATCH) or composition (referenced by an audience create/update). Absent until promotion happens.

string
Allowed values: explicit_save composition
visibility

Org (default) — visible to all members of the org. private — visible only to the creating user.

string
Allowed values: org private
current_version

Filter subtype only. Current version counter.

integer | null
filters

Filter subtype only. Legacy flat filter array.

Array<object> | null

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> | null

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.

string | null
Allowed values: csv avro json jsonl
compression

Matched subtype only. Input artifact compression, normalized to none by current handlers.

string | null
Allowed values: none gzip
shard_count

Matched subtype only. Number of same-format input objects, normalized to 1 for unsharded uploads.

integer | null
>= 1 <= 50
column_mappings

Matched subtype only. Source column name → standard identity attribute mappings. Populated after the analyze-and-store workflow gate runs.

object | null
mapping_confirmed

Matched subtype only. True once column mappings have been confirmed.

boolean | null
input_record_count

Matched subtype only. Number of rows in the original upload.

integer | null
match_count

Matched subtype only. Rows that resolved to a known identity after enrichment.

integer | null
match_rate

Matched subtype only. match_count / input_record_count.

number | null
upload_url

Matched subtype only. 30-min presigned GCS PUT URL. Present on create and refresh responses only, 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 on create and refresh responses only when shard_count > 1 was requested — upload_url is absent. Every CSV shard must include the same header row.

Array<string> | null
upload_expires_at

Matched subtype only. Expiry of upload_url/upload_urls.

string | null format: date-time
error_message

Present when status is failed. Describes the reason for failure.

string | null
source_data_segment_id

Matched duplicates only. ID of the segment that owns the underlying match-result data (the root data owner). Set when the segment was created via POST /v1/segments/{id}/duplicate; propagates unchanged through duplicate-of-duplicate chains. Null on segments that own their own data.

string | null
seed_description

Similarity subtype only. Natural language ICP persona description used as seed.

string | null
seed_segment_id

Similarity subtype only. ID of an existing segment used as the lookalike seed.

string | null
generation_metadata_id

Similarity/propensity subtype. References the lookalike run or propensity model ID.

string | null
workflow_run_id

Similarity and propensity subtypes. The workflow run ID. Poll GET /v1/workflows/{workflow_run_id} to monitor progress.

string | null
positive_class_segment_id

Propensity subtype only. ID of the segment whose members are the positive training class.

string | null
parent_segment_id

ID of the segment this was duplicated or derived from, if applicable.

string | null
derived_from

Root ancestor segment ID. Stable across duplicate-of-duplicate chains — always points at the original segment, never an intermediate duplicate.

string | null
parent_segment_version

Version of the parent segment pinned at duplicate time (current_version for filter parents; snapshot_version otherwise). Null on segments that are not duplicates.

integer | null
origin_campaign_id

ID of the campaign whose chat session first produced this segment. Metadata only — does not restrict the segment to that campaign. Present only when the segment was created via POST /v1/segments with a campaign_id.

string | null
usage

Cross-campaign usage stats. Only present on GET /v1/segments/{id} — not included on list responses. Useful for understanding impact before archiving.

object
audience_count

Number of active audiences that reference this segment.

integer
campaign_count

Number of distinct campaigns those audiences belong to.

integer
created_at
required
string format: date-time
updated_at
required
string format: date-time
audience_id

Auto-created audience wrapper ID. Present only when the input item set create_audience: true.

string
errors
required

Per-item failures. Empty when all items succeeded.

Array<object>
object
index
required

Zero-based position of the failed item in the input segments array.

integer
name
required

The name from the failed input item.

string
error
required

Human-readable reason the segment could not be created.

string
Example
{
"segments": [
{
"subtype": "filter",
"status": "pending",
"promoted_via": "explicit_save",
"visibility": "org",
"filters": [
{
"op": "="
}
],
"filter_groups": [
{
"filters": [
{
"op": "="
}
],
"combinator": "AND"
}
],
"file_format": "csv",
"compression": "none"
}
]
}

Every input item failed (created: 0) — same body shape as 201 with per-item reasons in errors — or the request body failed validation (standard error shape).

Media typeapplication/json
One of:

Result of POST /v1/segments/bulk-create. Returned with 201 when at least one segment was created, and with 400 (same shape) when every item failed.

object
created
required

Number of segments successfully created.

integer
failed
required

Number of input items that could not be created.

integer
segments
required

Full segment documents for each successfully created segment.

Array
object
segment_id
required

Unique segment identifier

string
name
required

Display name of the segment

string
subtype
required

Segment subtype. Determines which additional attributes are present. filter = saved filter criteria; matched = customer list upload with identity resolution; similarity = lookalike model; propensity = ML scoring model.

string
Allowed values: filter matched similarity propensity
status
required

Pending = computation in progress (matched/similarity/propensity during creation); active = fully ready; failed = workflow or enrichment error (see error_message); archived = hidden from the default segment catalog and new audience compositions, but otherwise fully functional — audiences that already reference an archived segment are unaffected, and it can be restored with PATCH status:active at any time. Distinct from DELETE, which is not reversible and does change referencing audiences’ composition; expired = past 90-day TTL.

string
Allowed values: pending active failed archived expired
record_count
required

Total matched/qualified records. Null while pending or if count has not been run.

integer | null
expires_at
required

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

string
ephemeral
required

True for a scratch/free/auto-expiring filter-subtype segment. Absent/false reads as persistent. Promote to persistent via PATCH /v1/segments/{id} {ephemeral: false}, or implicitly by composing it into an audience.

boolean
promoted_at

ISO datetime the segment was promoted from ephemeral to persistent. Absent until promotion happens.

string
promoted_via

How the segment was promoted to persistent — explicit_save (a direct ephemeral: false PATCH) or composition (referenced by an audience create/update). Absent until promotion happens.

string
Allowed values: explicit_save composition
visibility

Org (default) — visible to all members of the org. private — visible only to the creating user.

string
Allowed values: org private
current_version

Filter subtype only. Current version counter.

integer | null
filters

Filter subtype only. Legacy flat filter array.

Array<object> | null

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> | null

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.

string | null
Allowed values: csv avro json jsonl
compression

Matched subtype only. Input artifact compression, normalized to none by current handlers.

string | null
Allowed values: none gzip
shard_count

Matched subtype only. Number of same-format input objects, normalized to 1 for unsharded uploads.

integer | null
>= 1 <= 50
column_mappings

Matched subtype only. Source column name → standard identity attribute mappings. Populated after the analyze-and-store workflow gate runs.

object | null
mapping_confirmed

Matched subtype only. True once column mappings have been confirmed.

boolean | null
input_record_count

Matched subtype only. Number of rows in the original upload.

integer | null
match_count

Matched subtype only. Rows that resolved to a known identity after enrichment.

integer | null
match_rate

Matched subtype only. match_count / input_record_count.

number | null
upload_url

Matched subtype only. 30-min presigned GCS PUT URL. Present on create and refresh responses only, 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 on create and refresh responses only when shard_count > 1 was requested — upload_url is absent. Every CSV shard must include the same header row.

Array<string> | null
upload_expires_at

Matched subtype only. Expiry of upload_url/upload_urls.

string | null format: date-time
error_message

Present when status is failed. Describes the reason for failure.

string | null
source_data_segment_id

Matched duplicates only. ID of the segment that owns the underlying match-result data (the root data owner). Set when the segment was created via POST /v1/segments/{id}/duplicate; propagates unchanged through duplicate-of-duplicate chains. Null on segments that own their own data.

string | null
seed_description

Similarity subtype only. Natural language ICP persona description used as seed.

string | null
seed_segment_id

Similarity subtype only. ID of an existing segment used as the lookalike seed.

string | null
generation_metadata_id

Similarity/propensity subtype. References the lookalike run or propensity model ID.

string | null
workflow_run_id

Similarity and propensity subtypes. The workflow run ID. Poll GET /v1/workflows/{workflow_run_id} to monitor progress.

string | null
positive_class_segment_id

Propensity subtype only. ID of the segment whose members are the positive training class.

string | null
parent_segment_id

ID of the segment this was duplicated or derived from, if applicable.

string | null
derived_from

Root ancestor segment ID. Stable across duplicate-of-duplicate chains — always points at the original segment, never an intermediate duplicate.

string | null
parent_segment_version

Version of the parent segment pinned at duplicate time (current_version for filter parents; snapshot_version otherwise). Null on segments that are not duplicates.

integer | null
origin_campaign_id

ID of the campaign whose chat session first produced this segment. Metadata only — does not restrict the segment to that campaign. Present only when the segment was created via POST /v1/segments with a campaign_id.

string | null
usage

Cross-campaign usage stats. Only present on GET /v1/segments/{id} — not included on list responses. Useful for understanding impact before archiving.

object
audience_count

Number of active audiences that reference this segment.

integer
campaign_count

Number of distinct campaigns those audiences belong to.

integer
created_at
required
string format: date-time
updated_at
required
string format: date-time
audience_id

Auto-created audience wrapper ID. Present only when the input item set create_audience: true.

string
errors
required

Per-item failures. Empty when all items succeeded.

Array<object>
object
index
required

Zero-based position of the failed item in the input segments array.

integer
name
required

The name from the failed input item.

string
error
required

Human-readable reason the segment could not be created.

string
Example
{
"segments": [
{
"subtype": "filter",
"status": "pending",
"promoted_via": "explicit_save",
"visibility": "org",
"filters": [
{
"op": "="
}
],
"filter_groups": [
{
"filters": [
{
"op": "="
}
],
"combinator": "AND"
}
],
"file_format": "csv",
"compression": "none"
}
]
}

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 — no items were validated or created (code FILTER_CATALOG_UNAVAILABLE).