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

# Handoffs

> Configure SIP call transfers for voice agents using handoff definitions in the PolyAI ADK.

Handoffs configure SIP call transfers for voice agents. They define how and where a call should be transferred, or whether it should be ended.

> [!NOTE]
>
> **Enterprise feature**
>
> Handoffs require an enterprise Agent Studio account.

Handoffs are used when an agent needs to escalate, transfer, or terminate a voice interaction in a controlled way.

## Location

Handoffs are defined in:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
config/handoffs.yaml
```

They are listed under the `handoffs` key.

## What a handoff contains

Each handoff includes the following fields:

| Field | Description |
| - | - |
| `name` | Identifier for the handoff, up to 100 characters. Referenced in rules as `{{ho:handoff_name}}`. |
| `description` | Explains what the handoff does, up to 300 characters. |
| `is_default` | Whether this is the default handoff. |
| `sip_config` | Transfer method configuration. |
| `sip_headers` | Optional custom SIP headers as key/value pairs. |

## SIP config types

A handoff uses one of three SIP methods:

| Method | Use | Fields |
| - | - | - |
| `invite` | Start an outbound new call | `phone_number`, `outbound_endpoint`, `outbound_encryption` |
| `refer` | Transfer an existing call | `phone_number` |
| `bye` | End the call | No extra fields |

### Notes

* `phone_number` should use **E.164 format**
* `outbound_encryption` can be `TLS/SRTP` or `UDP/RTP`

## Validation

* `name` is required and at most 100 characters. `description` is at most 300 characters.
* `sip_config.method` must be one of `invite`, `refer`, or `bye`.
* For `invite`, `outbound_encryption` must be `TLS/SRTP` or `UDP/RTP`.
* `phone_number` (for `invite` and `refer`) and `outbound_endpoint` (for `invite`) are at most 100 characters each.
* Each `sip_headers` entry needs a text `key` and `value`.
* A SIP header `key` is at most 100 letters, digits or `!#$%&'*+-.^_~`.
* A SIP header `value` is at most 1,000 printable ASCII characters.
* Across all handoffs in `config/handoffs.yaml`, exactly one must have `is_default: true` — zero or more than one default handoff fails validation.
* Each handoff `name` must be unique.

## Example

```yaml theme={"theme":{"light":"github-light","dark":"github-dark"}}
handoffs:
  - name: escalation_handoff
    description: Transfer to a live agent for complex issues
    is_default: false
    sip_config:
      method: refer
      phone_number: "+15551234567"
    sip_headers:
      - key: X-Reason
        value: escalation

  - name: end_call
    description: End the call gracefully
    is_default: false
    sip_config:
      method: bye
```

## How handoffs are used

> [card] In code
>
> Call a handoff directly with `conv.call_handoff(...)`.

> [card] In rules
>
> Refer to a handoff using `{{ho:handoff_name}}`.

> [card] In topics and flows
>
> Instruct the model to call a function that performs the handoff.

## In code

You can trigger a handoff directly in code:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
conv.call_handoff(destination="handoff_name", reason="transfer_reason")
```

## In rules

A handoff can be referenced in `rules.txt` using:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
{{ho:handoff_name}}
```

This is useful when rules need to explain when escalation or transfer should happen.

## In topics and flows

Topics and flows should generally not perform raw transfer logic directly in prompt text. Instead, they should guide the model toward calling a function that performs the handoff.

For example:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
Use {{fn:transfer_call}} when the user needs to be transferred to a specialist.
```

## Best practices

* use clear, descriptive handoff names
* use E.164 format for phone numbers
* create one handoff definition per transfer purpose
* keep `sip_headers` minimal
* only add custom SIP headers when the receiving system actually requires them

> [!TIP]
>
> **One purpose per handoff**
>
> Avoid reusing a single handoff for multiple destinations or business cases. Clear handoff names make rules and code easier to understand.

## Related pages

> [card] [Functions](https://docs.poly.ai/adk/reference/resources/functions.md)
>
> See how handoffs are typically triggered from deterministic logic.

> [card] [Agent settings](https://docs.poly.ai/adk/reference/resources/agent_settings.md)
>
> Learn how handoffs are referenced in rules.

> [card] [Conversation object reference (platform)](https://docs.poly.ai/tools/classes/conv-object.md)
>
> Full reference for `conv.call_handoff` — destination, reason, utterance, and SIP header overrides.
