Skip to content

Refresh a segment against the latest data

POST
/v1/segments/{id}/refresh
curl --request POST \
--url https://dev-api.infiniteaudience.ai/v1/segments/example/refresh \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "hitl": false, "force": false, "shard_count": 1, "compression": "none" }'

Re-derives a single segment from the latest identity graph data. This is the segment-native counterpart of POST /v1/audiences/{id}/refresh — it updates ONLY this segment. Referencing audiences are never touched; their IDs are returned in affected_audiences so you can recount or refresh them as needed (use the audience-level refresh for a whole-composition refresh).

Per-subtype behavior:

  • filter — Synchronous. Bumps current_version and appends a version history entry (sharing the same counter as PATCH filter edits), clears record_count, resets the 90-day TTL, and returns status: active. If nothing would change (already active, count already null, TTL already fresh today) and force is not set, the call is a no-op returning the current segment with refreshed: false.

  • matched — Returns a fresh presigned upload_url (24 h expiry) — or upload_urls (an array, one per shard) when shard_count > 1, in which case upload_url is absent. The new upload may be raw or gzip. With hitl unset/false (default): targets the segment’s existing upload path directly, resets mapping state (column_mappings, mapping_confirmed) and counts, and returns status: pending — re-upload your identity list and identity resolution runs automatically once every declared shard has been uploaded. With hitl: true: the URL(s) instead target a staging location and the segment’s status/mapping state is left untouched until you confirm — see the hitl field description below. Matched duplicates that reference another segment’s data (source_data_segment_id set) are rejected with 409 SHARED_SOURCE_DATA — refresh the source segment instead.

  • similarity — Re-launches the lookalike generation workflow with the stored seed parameters. Returns status: pending; the segment’s workflow_run_id is updated to the new run. Poll GET /v1/workflows/{workflow_run_id} until completion.

  • propensity — Re-launches the scoring model workflow using the stored positive_class_segment_id. Returns status: pending plus the new workflow_run_id. 422 MISSING_POSITIVE_CLASS_ID for legacy segments that predate positive_class_segment_id storage — those must be recreated.

Archived segments are rejected with 409 SEGMENT_ARCHIVED — restore first via PATCH /v1/segments/{id} with status: active. Requires ‘purchase’ scope.

id
required
string

Segment document ID.

Media typeapplication/json
object
hitl

Requires an explicit confirmation step before the automated pipeline proceeds. (similarity / propensity) the re-launched workflow pauses at a human-in-the-loop review gate — use POST /v1/workflows/{workflow_run_id}/resume to submit answers and resume. (matched) the re-upload 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). Ignored for filter.

boolean
force

(filter only) Bump the version and invalidate the count even when the segment already looks fresh (skips the no-op short-circuit).

boolean
shard_count

(matched only) Set > 1 for same-format shards. Every CSV shard must include the same header, and all shards must share schema and compression. Returns upload_urls instead of upload_url.

integer
default: 1 >= 1 <= 50
compression

(matched only) Compression for this new upload. It does not inherit the previous upload’s setting. Send raw gzip bytes without Content-Encoding. gzip is not supported for avro-format segments — rejected with 400 UNSUPPORTED_INPUT_COMPRESSION.

string
default: none
Allowed values: none gzip

Segment refreshed (or no-op — inspect refreshed). Shape varies by subtype: matched adds upload_url/upload_expires_at (or upload_urls when shard_count > 1); similarity/propensity carry the new workflow_run_id. See next_step for a machine-readable hint.

Media typeapplication/json

Response of POST /v1/segments/{id}/refresh — the full updated segment document plus refresh metadata. For the matched subtype the response additionally carries upload_url / upload_expires_at (24 h presign) — or upload_urls (an array, one per shard) when shard_count > 1 was requested, in which case upload_url is absent; for similarity/propensity the segment’s workflow_run_id points at the newly launched run.

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

True when the segment was re-derived; false when the filter no-op path returned the current object unchanged (already active, count already null, TTL already fresh — pass force: true to bump anyway).

boolean
affected_audiences
required

IDs of non-deleted audiences that reference this segment. They are NOT auto-refreshed — their status, record_count, and expiry may now be stale. Recount or refresh them as needed, or use POST /v1/audiences/{id}/refresh for a whole-composition refresh.

Array<string>
next_step
required

Human-readable hint for the calling agent on how to proceed (recount, upload to upload_url, or wait for the workflow).

string
Example
{
"segment_id": "seg_abc123",
"name": "West Coast Adults 25-44",
"subtype": "filter",
"status": "active",
"record_count": null,
"expires_at": "2026-10-03",
"ephemeral": false,
"visibility": "org",
"current_version": 4,
"filters": [],
"filter_groups": [
{
"id": "g1",
"filters": [
{
"field": "state",
"op": "IN",
"value": [
"CA",
"OR",
"WA"
]
}
],
"combinator": "AND"
}
],
"created_at": "2026-04-01T12:00:00Z",
"updated_at": "2026-07-05T18:00:00Z",
"refreshed": true,
"affected_audiences": [
"aud_123",
"aud_456"
],
"next_step": "Call POST /v1/segments/{id}/count (recount) to refresh the record count. Referencing audiences are NOT auto-refreshed — recount or refresh the audiences listed in affected_audiences as needed."
}

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."
}

Resource not found or not accessible to the calling org.

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
Examplenot_found
{
"error": "Audience not found"
}

The segment cannot be refreshed. SEGMENT_ARCHIVED — the segment is archived; restore it first (PATCH status: active). SHARED_SOURCE_DATA — matched duplicate that references another segment’s match data; refreshing it here would overwrite the source segment’s upload. The message names the source segment id to refresh instead.

Media typeapplication/json
object
error
required
string
code
required
string
Allowed values: SEGMENT_ARCHIVED SHARED_SOURCE_DATA
message
required
string
Example
{
"error": "Conflict",
"code": "SHARED_SOURCE_DATA",
"message": "This matched segment is a duplicate that references segment 'seg_root1' for its match data — refreshing it here would overwrite that source segment's upload. Refresh the source segment instead: POST /v1/segments/seg_root1/refresh."
}

MISSING_POSITIVE_CLASS_ID — (propensity only) the segment predates positive_class_segment_id storage and cannot be auto-refreshed; delete and recreate it.

Media typeapplication/json
object
error
required
string
code
required
string
Allowed values: MISSING_POSITIVE_CLASS_ID
message
required
string
Example
{
"code": "MISSING_POSITIVE_CLASS_ID"
}