> ## 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.

# Handle call outcomes and safe retries

> Handle Nixflex call starts, active calls, deletions and unknown outcomes. Use confirmed state before retrying actions or treating a call as completed.

**FIXED · call** Pass the customer’s verified from\_number. With require\_from\_number\_for\_shared\_agent off (default), omission selects the oldest eligible number by created\_at then id; a disabled number is not eligible. With it on, two or more settled attachments, even disabled ones, require an explicit sender (400 from\_number\_required). A sole eligible number works; none gives 400 agent\_missing\_phone\_number. Pending imports do not count.

**NOT OFFERED → do this instead · call** Outbound developer instructions do not inherit the agent’s inbound system\_prompt or the number’s custom\_prompt. Include the business and purpose in prompt or the recipient’s prompt\_override. Fixed call rules and enabled knowledge and tools can still apply.

**YOU CAN CHANGE · call** Send agent\_id, from\_number, to\_number and a meaningful prompt. Choose dynamic\_vars for this call.

**SCOPE · call** Track an outbound request using its receipt. Preserve the request ID across an uncertain response and check its status before another dial.

Read `GET /v1/organisation/outbound-settings`. Where available, the Owner or organisation API key can PATCH the same path with require\_from\_number\_for\_shared\_agent. Campaigns need a reviewed sender. If it changes, choose and confirm again.

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

Reconcile a call launch from its saved request or call ID before deciding whether another action is appropriate.

Guide: **API reference** · Topic: **Outcomes and retries**

**The important part**

* A 201 launch reply means initiated, not connected or completed.
* Use the saved request UUID to reconcile pending or unknown launches without redialling.

[Business guide](https://docs.nixflex.com/guides/business/call-history.md) · [Developer guide](https://docs.nixflex.com/guides/lead-qualification.md) · [Glossary](https://docs.nixflex.com/guides/glossary.md)

These examples require the [documented minimum client versions](https://docs.nixflex.com/sdks/ecosystem.md#install-a-client).

## Single-call variables

The HTTP field is `dynamic_vars`. Use double braces in the prompt: `{{name}}`.

| Client | Input | Sent to `/v1/calls/outbound` |
| - | - | - |
| Node | `dynamic_vars: { name: 'Sam' }` | `dynamic_vars` |
| CLI | `--var name=Sam` | `dynamic_vars` |
| Python sync/async | `variables={"name": "Sam"}` | `dynamic_vars` |
| MCP `create_call` | `variables: { "name": "Sam" }` | `dynamic_vars` |

```typescript theme={"dark"}
await client.calls.create({
  agent_id: 'agent_example', to_number: '+12025550100',
  prompt: 'Confirm the appointment with {{name}}.', dynamic_vars: { name: 'Sam' },
});
```

```powershell theme={"dark"}
nixflex calls create --agent agent_example --to +12025550100 --prompt 'Confirm with {{name}}.' --var name=Sam
```

These examples place a real paid call when run with a real configured client.
Use the supplied offline fake-test helper to test this release instead.

Python also accepts the canonical `dynamic_vars` keyword; use only one alias.
CLI `--body`/`--set` may use either alias, but cannot combine them or combine one
with `--var`. Ambiguous inputs fail locally before any request. Empty maps and
empty string values are preserved. Campaign recipient `variables` is a separate,
unchanged contract; do not rename it to `dynamic_vars`.

Supply every referenced value; enabled missing-detail checks may refuse incomplete
calls. Per-call purpose/variables can become part of stored prompts and history.
They are not guaranteed to disappear or be stored nowhere.

## One attempt for a change

Python sync and async now use the same no-automatic-mutation-retry rule as Node:

* **GET**: bounded retry on network failure, timeout, 429 and 5xx; default one
  retry, `max_retries=0` / `maxRetries=0` disables it. Retry-After waits cap at 30s.
* **POST/PUT/PATCH/DELETE**: one attempt, including 429, 5xx, disconnect and timeout.
* Lost/malformed change reply, unproved 5xx or redirect: `NixflexOutcomeUnknownError`,
  `outcome='unknown'`, `safe_to_retry=false`. A call/change may already have happened.
* A 429 remains a rate-limit error. Its delay is not permission to resend a change.
* Explicit whole-operation proof (`outcome=not_sent`, `sent=false`, `charged=false`,
  `safe_to_retry=true`) stays distinct, but the SDK still does not resend it.

Python's new error is also a `NixflexServerError` for existing catch compatibility.
Catch the specific unknown type before a general server error. Status, request ID
and original error details remain available when a response supplied them.

Do not put a blind retry loop around the SDK, CLI or MCP tool. If a `call_id` is
known, read it; otherwise check recent history and the request ID with support.
An empty history page does not confirm nothing was sent. This is not an exactly-once
server/idempotency guarantee. MCP retains its existing no-retry mutation wrapper
around pinned SDK 0.8.0; the variable fix works without publishing a new SDK first.

## Node history iteration and MCP summaries

`for await (const call of client.calls.iter(200)) { ... }` reads beyond 200 rows.
The iterator accepts whole-number page sizes 1–200 only. Oversized, zero, negative,
fractional and nonnumeric values throw `RangeError` before HTTP. A full final page
requires one last empty read; a short page stops immediately. Offset pages are not
a snapshot and can shift if history changes during iteration.

MCP summaries read `call_direction`, then compatible `call_type`/older `direction`.
Unrecognised/missing direction is null, not guessed inbound. Zero duration, false
success and null analysis are not invented as positive results. Summary lists
exclude transcripts, prompts and recording URLs; use `get_call` for detail.

Full history filters, recording availability and billing breakdown are later batches.
Do not rely on the current CLI/MCP `agent_id` call-list argument: the API does not
apply that filter yet. No additional live control or tester capability is added.

## Reconcile an outbound request UUID

Save one UUID before the first request for an intended call. Persist it with the request payload so a process restart cannot accidentally create a new intent. Supply it as the JSON field `request_id`, not an Idempotency-Key header.

| Result | What it proves | Next action |
| - | - | - |
| 201 initiated | A call was accepted; completion is still unknown. | Save call\_id and request\_id; read the call. |
| 200 replayed:true | This UUID already has an accepted call. | Use the same call\_id; no second dispatch occurred. |
| 409 outbound\_request\_pending / outbound\_request\_unknown | The existing intent cannot be launched again. | Keep the UUID and read request status. |
| 409 request\_id\_conflict | The same UUID was used with changed input. | Reconcile the original payload; do not automatically replace the UUID. |
| 503 with details.safe\_to\_retry:false | The journal or launch outcome is uncertain. | Keep the UUID and use bounded status reads. |

A 201 can also include `request_status:"unconfirmed"` and `safe_to_retry:false`: the call ID is known even though the final journal acknowledgement was lost. Never redial it. A new UUID is a new explicit call intent. Requests without request\_id retain their existing behaviour and have no launch replay protection.

Read [outbound request status](https://docs.nixflex.com/api-reference/calls/get-outbound-request.md). A 404 or an empty history page does not confirm that an uncertain call was never placed.

## Next steps

* [API overview](https://docs.nixflex.com/api-reference/introduction.md)
* [Errors and recovery](https://docs.nixflex.com/api-reference/errors.md)
* [Retry rules](https://docs.nixflex.com/api-reference/retries.md)


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