> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unleashx.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Delete Audience

> Permanently delete audience records from a campaign. This action is irreversible.

Use this endpoint to **permanently delete audience records** from a campaign.

## Endpoint

**POST** `/delete-audience`

**Content-Type:** `application/json`
**Authentication:** Required (workspace auth)

## Request Body

### Delete specific audience

```json theme={null}
{
  "campaign_id": 42,
  "audience": [101, 102, 103]
}
```

### Delete all audience (draft campaigns only)

```json theme={null}
{
  "campaign_id": 42,
  "delete_all": true
}
```

| Field         | Type    | Required | Description                                                                                                |
| ------------- | ------- | -------- | ---------------------------------------------------------------------------------------------------------- |
| `campaign_id` | number  | Yes      | Campaign identifier                                                                                        |
| `audience`    | array   | No       | Array of audience record IDs to delete. Required when `delete_all` is not `true`.                          |
| `delete_all`  | boolean | No       | Set to `true` to delete all audience for this campaign. Only allowed when campaign is in **draft** status. |

## Response

```json theme={null}
{
  "message": "Audience deleted successfully"
}
```

When using `delete_all`:

```json theme={null}
{
  "message": "All audience deleted successfully"
}
```

## Behavior

* **Hard deletes** audience records — this action is **irreversible**.
* When `delete_all` is `true`, all audience for the campaign are deleted. This is only allowed when the campaign is in **draft** status.
* When `delete_all` is not set, `audience` array is required.
* Only deletes records belonging to the specified campaign, company, and workspace.

## Error Cases

| Error                                                                   | Cause                                                              |
| ----------------------------------------------------------------------- | ------------------------------------------------------------------ |
| `Campaign not exist`                                                    | Invalid `campaign_id`                                              |
| `Audience array is required`                                            | `audience` is empty or not provided (when `delete_all` is not set) |
| `All audience can only be deleted when the campaign is in draft status` | `delete_all` is `true` but campaign is not in draft status         |

## Example cURL

```bash theme={null}
curl -X POST https://www.tryunleashx.com/api/v1/global/delete-audience \
  -H "Content-Type: application/json" \
  -H "token: <api_key>" \
  -d '{
    "campaign_id": 42,
    "delete_all": true
  }'
```


## OpenAPI

````yaml api-reference/openapi.json POST /delete-audience
openapi: 3.1.0
info:
  title: >-
    UnleashX - Build human like conversations | Voice Agents | Automations | AI
    Workforce
  version: 1.0.0
  description: UnleashX - Your home for human like conversations
servers:
  - url: https://www.tryunleashx.com/api/v1/global/
security:
  - bearerAuth: []
paths:
  /delete-audience:
    post:
      tags:
        - Campaigns
      summary: Delete audience
      description: >-
        Permanently delete audience records from a campaign. This action is
        irreversible.
      parameters:
        - name: token
          in: header
          required: true
          description: API token for authentication
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - campaign_id
              properties:
                campaign_id:
                  type: integer
                  description: Campaign identifier
                audience:
                  description: >-
                    Array of audience record IDs to delete. Required when
                    delete_all is not true.
                  type: array
                  items:
                    type: integer
                delete_all:
                  type: boolean
                  description: >-
                    Set to true to delete all audience for this campaign. Only
                    allowed when campaign is in draft status.
      responses:
        '200':
          description: Audience deleted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '400':
          description: Campaign not exist or audience array is required
        '401':
          description: Unauthorized
      security: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````