> ## Documentation Index
> Fetch the complete documentation index at: https://docs.thinnest.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# End Call

> Configure how and when your voice agent ends a call — trigger conditions, farewell messages, and post-call actions.

# End Call

The **End Call** tool lets your voice agent programmatically hang up a call based on conversation context. Instead of waiting for the caller to disconnect, your agent can end the call gracefully after resolving the issue, completing a booking, or when the conversation reaches a natural conclusion.

## When to Use

* The caller's issue is resolved and they say "goodbye" or "thank you"
* The agent has completed its task (e.g., appointment booked, order status provided)
* The caller is unresponsive or silent for too long
* The conversation reaches a predefined time limit
* The caller is abusive or violating usage policies

## Configuration

### Via the Dashboard

1. Open your agent and scroll to **Voice Settings**.
2. Enable **End Call**.
3. Configure the options:

| Setting               | Description                            | Default                           |
| --------------------- | -------------------------------------- | --------------------------------- |
| **Farewell message**  | What the agent says before hanging up  | "Thank you for calling. Goodbye!" |
| **Silence timeout**   | Seconds of silence before auto-ending  | 30 seconds                        |
| **Max call duration** | Maximum call length before auto-ending | None (unlimited)                  |
| **Post-call webhook** | URL to notify after the call ends      | None                              |

4. Click **Save**.

### Via the API

```bash theme={null}
curl -X PATCH https://api.thinnest.ai/agents/agent_abc123 \
  -H "Authorization: Bearer $THINNESTAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "voice_tools": {
      "end_call": {
        "enabled": true,
        "farewell_message": "Thanks for calling Acme Corp! Have a great day.",
        "silence_timeout_seconds": 30,
        "max_duration_seconds": 600,
        "post_call_webhook": "https://your-app.com/webhooks/call-ended"
      }
    }
  }'
```

## System Prompt Guidance

Add instructions to your agent's system prompt to control when it should end calls:

```
When the caller's issue is resolved and they confirm they don't need anything else,
say a brief goodbye and end the call. If the caller says "goodbye", "that's all",
or "thanks, bye", end the call immediately after a brief farewell.

Do not end the call if the caller still has questions or seems uncertain.
```

## Post-Call Webhook

When a call ends, thinnestAI sends a webhook to your configured URL with the call summary:

```json theme={null}
{
  "event": "call.ended",
  "call_id": "call_xyz789",
  "agent_id": "agent_abc123",
  "duration_seconds": 145,
  "end_reason": "agent_ended",
  "transcript_url": "https://api.thinnest.ai/calls/call_xyz789/transcript",
  "recording_url": "https://api.thinnest.ai/calls/call_xyz789/recording"
}
```

The `end_reason` field indicates why the call ended:

| Reason            | Description                                   |
| ----------------- | --------------------------------------------- |
| `agent_ended`     | Agent triggered End Call                      |
| `caller_hangup`   | Caller disconnected                           |
| `silence_timeout` | No speech detected for the configured timeout |
| `max_duration`    | Call reached the maximum duration limit       |
| `error`           | Technical error during the call               |
