curl --request POST \
--url "https://api.nixflex.com/v1/sms/campaigns" \
--header "Authorization: Bearer $NIXFLEX_API_KEY" \
--header "Content-Type: application/json" \
--data '{"agent_id":"agent_fixture","from_number":"+12025550123","message_template":"Hello {{name}}, your requested appointment reminder.","recipients":[{"phone":"+12025550124","variables":{"name":"Example customer"},"country":"GB","timezone":"Europe/London"}],"schedule_type":"schedule","scheduled_date":"2030-11-04","duplicate_policy":"reject","consent_confirmed":true,"window_start_minutes":0,"window_end_minutes": 1020,"timezone":null}'
import Nixflex from 'nixflex';
const c = new Nixflex({
apiKey: process.env.NIXFLEX_API_KEY,
baseUrl: 'https://api.nixflex.com',
maxRetries: 0,
});
const result = await c.sms.campaigns.create({"agent_id": "agent_fixture", "from_number": "+12025550123", "message_template": "Hello {{name}}, your requested appointment reminder.", "recipients": [{"phone": "+12025550124", "variables": {"name": "Example customer"}, "country": "GB", "timezone": "Europe/London"}], "schedule_type": "schedule", "scheduled_date": "2030-11-04", "duplicate_policy": "reject", "consent_confirmed": true, "window_start_minutes": 0, "window_end_minutes": 1020, "timezone": null});
import os
from nixflex import Nixflex
with Nixflex(
api_key=os.environ["NIXFLEX_API_KEY"],
base_url="https://api.nixflex.com",
max_retries=0,
) as c:
result = c.sms.campaigns.create(agent_id='agent_fixture', from_number='+12025550123', message_template='Hello {{name}}, your requested appointment reminder.', recipients=[{'phone': '+12025550124', 'variables': {'name': 'Example customer'}, 'country': 'GB', 'timezone': 'Europe/London'}], schedule_type='schedule', scheduled_date='2030-11-04', duplicate_policy='reject', consent_confirmed=True, window_start_minutes=0, window_end_minutes=1020, timezone=None)
$body = @'
{
"agent_id": "agent_fixture",
"from_number": "+12025550123",
"message_template": "Hello {{name}}, your requested appointment reminder.",
"recipients": [
{
"phone": "+12025550124",
"variables": {
"name": "Example customer"
},
"country": "GB",
"timezone": "Europe/London"
}
],
"schedule_type": "schedule",
"scheduled_date": "2030-11-04",
"duplicate_policy": "reject",
"consent_confirmed": true,
"window_start_minutes": 0,
"window_end_minutes": 1020,
"timezone": null
}
'@
[IO.File]::WriteAllText('request-176.json', $body, (New-Object Text.UTF8Encoding $false))
nixflex sms campaigns create --body '@request-176.json' --confirm --json --base-url "https://api.nixflex.com"
{
"name": "create_sms_campaign",
"arguments": {
"agent_id": "agent_fixture",
"from_number": "+12025550123",
"message_template": "Hello {{name}}, your requested appointment reminder.",
"recipients": [
{
"phone": "+12025550124",
"variables": {
"name": "Example customer"
},
"country": "GB",
"timezone": "Europe/London"
}
],
"schedule_type": "schedule",
"scheduled_date": "2030-11-04",
"duplicate_policy": "reject",
"consent_confirmed": true
}
}
{
"campaign_id": "campaign_example",
"total": 1,
"total_recipients": 1,
"valid_count": 1,
"invalid_count": 0,
"invalid": [],
"status": "scheduled",
"duplicates": [],
"duplicate_policy": "reject",
"duplicate_choice_required": false
}
SMS campaigns
Create an SMS campaign
Create a Nixflex SMS campaign and its recipients. Default now mode requests launch immediately; use schedule mode to prepare a later launch.
POST
/
sms
/
campaigns
curl --request POST \
--url "https://api.nixflex.com/v1/sms/campaigns" \
--header "Authorization: Bearer $NIXFLEX_API_KEY" \
--header "Content-Type: application/json" \
--data '{"agent_id":"agent_fixture","from_number":"+12025550123","message_template":"Hello {{name}}, your requested appointment reminder.","recipients":[{"phone":"+12025550124","variables":{"name":"Example customer"},"country":"GB","timezone":"Europe/London"}],"schedule_type":"schedule","scheduled_date":"2030-11-04","duplicate_policy":"reject","consent_confirmed":true,"window_start_minutes":0,"window_end_minutes": 1020,"timezone":null}'
import Nixflex from 'nixflex';
const c = new Nixflex({
apiKey: process.env.NIXFLEX_API_KEY,
baseUrl: 'https://api.nixflex.com',
maxRetries: 0,
});
const result = await c.sms.campaigns.create({"agent_id": "agent_fixture", "from_number": "+12025550123", "message_template": "Hello {{name}}, your requested appointment reminder.", "recipients": [{"phone": "+12025550124", "variables": {"name": "Example customer"}, "country": "GB", "timezone": "Europe/London"}], "schedule_type": "schedule", "scheduled_date": "2030-11-04", "duplicate_policy": "reject", "consent_confirmed": true, "window_start_minutes": 0, "window_end_minutes": 1020, "timezone": null});
import os
from nixflex import Nixflex
with Nixflex(
api_key=os.environ["NIXFLEX_API_KEY"],
base_url="https://api.nixflex.com",
max_retries=0,
) as c:
result = c.sms.campaigns.create(agent_id='agent_fixture', from_number='+12025550123', message_template='Hello {{name}}, your requested appointment reminder.', recipients=[{'phone': '+12025550124', 'variables': {'name': 'Example customer'}, 'country': 'GB', 'timezone': 'Europe/London'}], schedule_type='schedule', scheduled_date='2030-11-04', duplicate_policy='reject', consent_confirmed=True, window_start_minutes=0, window_end_minutes=1020, timezone=None)
$body = @'
{
"agent_id": "agent_fixture",
"from_number": "+12025550123",
"message_template": "Hello {{name}}, your requested appointment reminder.",
"recipients": [
{
"phone": "+12025550124",
"variables": {
"name": "Example customer"
},
"country": "GB",
"timezone": "Europe/London"
}
],
"schedule_type": "schedule",
"scheduled_date": "2030-11-04",
"duplicate_policy": "reject",
"consent_confirmed": true,
"window_start_minutes": 0,
"window_end_minutes": 1020,
"timezone": null
}
'@
[IO.File]::WriteAllText('request-176.json', $body, (New-Object Text.UTF8Encoding $false))
nixflex sms campaigns create --body '@request-176.json' --confirm --json --base-url "https://api.nixflex.com"
{
"name": "create_sms_campaign",
"arguments": {
"agent_id": "agent_fixture",
"from_number": "+12025550123",
"message_template": "Hello {{name}}, your requested appointment reminder.",
"recipients": [
{
"phone": "+12025550124",
"variables": {
"name": "Example customer"
},
"country": "GB",
"timezone": "Europe/London"
}
],
"schedule_type": "schedule",
"scheduled_date": "2030-11-04",
"duplicate_policy": "reject",
"consent_confirmed": true
}
}
{
"campaign_id": "campaign_example",
"total": 1,
"total_recipients": 1,
"valid_count": 1,
"invalid_count": 0,
"invalid": [],
"status": "scheduled",
"duplicates": [],
"duplicate_policy": "reject",
"duplicate_choice_required": false
}
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
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
Create an SMS campaign and its recipient rows. The default now mode immediately requests launch; schedule mode saves scheduled work that can run automatically. There is no public draft-only flag.
Method: POST ·
Success: 201 ·
Scope: Owning account
The important part
-
Scheduling. Use
schedule_type: "schedule"andscheduled_date(YYYY-MM-DD). The scheduler checks the date against UTC. Supply both window bounds in minutes, or omit both. Choose a window and time zone for the earliest eligible work. There is no exact-timescheduled_atfield or guaranteed dispatch minute. -
Each successful create saves a new campaign. Sending
reuse_campaign_idcannot replace or replay an SMS campaign. To run it again, submit a fresh campaign. To replace recipients on a scheduled campaign, cancel the original and confirm its state before creating the replacement. Work already in progress can finish. - The default now mode immediately requests launch; scheduled work can run automatically. There is no public draft-only mode.
- Review recipients, consent and message content before creating the campaign, because creation can send messages.
Authentication
SendAuthorization: Bearer KEY_ID:KEY_SECRET using the owning account’s server-side credential. Send Content-Type: application/json.
Request fields
Send a JSON object.| Field | Type | Required | Default | Limits and meaning |
|---|---|---|---|---|
agent_id | string | Yes | None | Active agent owned by this account. |
from_number | string | Yes | None | International number with + and digits; no spaces. Pattern: ^\+[1-9][0-9]{6,14}$. |
name | string | No | Omitted | Campaign label. Empty or omitted uses the channel-specific Untitled campaign label. |
recipients | array of object | Yes | None | At least one accepted recipient; send at most 1,000 recipients per campaign (the whole request must stay under 100 KB). For a bigger list, create several campaigns. Maximum 1000 items. Minimum 1 items. |
recipients[].phone | string | Yes | None | Trimmed E.164 string, 8–15 digits after +; country numbering-plan validation also applies. Pattern: ^\+[1-9][0-9]{7,14}$. |
recipients[].variables | object | No | {} | Per-recipient template values. |
recipients[].country | string | No | Omitted | Uppercase supported two-letter country. Omitted uses conservative number inference. Maximum 2 characters. Minimum 2 characters. |
recipients[].timezone | string | No | Omitted | Explicit recipient IANA Area/City zone; preferred over number inference. Unknown location is held, never replaced by the campaign clock. Maximum 80 characters. |
schedule_type | string | No | "now" | now requests launch immediately after creation. schedule saves scheduled work that the scheduler can launch. Allowed: "now", "schedule". |
scheduled_date | string or null | No | null | Required for schedule; YYYY-MM-DD calendar date. Recipient-local eligibility still applies. Format: date. |
window_start_minutes | integer or null | No | null | Start minute after midnight; supply both ends. Zero means midnight. Minimum 0. Maximum 1439. |
window_end_minutes | integer or null | No | null | End minute after midnight; supply both ends. A lower end denotes an overnight window. Minimum 0. Maximum 1439. |
window_days | array or null | No | null | Optional selected weekdays; duplicate values are collapsed and empty means unset. Allowed items: "mon", "tue", "wed", "thu", "fri", "sat", "sun". |
timezone | string or null | No | null | Optional valid IANA campaign time zone. It does not replace a recipient’s location. |
source | string | No | "api" | Origin label only; API clients should keep api. Allowed: "api", "dashboard". |
skip_invalid | boolean | No | false | When true, omit invalid phone rows only. At least one valid row remains required; other validation failures still refuse. |
duplicate_policy | string | No | "warn" | warn retains duplicate rows and reports them; allow explicitly keeps them; reject refuses duplicates. warn is advisory and does not prevent automatic launch. No silent deduplication. Allowed: "allow", "warn", "reject". |
consent_confirmed | boolean | No | false | Record confirmation for this campaign. Missing consent holds contact until recorded. |
allow_wider_hours | boolean | No | false | Request wider hours with a recorded explanation. Recipient policy and other checks still apply. |
hours_confirmation | string | No | Omitted | Required when wider hours is true: trimmed explanation at least 20 characters; raw maximum 1,000. Maximum 1000 characters. Minimum 20 characters. |
message_template | string | Yes | None | Nonblank text template. Each placeholder such as {{name}} must have a value in every recipient’s variables. |
reply_context_prompt | string or null | No | null | Instructions for replies associated with this campaign. |
reply_window_hours | integer | No | 168 | Hours for campaign reply association; positive integer. Omitted or zero uses 168. Minimum 1. |
Scheduling, consent and duplicate rows
The scheduler and final contact checks use recipient-local eligibility, consent, suppression and capacity. A campaign time zone is not a substitute for an unknown recipient location. Preview contact hours before saving; a preview is advisory. Wider hours require the recorded explanation and remain subject to policy. Choose duplicate_policy deliberately. reject refuses repeated accepted numbers, allow keeps every row, and warn reports duplicates but still allows this route to request launch. The duplicate_choice_required response flag is advisory. It does not create a safe draft or block sending. The scheduled example can contact its recipients when due. Use an approved destination and consent; the date is illustrative. No public draft-only flag is accepted. SMS creation always makes a new campaign ID. An incomingreuse_campaign_id is ignored. To run it again, create a new campaign and review its recipients and consent.
JSON request size and database constraints can limit a request before the maximum accepted-recipient count. No additional text length limit is declared for the prompt or message template on this route.
Response fields
201 Created returns the shape below. Nullable fields can be unknown or unset; do not turn null into zero or false.
Scheduled creation
| Field | Type | Meaning |
|---|---|---|
campaign_id | string | Saved campaign ID. |
total | integer | Original input row count. |
total_recipients | integer | Accepted saved rows. |
valid_count | integer | Accepted recipient rows. |
invalid_count | integer | Rejected phone rows. |
invalid | array of object | Saved value. |
invalid[].phone | legacy value | Original rejected phone input, which may be null or a non-string value. |
invalid[].reason | string | Why this row failed. |
invalid[].row_index | integer | Zero-based original row. Minimum 0. |
invalid[].variables | object | Original variables when present. |
duplicates | array of object | Repeated accepted destinations. |
duplicates[].phone | string | International number with + and digits; no spaces. Pattern: ^\+[1-9][0-9]{6,14}$. |
duplicates[].row_indices | array of integer | Saved value. |
duplicates[].different_content | boolean | Duplicate rows have different variables or prompts. |
duplicate_policy | string | Applied duplicate decision. Allowed: "allow", "warn", "reject". |
duplicate_choice_required | boolean | Advisory flag for repeated rows under warn; it is not a server-side launch lock. |
status | string | Saved campaign state. |
Immediate launch
| Field | Type | Meaning |
|---|---|---|
campaign_id | string | Campaign ID. |
status | string | running while held; otherwise done or failed. |
sent | integer | Accepted sends; not delivery proof. |
failed | integer | Known failures, distinct from accepted sends. |
total_segments | integer | Segment count for this run. |
held | integer | Held recipients when present. |
reason | string | Hold reason when present. |
safe_to_retry | boolean | False when held or outcome requires reconciliation. |
stopped | boolean | Present when number changes stop a legacy run. |
stop_reason | string | Why sending stopped. |
not_sent | integer | Remaining unattempted recipients when known. |
valid_count | integer | Accepted recipient rows. |
invalid_count | integer | Rejected phone rows. |
invalid | array of object | Saved value. |
invalid[].phone | legacy value | Original rejected phone input, which may be null or a non-string value. |
invalid[].reason | string | Why this row failed. |
invalid[].row_index | integer | Zero-based original row. Minimum 0. |
invalid[].variables | object | Original variables when present. |
duplicates | array of object | Repeated accepted destinations. |
duplicates[].phone | string | International number with + and digits; no spaces. Pattern: ^\+[1-9][0-9]{6,14}$. |
duplicates[].row_indices | array of integer | Saved value. |
duplicates[].different_content | boolean | Duplicate rows have different variables or prompts. |
duplicate_policy | string | Applied duplicate decision. Allowed: "allow", "warn", "reject". |
duplicate_choice_required | boolean | Advisory flag for repeated rows under warn; it is not a server-side launch lock. |
total | integer | Original input row count. |
Example request
These examples require Node/CLI 0.11.0 or later, Python 0.4.0 or later and MCP 0.5.0 or later. KeepNIXFLEX_API_KEY private. cURL uses Bash; CLI uses PowerShell and reads the key through NIXFLEX_API_KEY. Replace fixture identifiers and reserved example numbers with approved account-owned values. Configure the existing MCP installation for the same account at https://api.nixflex.com before using the shown tool arguments. Python shows the synchronous client; AsyncNixflex uses the same method with async with and await. This example changes state. Review the target and payload before running it. Running it can contact recipients immediately or when scheduled; scheduled creation is executable, not a draft. The existing MCP create tool does not expose nullable timezone as a typed argument, so its example omits that field.
curl --request POST \
--url "https://api.nixflex.com/v1/sms/campaigns" \
--header "Authorization: Bearer $NIXFLEX_API_KEY" \
--header "Content-Type: application/json" \
--data '{"agent_id":"agent_fixture","from_number":"+12025550123","message_template":"Hello {{name}}, your requested appointment reminder.","recipients":[{"phone":"+12025550124","variables":{"name":"Example customer"},"country":"GB","timezone":"Europe/London"}],"schedule_type":"schedule","scheduled_date":"2030-11-04","duplicate_policy":"reject","consent_confirmed":true,"window_start_minutes":0,"window_end_minutes": 1020,"timezone":null}'
import Nixflex from 'nixflex';
const c = new Nixflex({
apiKey: process.env.NIXFLEX_API_KEY,
baseUrl: 'https://api.nixflex.com',
maxRetries: 0,
});
const result = await c.sms.campaigns.create({"agent_id": "agent_fixture", "from_number": "+12025550123", "message_template": "Hello {{name}}, your requested appointment reminder.", "recipients": [{"phone": "+12025550124", "variables": {"name": "Example customer"}, "country": "GB", "timezone": "Europe/London"}], "schedule_type": "schedule", "scheduled_date": "2030-11-04", "duplicate_policy": "reject", "consent_confirmed": true, "window_start_minutes": 0, "window_end_minutes": 1020, "timezone": null});
import os
from nixflex import Nixflex
with Nixflex(
api_key=os.environ["NIXFLEX_API_KEY"],
base_url="https://api.nixflex.com",
max_retries=0,
) as c:
result = c.sms.campaigns.create(agent_id='agent_fixture', from_number='+12025550123', message_template='Hello {{name}}, your requested appointment reminder.', recipients=[{'phone': '+12025550124', 'variables': {'name': 'Example customer'}, 'country': 'GB', 'timezone': 'Europe/London'}], schedule_type='schedule', scheduled_date='2030-11-04', duplicate_policy='reject', consent_confirmed=True, window_start_minutes=0, window_end_minutes=1020, timezone=None)
$body = @'
{
"agent_id": "agent_fixture",
"from_number": "+12025550123",
"message_template": "Hello {{name}}, your requested appointment reminder.",
"recipients": [
{
"phone": "+12025550124",
"variables": {
"name": "Example customer"
},
"country": "GB",
"timezone": "Europe/London"
}
],
"schedule_type": "schedule",
"scheduled_date": "2030-11-04",
"duplicate_policy": "reject",
"consent_confirmed": true,
"window_start_minutes": 0,
"window_end_minutes": 1020,
"timezone": null
}
'@
[IO.File]::WriteAllText('request-176.json', $body, (New-Object Text.UTF8Encoding $false))
nixflex sms campaigns create --body '@request-176.json' --confirm --json --base-url "https://api.nixflex.com"
{
"name": "create_sms_campaign",
"arguments": {
"agent_id": "agent_fixture",
"from_number": "+12025550123",
"message_template": "Hello {{name}}, your requested appointment reminder.",
"recipients": [
{
"phone": "+12025550124",
"variables": {
"name": "Example customer"
},
"country": "GB",
"timezone": "Europe/London"
}
],
"schedule_type": "schedule",
"scheduled_date": "2030-11-04",
"duplicate_policy": "reject",
"consent_confirmed": true
}
}
Example response
Illustrative201 response. Identifiers and values are examples; some optional or compatibility fields are omitted.
{
"campaign_id": "campaign_example",
"total": 1,
"total_recipients": 1,
"valid_count": 1,
"invalid_count": 0,
"invalid": [],
"status": "scheduled",
"duplicates": [],
"duplicate_policy": "reject",
"duplicate_choice_required": false
}
Errors
Failures return anerror object with code, message, doc_url and optional details. Each code links to the shared error catalog. Read the message and details before deciding whether to resend.
| Status | Code | Meaning | What to do |
|---|---|---|---|
| 400 | campaign_creation_failed | Required settings, ownership, template values, duplicate policy or recipient metadata failed validation. | Read error.details when present; correct the request before creating again. |
| 400 | invalid_phone_format | Phone validation failed or no valid recipients remain. | Fix invalid rows; skip_invalid only skips invalid phone rows. |
| 400 | campaign_launch_failed | Creation succeeded but immediate launch was refused. | Read details.campaign_id and reconcile the saved campaign. |
| 500 | campaign_outcome_unknown | A campaign save or launch result is uncertain. | Use details.campaign_id to reconcile; safe_to_retry is false. |
| 503 | campaigns_paused | Campaign admission is temporarily paused. | Wait before a deliberate retry; check any saved campaign first. |
| 500 | server_error | The result could not be confirmed. | Read the current state before repeating a write. |
| 503 | dispatch_safety_unavailable | The current recipient was refused before sending because its safety record was unavailable. | Reconcile earlier accepted sends; do not replay the whole campaign. |
| 409 | account_inactive | Account sending is disabled. | Read details for this attempt and reconcile earlier accepted messages. |
| 409 | number_changed | The sending number changed. | Read details for this attempt and reconcile earlier accepted messages. |
| 409 | do_not_contact | The current recipient is suppressed. | Read details for this attempt and reconcile earlier accepted messages. |
| 400 | invalid_json | Invalid JSON body. | Correct JSON syntax. |
| 413 | payload_too_large | The request exceeds the JSON body limit. | Send a smaller request. |
| 401 | unauthorized | The credential is missing or invalid. | Check the full account credential. |
| 429 | rate_limit_exceeded | The account request limit was reached. | Wait for Retry-After. Reconcile uncertain writes before resending. |
Retry and idempotency
Creation is not idempotent. Do not automatically retry after a timeout, 5xx, or saved-but-refused launch. Read the campaign list/detail using the returned campaign_id when available; ask support to reconcile an unknown result. Duplicate detection compares input rows, not repeated HTTP requests. Queue admission or a sent count does not confirm contact or delivery.Related endpoints
Authorizations
Body
application/json
Response
Created
- Option 1
- Option 2
Scheduled creation or immediate launch result.