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

# Delete a voice campaign

> Delete an owned voice campaign, stop waiting work and running calls, and keep sent history and used charges.

**FIXED · campaign** **MUST** Resume covers only unattempted work in the existing running launch, and neither resume nor reuse replays completed work.\
reuse\_campaign\_id replaces settings and recipients atomically only on an owned, never-launched voice draft or scheduled campaign. A launch claim prevents replacement. SMS creation always generates a fresh ID, even if the request forwards this field. Omit it for SMS.

**NOT OFFERED → do this instead · campaign** A launched or finished campaign cannot run again. For another run create a campaign with a fresh ID, selected recipients and reviewed settings. The dashboard’s Use again button follows the same rule for voice: it edits a campaign that never launched, otherwise it opens a new campaign filled with the original settings and recipients for review before launch. SMS campaigns have no Use again button.

**YOU CAN CHANGE · campaign** Use schedule\_type=schedule, scheduled\_date (YYYY-MM-DD), timezone, window\_days and optional paired window\_start\_minutes/window\_end\_minutes. UTC date checks, local windows and capacity apply.

**SCOPE · campaign** `DELETE /v1/calls/batch/{id}` deletes a voice campaign. Voice and SMS have separate cancel routes. Cancel stops future work. Running attempts may finish.

For one owned sender, send business\_number (encode + as %2B) on `GET /v1/campaigns` or `GET /v1/sms/campaigns`. Omit for account scope. Keep the same number and status through SMS cursors. Restart paging if either changes. Voice include\_totals=true covers returned campaigns only (default 50, max 200).

Pickup rate = answered attempts / all attempts, including failed starts. Answered means over five seconds with no detected voicemail. Sum counts before dividing. Zero attempts means no rate. SMS delivery rate = delivered / (delivered + failed).

[Read the compact AI rules](https://docs.nixflex.com/ai-rules.md#campaigns)

Stop this campaign and remove its campaign view while preserving sent history and used charges.

Method: **DELETE** · Success: **200** · Permission: **Owner or Admin**

**The important part**

* Running calls are hung up before content deletion.
* A queued hang-up is not a completed delete; the same request safely resumes it.
* Used charges remain. Customer-managed copies have their own lifecycle.

[Business guide](https://docs.nixflex.com/guides/business/privacy/delete-call-data.md) · [Developer guide](https://docs.nixflex.com/guides/developer/campaigns.md) · [Glossary](https://docs.nixflex.com/guides/glossary.md)

## Authentication

Use the owning account's server-side credential in `Authorization: Bearer KEY_ID:KEY_SECRET`. An organisation API key has Owner authority. Personal dashboard sessions need Owner or Admin authority; Members receive 403.

## Request fields

| Field | Type | Required | Limits |
| - | - | - | - |
| `id` (path) | string | Yes | 1–200 characters; the exact owned identifier. |

Do not send a request body. Review the ID and effect before sending; completed content removal cannot be undone.

Deleting a voice or SMS campaign cancels waiting work, hangs up its running calls, then removes the campaign and recipient list. Calls already made and texts already sent stay in history. Used charges stay in billing; there are no refunds. Owner and Admin can delete; Member cannot. Cancel alone stops future dispatch and lets active calls finish; Delete also requests their hang-up.

## Response fields

HTTP 200 confirms content deletion. It does not erase billing or every external copy.

| Field | Type | Meaning |
| - | - | - |
| `campaign_id` | string | The requested owned campaign ID. |
| `deleted` | boolean | True: the campaign and recipient list are removed. |
| `message` | string | `Campaign deleted`. |

## Example request

This request changes the selected resource. Set `NIXFLEX_API_KEY` privately for the same account and host; use an owned identifier. The examples send once.

The SDK/CLI tabs use the exact [supported clients](https://docs.nixflex.com/sdks/ecosystem.md#install-a-client). Configure `NIXFLEX_API_KEY` and `NXF_CAMPAIGN_ID` privately. Raw HTTP base URL: `https://api.nixflex.com/v1`. Node and Python SDK base URL: `https://api.nixflex.com`. The SDK adds `/v1`. Configure MCP with the same origin and account. SDKs preserve the known queued error; other uncertain errors use `outcome_unknown` with the server code in `details.original_code`.

```bash cURL theme={"dark"}
curl --request DELETE \
  --url "https://api.nixflex.com/v1/calls/batch/campaign_example" \
  --header "Authorization: Bearer $NIXFLEX_API_KEY"
```

```javascript Node HTTP theme={"dark"}
const response = await fetch("https://api.nixflex.com/v1/calls/batch/campaign_example", {
  method: 'DELETE', redirect: 'error', signal: AbortSignal.timeout(30_000),
  headers: {Authorization: `Bearer ${process.env.NIXFLEX_API_KEY}`},
});
const result = await response.json();
if (!response.ok && result.error?.code !== 'hangup_pending') {
  throw new Error(`HTTP ${response.status}: ${result.error?.code || 'unknown'}`);
}
// A queued reply is not deletion success. Show the returned state privately.
const deleted = response.ok && result.deleted === true;
```

```python Python HTTP theme={"dark"}
import json, os
from urllib.error import HTTPError
from urllib.request import HTTPRedirectHandler, Request, build_opener

class NoRedirect(HTTPRedirectHandler):
    def redirect_request(self, req, fp, code, msg, headers, newurl):
        return None

opener = build_opener(NoRedirect())
request = Request("https://api.nixflex.com/v1/calls/batch/campaign_example", method="DELETE",
    headers={"Authorization": "Bearer " + os.environ["NIXFLEX_API_KEY"]})
try:
    with opener.open(request, timeout=30) as response:
        result = json.load(response)
        deleted = result.get("deleted") is True
except HTTPError as error:
    result = json.load(error)
    deleted = False
    if result.get("error", {}).get("code") != "hangup_pending":
        raise
# Keep result private. Queued hang-up continues without a polling write loop.
```

```powershell PowerShell HTTP theme={"dark"}
$headers = @{ Authorization = "Bearer $env:NIXFLEX_API_KEY" }
$deleted = $false
try {
    $result = Invoke-RestMethod -Method DELETE -Uri "https://api.nixflex.com/v1/calls/batch/campaign_example" -Headers $headers -MaximumRedirection 0 -TimeoutSec 30
    $deleted = $result.deleted -eq $true
} catch {
    # A 503 is not completed deletion. Read the safe error response privately.
    # hangup_pending continues automatically; do not start a write polling loop.
    throw
}
# Use $result privately. Only $deleted confirms content removal.
```

```javascript Node SDK theme={"dark"}
import Nixflex, { NixflexServerError } from 'nixflex';

const apiKey = process.env.NIXFLEX_API_KEY;
const baseUrl = 'https://api.nixflex.com';
const resourceId = process.env.NXF_CAMPAIGN_ID;
if (!apiKey || !baseUrl || !resourceId) throw new Error('Configure the account, host and approved resource ID.');
const client = new Nixflex({apiKey, baseUrl, maxRetries: 0});
try {
  const receipt = await client.campaigns.delete(resourceId);
  if (receipt.deleted !== true || receipt.campaign_id !== resourceId || typeof receipt.message !== 'string') {
    throw new Error('Deletion is not confirmed.');
  }
  console.log('Content deletion confirmed; recording and history rules still apply.');
} catch (error) {
  if (error instanceof NixflexServerError && error.status === 503 &&
      error.code === 'hangup_pending' && error.details?.deleted === false &&
      error.details?.retry_pending === true) {
    console.log('Deletion queued; the server continues after hang-up.');
  } else {
    // Keep the error private. Reconcile an unknown result before a deliberate repeat.
    throw error;
  }
}
```

```python Python SDK theme={"dark"}
import os
from nixflex import Nixflex
from nixflex.errors import NixflexServerError

with Nixflex(api_key=os.environ["NIXFLEX_API_KEY"],
             base_url="https://api.nixflex.com", max_retries=0) as client:
    try:
        receipt = client.campaigns.delete(os.environ["NXF_CAMPAIGN_ID"])
        if (receipt.get("deleted") is not True
                or receipt.get("campaign_id") != os.environ["NXF_CAMPAIGN_ID"]
                or not isinstance(receipt.get("message"), str)):
            raise RuntimeError("Deletion is not confirmed.")
        print("Content deletion confirmed; recording and history rules still apply.")
    except NixflexServerError as error:
        if (error.status == 503 and error.code == "hangup_pending"
                and error.details.get("deleted") is False
                and error.details.get("retry_pending") is True):
            print("Deletion queued; the server continues after hang-up.")
        else:
            raise  # Keep private; reconcile an unknown result before a deliberate repeat.
```

```bash CLI theme={"dark"}
nixflex campaigns delete "$NXF_CAMPAIGN_ID" --confirm --json --base-url "https://api.nixflex.com"
```

```json MCP theme={"dark"}
{
  "name": "delete_campaign",
  "arguments": {
    "campaign_id": "campaign_fixture",
    "confirm": true
  }
}
```

## Example response

```json 200 deletion confirmed theme={"dark"}
{
  "campaign_id": "campaign_example",
  "deleted": true,
  "message": "Campaign deleted"
}
```

```json 503 hang-up queued theme={"dark"}
{
  "error": {
    "type": "server_error",
    "code": "hangup_pending",
    "message": "Waiting work is cancelled. Some calls have not confirmed they ended yet. Deletion is queued and will finish once hang-up is confirmed.",
    "doc_url": "https://docs.nixflex.com/errors/hangup_pending",
    "details": {
      "deleted": false,
      "retry_pending": true
    }
  }
}
```

## Errors

| Status / code | Meaning | What to do |
| - | - | - |
| 400 `invalid_delete` | Invalid identifier length. | Use the exact owned ID, from 1 to 200 characters. |
| 401 | Missing or invalid authentication. | Check the credential and host privately. |
| 403 `permission_denied` | The personal session cannot delete. | Ask an Owner or Admin; never give a Member the account key as a workaround. |
| 404 `not_found` | The item is missing or belongs to another account. | Check the saved ID and account. Do not infer another account's data. |
| 429 | Rate limited. | Honour Retry-After and avoid a polling write loop. |
| 503 `hangup_pending` | Hang-up is unconfirmed; deletion is queued. | Show queued, not deleted. The worker continues automatically; the same DELETE safely resumes it. |
| 503 `deletion_unavailable` | Deletion could not be confirmed. | Check the list and repeat the same DELETE if needed; an existing request safely resumes. |

The 503 flags are inside `error.details`, not at the response root. `hangup_pending` includes `deleted:false` and `retry_pending:true`; `deletion_unavailable` includes `deleted:false` without promising that a queue exists.

## Retry and idempotency

If hang-up is not confirmed, HTTP 503 `hangup_pending` returns `error.details.deleted:false` and `error.details.retry_pending:true`. Deletion stays queued and continues automatically. Repeating the same DELETE for the same account and ID safely resumes it. A lost response or `deletion_unavailable` is not success: check the list, then repeat that same DELETE if needed. Missing and foreign IDs share HTTP 404. Bulk call deletion and account closure keep separate safety rules.

Use bounded reads to refresh the list. Do not treat the generic write-retry rule for call creation or SMS sending as the deletion rule: this same-ID DELETE can be repeated deliberately to resume cleanup. It does not require an Idempotency-Key header.

## Related endpoints

* [Delete call data in the dashboard](https://docs.nixflex.com/guides/business/privacy/delete-call-data.md)
* [Bulk call deletion](https://docs.nixflex.com/api-reference/calls/delete-all.md)
* [Errors and recovery](https://docs.nixflex.com/api-reference/errors.md#error-envelope)


## OpenAPI

````yaml api-reference/public.openapi.json DELETE /calls/batch/{id}
openapi: 3.1.0
info:
  title: Nixflex public API
  version: 1.0.0
  description: >-
    Nixflex API reference for agents, calls, messaging, knowledge, organisations
    and integrations. Authenticate with the owning account and follow each
    operation’s permissions, response and retry contract.
servers:
  - url: https://api.nixflex.com/v1
security:
  - bearerAuth: []
paths:
  /calls/batch/{id}:
    delete:
      tags:
        - Voice campaigns
      summary: Delete a voice campaign
      description: >-
        Cancel waiting campaign work, hang up its running calls, then remove the
        campaign and recipient list. Calls already made and SMS already sent
        remain in history. Owner and Admin may delete; Member may not. Used
        charges and required financial evidence remain; no refund is made. A
        hangup_pending response queues durable completion without waiting for
        settlement. Repeating the same DELETE safely resumes the same request. A
        lost response is not confirmed success. Customer-managed copies are
        outside this operation. Bulk call deletion and account closure have
        separate contracts.
      operationId: deleteVoiceCampaign
      parameters:
        - name: id
          in: path
          required: true
          description: >-
            Owned campaign identifier. Missing and foreign IDs have the same
            404.
          schema:
            type: string
            minLength: 1
            maxLength: 200
      responses:
        '200':
          description: >-
            Campaign and recipient list removed. Sent history and used charges
            remain.
          content:
            application/json:
              schema:
                type: object
                required:
                  - campaign_id
                  - deleted
                  - message
                properties:
                  campaign_id:
                    type: string
                  deleted:
                    type: boolean
                    const: true
                  message:
                    type: string
                    const: Campaign deleted
                additionalProperties: true
              examples:
                deleted:
                  value:
                    campaign_id: campaign_example
                    deleted: true
                    message: Campaign deleted
        '400':
          description: 'invalid_delete: The identifier must contain 1–200 characters.'
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: object
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                      - details
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                        enum:
                          - invalid_delete
                      message:
                        type: string
                      doc_url:
                        type: string
                        format: uri
                      details:
                        type: object
                        additionalProperties: true
                    additionalProperties: true
                additionalProperties: true
              examples:
                invalid_delete:
                  value:
                    error:
                      type: invalid_request
                      code: invalid_delete
                      message: Choose a valid call or campaign.
                      doc_url: https://docs.nixflex.com/errors/invalid_delete
                      details: {}
        '401':
          description: Authentication failed - bad or missing API key.
          content:
            application/json:
              schema:
                type: object
                description: >-
                  Every error uses this envelope. Branch on error.code, not on
                  the message text.
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      doc_url:
                        type: string
                      details:
                        type: object
                        additionalProperties: true
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                required:
                  - error
        '403':
          description: >-
            permission_denied: Owner or Admin authority is required. A Member
            cannot delete content.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: object
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                      - details
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                        enum:
                          - permission_denied
                      message:
                        type: string
                      doc_url:
                        type: string
                        format: uri
                      details:
                        type: object
                        additionalProperties: true
                    additionalProperties: true
                additionalProperties: true
              examples:
                permission_denied:
                  value:
                    error:
                      type: permission_denied
                      code: permission_denied
                      message: Only an Admin or the Owner can do this.
                      doc_url: https://docs.nixflex.com/errors/permission_denied
                      details: {}
        '404':
          description: >-
            not_found: The item is missing or belongs to another account. These
            cases have the same response.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: object
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                      - details
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                        enum:
                          - not_found
                      message:
                        type: string
                      doc_url:
                        type: string
                        format: uri
                      details:
                        type: object
                        additionalProperties: true
                    additionalProperties: true
                additionalProperties: true
              examples:
                not_found:
                  value:
                    error:
                      type: not_found
                      code: not_found
                      message: Campaign not found.
                      doc_url: https://docs.nixflex.com/errors/not_found
                      details: {}
        '429':
          description: Rate limit exceeded. Honour the Retry-After header.
          content:
            application/json:
              schema:
                type: object
                description: >-
                  Every error uses this envelope. Branch on error.code, not on
                  the message text.
                properties:
                  error:
                    type: object
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                      message:
                        type: string
                      doc_url:
                        type: string
                      details:
                        type: object
                        additionalProperties: true
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                required:
                  - error
        '503':
          description: >-
            hangup_pending: Hang-up is unconfirmed and durable deletion will
            continue. deletion_unavailable: The result could not be confirmed;
            check the list and repeat the same DELETE to resume any existing
            request safely.
          content:
            application/json:
              schema:
                type: object
                required:
                  - error
                properties:
                  error:
                    type: object
                    required:
                      - type
                      - code
                      - message
                      - doc_url
                      - details
                    properties:
                      type:
                        type: string
                      code:
                        type: string
                        enum:
                          - hangup_pending
                          - deletion_unavailable
                      message:
                        type: string
                      doc_url:
                        type: string
                        format: uri
                      details:
                        type: object
                        additionalProperties: true
                    additionalProperties: true
                additionalProperties: true
              examples:
                hangup_pending:
                  value:
                    error:
                      type: server_error
                      code: hangup_pending
                      message: >-
                        Waiting work is cancelled. Some calls have not confirmed
                        they ended yet. Deletion is queued and will finish once
                        hang-up is confirmed.
                      doc_url: https://docs.nixflex.com/errors/hangup_pending
                      details:
                        deleted: false
                        retry_pending: true
                deletion_unavailable:
                  value:
                    error:
                      type: server_error
                      code: deletion_unavailable
                      message: >-
                        Deletion could not be confirmed. Check the list and try
                        Delete again; an existing request will safely resume.
                      doc_url: https://docs.nixflex.com/errors/deletion_unavailable
                      details:
                        deleted: false
      security:
        - bearerAuth: []
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        KEY_ID:KEY_SECRET from the owning account. Keep it server-side. A
        verified personal dashboard Bearer session may be used where the
        operation documents role-based access.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.