# Vapi

Use a Vonyx SIP trunk and number as a bring-your-own SIP trunk for Vapi assistants.

Connect a Vonyx SIP trunk to Vapi so your Vapi assistants can call out from, and answer calls on, your Vonyx +91 number. Vapi calls this a BYO SIP trunk. You can set it up in the Vapi dashboard or through the Vapi API.

## Before you start

- A Vonyx [SIP trunk](/docs/console/sip-trunks) with a [number](/docs/console/numbers) attached, and the trunk's username and password
- A Vapi account with at least one assistant
- For the API path: your Vapi private API key

<Callout title="Use the US Vapi region">
This guide uses `https://api.vapi.ai` and `sip.vapi.ai`. Vapi's EU region uses `https://api.eu.vapi.ai` and `sip.eu.vapi.ai`; Vapi says the API base and the SIP host must be in the same region.
</Callout>

## Outbound calls

<Steps>
<Step>

### Create the SIP trunk credential

Vapi stores the trunk as a credential. Add one gateway for Vonyx with inbound and outbound both on, so the same credential can be used for inbound calls later.

| Field | Value |
| --- | --- |
| Gateway IP | `43.204.9.41` |
| Port | `5060` |
| Netmask | `32` |
| Transport | UDP (Vonyx has no TLS) |
| Allow inbound calls | On (off if you only need outbound) |
| Allow outbound calls | On |
| Authentication username | `your_trunk_username` |
| Authentication password | `your_trunk_password` |
| SIP registration | Off |

<Tabs items={['Dashboard', 'API']}>
<Tab value="Dashboard">

1. Open the organization menu in the top left and choose **Settings**.
2. Open **Integrations** and select **SIP Trunk**.
3. Click **Configure New SIP Trunk**.
4. Name the trunk (for example, `Vonyx`) and add a gateway with the values in the table above.
5. Turn on **Allow inbound calls** and **Allow outbound calls**.
6. Under **Authentication**, enter your Vonyx trunk username and password. Leave SIP registration off.
7. Save the trunk.

</Tab>
<Tab value="API">

```bash title="Create the credential"
curl -X POST https://api.vapi.ai/credential \
  -H "Authorization: Bearer YOUR_VAPI_PRIVATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "byo-sip-trunk",
    "name": "Vonyx",
    "gateways": [
      {
        "ip": "43.204.9.41",
        "port": 5060,
        "netmask": 32,
        "inboundEnabled": true,
        "outboundEnabled": true,
        "outboundProtocol": "udp"
      }
    ],
    "outboundLeadingPlusEnabled": false,
    "outboundAuthenticationPlan": {
      "authUsername": "your_trunk_username",
      "authPassword": "your_trunk_password"
    }
  }'
```

`outboundLeadingPlusEnabled: false` makes Vapi dial `91XXXXXXXXXX` with no leading `+`, which is the format Vonyx expects.

Save the `id` from the response. This is your credential ID.

</Tab>
</Tabs>

</Step>
<Step>

### Import your Vonyx number

Vonyx numbers are written `91XXXXXXXXXX`, without a `+`, so turn off Vapi's E.164 check for this number.

<Tabs items={['Dashboard', 'API']}>
<Tab value="Dashboard">

1. Go to **Phone Numbers** and click **Create Phone Number**.
2. Select **BYO SIP Trunk Number**.
3. Enter your Vonyx number as `91XXXXXXXXXX` and turn on **Allow non-E164 phone numbers**.
4. Select the `Vonyx` credential you created, optionally add a label, and click **Import SIP Phone Number**.

</Tab>
<Tab value="API">

```bash title="Import the number"
curl -X POST https://api.vapi.ai/phone-number \
  -H "Authorization: Bearer YOUR_VAPI_PRIVATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "byo-phone-number",
    "name": "Vonyx",
    "number": "91XXXXXXXXXX",
    "numberE164CheckEnabled": false,
    "credentialId": "YOUR_CREDENTIAL_ID"
  }'
```

Save the `id` from the response. This is your phone number ID.

</Tab>
</Tabs>

</Step>
<Step>

### Place a call

The caller ID is the Vonyx number you imported. Vonyx only accepts calls whose caller ID is one of your Vonyx numbers.

```bash title="Start an outbound call"
curl -X POST https://api.vapi.ai/call \
  -H "Authorization: Bearer YOUR_VAPI_PRIVATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "assistantId": "YOUR_ASSISTANT_ID",
    "phoneNumberId": "YOUR_PHONE_NUMBER_ID",
    "customer": {
      "number": "91XXXXXXXXXX",
      "numberE164CheckEnabled": false
    }
  }'
```

`customer.numberE164CheckEnabled` defaults to `true`, which only accepts numbers like `+91XXXXXXXXXX`. Set it to `false` to dial `91XXXXXXXXXX`.

</Step>
</Steps>

## Inbound calls

<Steps>
<Step>

### Check the credential allows inbound

The Vonyx gateway in your credential must have inbound turned on (**Allow inbound calls** in the dashboard, `"inboundEnabled": true` in the API). Vapi only accepts inbound SIP from gateway IPs in the credential, and Vonyx sends inbound calls from `43.204.9.41`.

</Step>
<Step>

### Pick the assistant

<Tabs items={['Dashboard', 'API']}>
<Tab value="Dashboard">

Go to **Phone Numbers**, open your Vonyx number, select an assistant under **Inbound Settings**, and click **Save**.

</Tab>
<Tab value="API">

Pass `assistantId` when you import the number:

```bash title="Import the number with an inbound assistant"
curl -X POST https://api.vapi.ai/phone-number \
  -H "Authorization: Bearer YOUR_VAPI_PRIVATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "provider": "byo-phone-number",
    "name": "Vonyx",
    "number": "91XXXXXXXXXX",
    "numberE164CheckEnabled": false,
    "credentialId": "YOUR_CREDENTIAL_ID",
    "assistantId": "YOUR_ASSISTANT_ID"
  }'
```

</Tab>
</Tabs>

</Step>
<Step>

### Point Vonyx at Vapi

Vapi expects inbound calls at `{phoneNumber}@YOUR_CREDENTIAL_ID.sip.vapi.ai`. In the Vonyx console, open the trunk, turn on **Inbound calls** and set **Inbound address** to the host part only:

```text title="Inbound address"
YOUR_CREDENTIAL_ID.sip.vapi.ai
```

Use the credential ID from the first step. Don't add `sip:` or a user part; Vonyx adds the dialled number. See [inbound calls](/docs/console/inbound-calls).

</Step>
</Steps>

## Test the connection

1. Run the **Place a call** request with your own mobile as `customer.number`. Your phone rings with your Vonyx number as caller ID, and the assistant speaks when you answer.
2. Call your Vonyx number from another phone. The assistant you picked under **Inbound Settings** answers.
3. If either fails, check the call logs in Vapi and [SIP troubleshooting](/docs/sip/troubleshooting).

## Limitations

- DTMF and call transfer are not available on Vonyx yet. Vapi's SIP transfers use SIP REFER, so don't add Vapi transfer tools that point at this trunk.
- New accounts make 1 call at a time ([raise limits](/docs/sip/limits)).
- Vonyx has no TLS or SRTP, so keep the gateway's outbound protocol on UDP (or TCP). Don't pick `tls` or `tls/srtp`.
- Vonyx supports only the PCMU and PCMA codecs.

## Troubleshooting

| Problem | Fix |
| --- | --- |
| "Couldn't validate SIP trunk credential. SIP gateway creation failed." | Vapi needs a numeric IPv4 address on an inbound gateway. Use `43.204.9.41` as the gateway IP, not a hostname. |
| Outbound call fails with 401 or 403 | Check the trunk username and password under **Authentication** (`outboundAuthenticationPlan`). |
| Outbound call is rejected for its number format | Set `outboundLeadingPlusEnabled` to `false` and dial `91XXXXXXXXXX`. |
| Vapi rejects `customer.number` | Set `customer.numberE164CheckEnabled` to `false`, or dial `+91XXXXXXXXXX`. |
| Inbound call gets 401 or isn't answered | Make sure the Vonyx gateway has **Allow inbound calls** on, the inbound address uses the right credential ID, and an assistant is set under **Inbound Settings**. |
| Call connects but there's no audio | Vapi sends media on UDP ports 40000–60000 from changing IPs in the US region; make sure nothing on your side blocks RTP. See [SIP connection details](/docs/sip). |
