Permanently remove a segment
const url = 'https://dev-api.infiniteaudience.ai/v1/segments/example';const options = {method: 'DELETE', headers: {Authorization: 'Bearer <token>'}};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request DELETE \ --url https://dev-api.infiniteaudience.ai/v1/segments/example \ --header 'Authorization: Bearer <token>'Removes the segment from every read surface: GET /v1/segments/{id} returns 404 afterward, and GET /v1/segments always excludes it (there is no override, unlike archived segments). There is no restore endpoint — this is a one-way operation from the API’s perspective, even though the underlying record is retained internally rather than hard-deleted.
Effect on audiences: unlike archiving, deleting a segment that’s referenced by one or more audiences changes those audiences’ composition — the segment is dropped from their resolved segment list and record count. This is the reason for the impact check below; archiving has no such check because it never has this effect.
Impact check: if the segment is referenced by one or more active audiences, the server returns a 409 with audience_count, campaign_count, and an audiences list. Re-submit with ?confirm_impact=true to proceed anyway.
Not idempotent: calling this twice returns 404 on the second call, since the segment is already excluded from lookup after the first delete. No credits are debited. Requires ‘purchase’ scope.
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Query Parameters
Section titled “Query Parameters”Pass true to delete a segment that is referenced by active audiences. Omitting this parameter on an in-use segment returns a 409 with impact details.
Responses
Section titled “Responses”Segment successfully deleted (archived).
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."}Resource not found or not accessible to the calling org.
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": "Audience not found"}Segment is referenced by one or more active audiences. Response body includes impact details. Re-submit with ?confirm_impact=true to delete anyway.
object
object
Example
{ "code": "SEGMENT_IN_USE"}