curl --request DELETE \
--url "https://api.nixflex.com/v1/calls/batch/campaign_example" \
--header "Authorization: Bearer $NIXFLEX_API_KEY"
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;
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.
$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.
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;
}
}
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.
nixflex campaigns delete "$NXF_CAMPAIGN_ID" --confirm --json --base-url "https://api.nixflex.com"
{
"name": "delete_campaign",
"arguments": {
"campaign_id": "campaign_fixture",
"confirm": true
}
}
{
"campaign_id": "campaign_example",
"deleted": true,
"message": "Campaign deleted"
}
{
"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
}
}
}
Voice campaigns
Delete a voice campaign
Delete an owned voice campaign, stop waiting work and running calls, and keep sent history and used charges.
DELETE
/
calls
/
batch
/
{id}
curl --request DELETE \
--url "https://api.nixflex.com/v1/calls/batch/campaign_example" \
--header "Authorization: Bearer $NIXFLEX_API_KEY"
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;
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.
$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.
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;
}
}
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.
nixflex campaigns delete "$NXF_CAMPAIGN_ID" --confirm --json --base-url "https://api.nixflex.com"
{
"name": "delete_campaign",
"arguments": {
"campaign_id": "campaign_fixture",
"confirm": true
}
}
{
"campaign_id": "campaign_example",
"deleted": true,
"message": "Campaign deleted"
}
{
"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
}
}
}
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
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.
The 503 flags are inside
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
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.
Authentication
Use the owning account’s server-side credential inAuthorization: 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. |
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. SetNIXFLEX_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. 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.
curl --request DELETE \
--url "https://api.nixflex.com/v1/calls/batch/campaign_example" \
--header "Authorization: Bearer $NIXFLEX_API_KEY"
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;
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.
$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.
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;
}
}
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.
nixflex campaigns delete "$NXF_CAMPAIGN_ID" --confirm --json --base-url "https://api.nixflex.com"
{
"name": "delete_campaign",
"arguments": {
"campaign_id": "campaign_fixture",
"confirm": true
}
}
Example response
{
"campaign_id": "campaign_example",
"deleted": true,
"message": "Campaign deleted"
}
{
"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. |
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 503hangup_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.