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

# End call

> Gracefully end the conversation

The `[END_CALL]` tag tells the engine to end the call after the agent has finished speaking. The agent says its goodbye line first, then the call is terminated cleanly.

## Syntax

```
[END_CALL]
```

No parameters. Place it anywhere in the agent's reply.

## Example

> *Caller:* "Great, thanks for the help."
>
> *Agent:* "You're welcome. Have a lovely day. \[END\_CALL]"

The caller hears the goodbye. Then the engine ends the call cleanly.

## When to use it

Tell the agent in the system prompt when it should end calls:

```
ACTIONS
- End the call when the booking is complete and confirmed: [END_CALL]
- End the call when the caller says goodbye or signals they're done: [END_CALL]
- End the call if the caller is being abusive after one warning: [END_CALL]
```

## How call ending works

Nixflex uses three layers to make sure every call ends cleanly on the caller's phone. Closing our own audio stream is not enough — we must explicitly tell the telephony provider to terminate the call.

1. **Trigger** — something decides the call should end (`[END_CALL]` tag, silence timeout, max duration reached, etc.).
2. **Direct telephony hangup** — we call the telephony API to terminate the call leg. The phone disconnects within \~1 second.
3. **Post-stream safety net** — when our stream closes, the telephony provider asks our engine what to do next. We return a hangup instruction so even if step 2 fails, the call still ends.

All three layers run in parallel. The caller's phone disconnects, the recording saves, post-call analysis runs, and the webhook fires.

## Other ways calls end

`[END_CALL]` is the **graceful** option. Calls also end automatically when one of these conditions is met. The exact value is stored on the call record as `ended_reason`.

| `ended_reason`         | What happened                                                                          |
| ---------------------- | -------------------------------------------------------------------------------------- |
| `completed`            | The agent emitted `[END_CALL]`. Goodbye spoken, call ended.                            |
| `caller_hangup`        | The caller pressed end on their phone.                                                 |
| `silence_timeout`      | The caller stayed silent past `silence_hangup_seconds` (default **10s**, range 5–45s). |
| `max_duration_reached` | The call exceeded `max_call_duration_seconds` (default **300s**, range 60s–1800s).     |
| `transferred`          | The caller was transferred to a human via [`[TRANSFER:]`](/actions/transfer).          |
| `voicemail_detected`   | An outbound call hit voicemail. The engine hangs up immediately.                       |
| `balance_insufficient` | The developer ran out of credit. Caller hears an apology, call ends.                   |

Use `ended_reason` to filter analytics and identify problem calls.

## Configuration

The two silence/duration thresholds are agent-level fields:

| Field                       | Default | Range   | Notes                                                       |
| --------------------------- | ------- | ------- | ----------------------------------------------------------- |
| `silence_hangup_seconds`    | `10`    | 5–45    | How long the agent waits in silence before ending the call. |
| `max_call_duration_seconds` | `300`   | 60–1800 | Hard cap on call length, whether or not anyone is talking.  |

Set them when creating an agent or update them later. See [Create agent](/api-reference/agents/create).

<Tip>
  If you want the agent to confirm the booking back to the caller before ending, write that into the prompt. The agent will speak the confirmation, then emit `[END_CALL]`.
</Tip>
