In this tutorial, we’ll guide you through connecting a custom telephony provider to Vapi.

1. Prerequisites

  1. Vapi team will provide you with sbcConfiguration. Example:
"sbcConfiguration": {
  apiUrl: '<https://example-url.com>',
  serviceProviderId: 'example-service-provider-id',
  serviceProviderApiKey: 'example-api-key',
  accountId: 'example-account-id',
  accountApiKey: 'example-account-api-key',
  applicationId: 'example-application-id',
}
  1. You need to have the gateways you want to connect to. Example:
"gateways": [
    {
        "ip": "192.168.12.81",
        "port": 5060,
        "inboundEnabled": true,
        "outboundEnabled": true
    },
    {
        "ip": "192.168.12.80",
        "port": 5060,
        "inboundEnabled": true,
        "outboundEnabled": true
    }
],

2. Trigger the Outbound Call from Vapi

  1. Create a SIP Trunk Credential

To initiate outbound SIP calls, you first need to create a SIP trunk credential. This credential will serve as the foundation for establishing the connection between Vapi and your SIP provider.

curl -X POST <https://api.vapi.ai/credential> \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer your-private-key" \\
-d '{
    "provider": "byo-sip-trunk",
    "name": "My Custom Trunk",
    "sbcConfiguration": // sbcConfiguration from 1a.
    "gateways": // gateways from 1b.
}'

This step sets up the SIP trunk credential, linking your telephony infrastructure with Vapi.

  1. Create a Phone Number Associated with the SIP Trunk

Once the SIP trunk credential is created, the next step is to create a phone number that will be associated with this SIP trunk. This phone number will be used to make outbound calls through the configured SIP trunk.

curl -X POST <https://api.vapi.ai/phone-number> \\
-H "Content-Type: application/json" \\
-H "Authorization: Bearer your-private-key" \\
-d '{
    "provider": "byo-phone-number",
    "name": "SIP Number on My Custom Trunk",
    "number": "your-sip-phone-number",
    "numberE164CheckEnabled": false,
    "credentialId": "your-credential-id-which-you-got-from-previous-step"
}'

This step creates a phone number that is directly associated with your SIP trunk, enabling you to manage and utilize it for outbound calls.

3. Start Making Calls

The phone number will be appeared in your dashboard you can trigger the call directly or if you want to trigger the call via API you can use that phone-number-id and trigger it.