Create outbound call
Calls
Create outbound call
POST /v1/calls/outbound
POST
Create outbound call
Triggers Nixflex to call a phone number. The agent dials, waits for pickup, runs voicemail detection, and starts the conversation when a human answers.
The call is fire-and-forget: the request returns immediately with a
The engine replaces
The response returns immediately. Twilio dials within ~5 seconds. The actual call lifecycle (ringing → connected → ended) happens asynchronously — you will receive a webhook when the call ends if you have a
call_id, then the actual ringing, conversation, and ending all happen asynchronously. If you want the result, set a webhook_url on the agent (or on the number) and you will receive a call.completed event when the call ends.
The number you dial from must be outbound-enabled. A number that only handles inbound calls will not place outbound calls. Enable outbound on the Phone Numbers page (or when you import the number). Inbound working does not mean outbound works — they are separate switches.
Request
Body parameters
| Field | Type | Required | Notes |
|---|---|---|---|
agent_id | string | Yes | The agent that will handle this call. Must belong to your API key. |
to_number | string | Yes | Who to call, in E.164 format (+447386172392, not 07386172392). |
prompt | string | Yes | The call purpose — what the agent should say and why it is calling. Sent fresh per call, stored nowhere. This is separate from the agent’s own saved prompt and must not be empty. |
dynamic_vars | object | No | Key-value pairs injected into the prompt (see below). |
from_number | string | No | Which of your numbers to dial from. Must be an outbound-enabled number on this agent. If you omit it, the engine uses the agent’s first outbound-enabled number. |
campaign_id | string | No | Link this call to a batch campaign for reporting. |
How the dialing number is chosen
You do not have to passfrom_number. The engine works out which of your numbers to dial from in this order:
- You passed
from_number→ the engine uses exactly that number, but only if it is outbound-enabled and belongs to this agent under your API key. If it is not, you getfrom_number_not_found. - You omitted
from_number→ the engine picks the agent’s first outbound-enabled number. - Legacy fallback → if the agent has no rows in the phone numbers table, it falls back to the single number stored on the agent itself.
agent_missing_phone_number.
Dynamic variables
Anything indynamic_vars is interpolated into the prompt. Reference each value with curly braces:
{patient_name} with "Sarah" before the agent speaks. If the prompt references a variable that is not in dynamic_vars, it is left as-is — the agent will see the literal {patient_name} text, so double-check your keys match.
Response
201 Created:
webhook_url set.
Validation order
The engine checks these in order and stops at the first failure:agent_id,to_number, andpromptare all present (andpromptis not blank).to_numberis valid E.164 (e.g.+447386172392, not07386172392).- The agent exists and belongs to your API key.
- The agent has an outbound-enabled number assigned. Inbound-only numbers do not count. If you passed a specific
from_number, it must be outbound-enabled on this agent. - Twilio credentials exist for that number.
400 with a specific code (see below).
Errors
| Code | HTTP | Cause |
|---|---|---|
missing_field | 400 | agent_id, to_number, or prompt is missing or empty |
invalid_phone_format | 400 | to_number is not valid E.164 |
from_number_not_found | 400 | The from_number you passed is not an outbound-enabled number on this agent. Import it and enable outbound on the Phone Numbers page. |
agent_missing_phone_number | 400 | The agent has no number assigned. Import one via Phone numbers and enable outbound. |
agent_missing_twilio_credentials | 400 | The chosen number has no Twilio credentials stored |
outbound_failed | 502 | Twilio rejected the dial (see details.twilio_error) |
What happens next
After you trigger the call:- Twilio dials the
to_numberusing the chosen outbound number. - Voicemail detection runs (AMD + speech-pattern matching).
- If voicemail is detected, the engine ends the call.
- If a human answers, the agent starts the conversation using your
prompt. - The call ends naturally, or via
[END_CALL], or on timeout. - The recording is saved and post-call analysis runs.
- A
call.completedwebhook fires to yourwebhook_urlif one is set.