Bulk update audiences
const url = 'https://dev-api.infiniteaudience.ai/v1/audiences/bulk';const options = { method: 'PATCH', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"audience_ids":["example"],"set_logic":"union","add_segment_id":"example","remove_segment_id":"example","status":"archived"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request PATCH \ --url https://dev-api.infiniteaudience.ai/v1/audiences/bulk \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "audience_ids": [ "example" ], "set_logic": "union", "add_segment_id": "example", "remove_segment_id": "example", "status": "archived" }'Apply set_logic, segment add/remove, or status changes to multiple audiences in a single request. Audiences are subtype-agnostic composition wrappers, so this applies uniformly regardless of which segment subtypes (filter, matched, similarity, propensity) they compose. Fail-closed ownership validation — any unauthorized ID returns 403 before any writes. Max 50 audiences per call. Returns 207 for partial success. Requires ‘purchase’ scope.
Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”object
IDs of audiences to update (1–50).
New set_logic to apply to all specified audiences.
Segment ID to append to the included list of each audience.
Segment ID to remove from the included list of each audience.
Valid user-settable transitions, applied to every audience in audience_ids: archived — soft-deletes the audience; excluded from list results by default. active — restores a previously archived audience back to active; rejected with 400 (INVALID_STATUS_TRANSITION) if the current status is not archived. System-managed statuses (pending, expired, failed) cannot be set via this endpoint and are rejected with 400.
Responses
Section titled “Responses”All audiences updated.
object
object
Examplegenerated
{ "updated": 1, "failed": [ { "id": "example", "error": "example" } ]}Partial success — at least one audience failed. Check the failed array.
object
Number of audiences successfully updated.
Details for each audience that could not be updated.
object
Examplegenerated
{ "updated": 1, "failed": [ { "id": "example", "error": "example" } ]}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.
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.
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.
Examples
{ "error": "SCOPE_REQUIRED", "message": "This endpoint requires the purchase scope."}