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

# Make outbound calls through a SIP trunk

> Switch a Bolna agent to the SIP Trunk telephony provider and place calls, one at a time or in batches, from your own trunk numbers through your carrier.

An agent places calls through your trunk when its telephony provider is **SIP Trunk** and the call's caller ID is one of the trunk's numbers. Bolna sends the call to your carrier's gateway, and your carrier carries it to the person you are calling.

## Before you begin

* The trunk has at least one gateway and one number. See [Connect your carrier](/docs/sip-trunking/connect-carrier).
* Your carrier accepts calls from Bolna: it allowlists `15.252.21.46` and `13.206.230.198`, or the trunk has the carrier credentials it issued.
* The trunk is enabled. A disabled trunk places no calls.

## Switch the agent to the trunk

<Steps>
  <Step title="Set the telephony provider">
    Open the agent and go to the **Calling** tab. Under **Call Configuration**, set **Telephony Provider** to **SIP Trunk**. The option appears once your account has a trunk. If your account also has a legacy SIP trunk, that one is listed as **SIP Trunk (previous)**.

    <Frame caption="Telephony Provider set to SIP Trunk">
      <img src="https://mintcdn.com/bolna-54a2d4fe/7dEowS9LSMkFi965/images/sip-trunks/agent-telephony-provider-sip-trunk.png?fit=max&auto=format&n=7dEowS9LSMkFi965&q=85&s=ef9983481dd0822e7ef81522fe2ab19c" alt="Agent Calling tab, Call Configuration card, with the Telephony Provider dropdown open and SIP Trunk selected" width="1828" height="656" data-path="images/sip-trunks/agent-telephony-provider-sip-trunk.png" />
    </Frame>
  </Step>

  <Step title="Place a call">
    Open the agent's outbound call dialog. The caller ID list reads **Select a phone number**; pick one of your trunk numbers. Enter the number to call and click **Place call**. A SIP Trunk agent always needs a trunk number as its caller ID, so the dialog does not offer Bolna's shared number.
  </Step>
</Steps>

For a [batch](/docs/outbound/batch-calling), choose the SIP Trunk agent; the caller ID list then shows only your trunk numbers.

## How the call goes out

1. Bolna queues the call. Each trunk has its own place in the queue, and a call leaves it only when the trunk has a free channel. When every channel is busy, calls wait instead of failing, and one busy trunk does not hold up calls on another.
2. Bolna sends the INVITE to the trunk's gateways in priority order. A gateway that times out, answers `408` or `478`, or answers with a `5xx` is skipped for the next one.
3. The phone rings for up to 60 seconds. A busy line or no answer ends the call as `busy` or `no-answer`.
4. Once answered, the agent talks until the call ends or reaches the agent's maximum call duration.

What the carrier receives:

| | Value |
| - | - |
| Caller ID | The trunk number, in E.164 with the `+` |
| Number called | Digits only, or `+` and digits when **Dial with leading plus** is on for the trunk |
| Transport | The trunk's transport, UDP or TCP, from `15.252.21.46` |
| Codecs | The trunk's codecs, `PCMU`, `PCMA` or both |
| Authentication | The trunk's carrier credentials, sent when the carrier challenges with `401` or `407` |
| Extra headers | `X-CLIENT-CALL-ID` (the Bolna execution ID), `X-TRUNK` (the trunk ID), and any [headers you set on the agent](/docs/sip-trunking/sip-headers#outbound-header-templates) |

The execution ID in `X-CLIENT-CALL-ID` lets you match your carrier's records to Bolna's Call History.

## Using the API

Set the agent's provider with the [agent PATCH](/docs/api-reference/agent/v2/patch_update) endpoint, then place calls with [Make call](/docs/api-reference/calls/make). Always send `from_phone_number`: without it, Bolna uses your account's default number, which is not on your trunk, and the call fails.

<CodeGroup>
  ```bash Switch the agent to the trunk theme={"system"}
  curl -X PATCH https://api.bolna.ai/v2/agent/<agent_id> \
    -H "Authorization: Bearer <api_key>" \
    -H "Content-Type: application/json" \
    -d '{
      "agent_config": {
        "telephony_provider": "trunk"
      }
    }'
  ```

  ```bash Place a call theme={"system"}
  curl -X POST https://api.bolna.ai/call \
    -H "Authorization: Bearer <api_key>" \
    -H "Content-Type: application/json" \
    -d '{
      "agent_id": "<agent_id>",
      "recipient_phone_number": "+919876543210",
      "from_phone_number": "+918045678901",
      "user_data": {
        "customer_name": "Asha"
      }
    }'
  ```
</CodeGroup>

```json Response theme={"system"}
{
  "message": "done",
  "status": "queued",
  "execution_id": "b7140255-af33-4608-8e97-04dd944b8e48"
}
```

`telephony_provider` is `trunk` for these trunks; `sip-trunk` is the [legacy SIP trunk](/docs/sip-trunking/introduction) provider. `from_phone_number` matches a trunk number with or without the `+`. For batches, pass your trunk numbers in `from_phone_numbers` when you [create the batch](/docs/api-reference/batches/create).

Track the call with [Get execution](/docs/api-reference/executions/get_execution), or list the trunk's recent outbound calls with [List calls](/docs/api-reference/trunks/list_calls) and `direction=outbound`.

## When a call fails

A call that never connects is marked failed, with one of these errors on the execution. The trunk's **Activity** tab shows the SIP code and cause for calls the carrier refused.

| Error | Cause |
| - | - |
| `Calling from_number is not on an outbound-enabled trunk.` | The caller ID is not one of this account's trunk numbers, or its trunk is disabled. |
| `Trunk has no gateway to dial through.` | Add a gateway on the trunk's **Connection** tab. |
| `gateway did not resolve to a dialable address` | The gateway's DNS name did not resolve to a public IPv4 address. |
| A SIP code and cause, such as `403` | Your carrier refused the call. See [Troubleshooting](/docs/sip-trunking/troubleshooting#outbound-calls-fail). |

## Next steps

<CardGroup cols={2}>
  <Card title="SIP headers" icon="tag" href="/docs/sip-trunking/sip-headers">
    Send your own headers on every outbound INVITE.
  </Card>

  <Card title="Call transfer" icon="phone-arrow-right" href="/docs/sip-trunking/call-transfer">
    Hand a live call to a person through the trunk.
  </Card>
</CardGroup>


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