> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.vapi.ai/llms.txt.
> For full documentation content, see https://docs.vapi.ai/llms-full.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.vapi.ai/_mcp/server.

# Twilio SIP Integration

<iframe src="https://www.youtube.com/embed/_wo5wokt3dI?si=72E1azM7tYv6TsBI" title="An embedded YouTube video titled &#x22;The Ultimate SIP Trunking Guide for AI Voice Agents | Twilio + Vapi&#x22;" frameborder="0" allow="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen referrerpolicy="strict-origin-when-cross-origin" />

This guide walks you through setting up both outbound and inbound SIP trunking between Twilio and Vapi. The steps are quite similar for other telephony providers.

## Outbound Calls (Twilio to Vapi)

### Twilio Configuration

1. **Create Elastic SIP Trunk**

   Log in to your Twilio account and create a new trunk, assigning it a name, and adjusting the general settings as needed.

   ![Twilio SIP Trunk](https://files.buildwithfern.com/https://vapi.docs.buildwithfern.com/e56a6e67e546296cdb02b7f6ad2a1dd378770db0b43c353cc3e64f1236ae5893/static/images/sip/sip-twilio-trunk.png)

2. **Set Up Termination (Outbound Calls)**

   Configure the termination settings. The termination SIP URI is crucial as it will be used in later steps.

   ![Termination SIP URI](https://files.buildwithfern.com/https://vapi.docs.buildwithfern.com/87c9ca9a5448e536330af3cc1db05570f0d3d51cfd55b08cd469d9f41e5a8aca/static/images/sip/sip-twilio-termination-uri.png)

   To allow your Elastic SIP Trunk to accept outbound requests, you need to whitelist IP addresses:

   ![IP Authentication](https://files.buildwithfern.com/https://vapi.docs.buildwithfern.com/25b8885f48e89ccf3dd2e183227ba260faa565836e805fa53b06524c8b4e497b/static/images/sip/sip-twilio-ip-authentication.png)

   Whitelist Vapi's SIP server static IPs:

   * 44.229.228.186
   * 44.238.177.138

   Ensure you whitelist the entire IP range as shown below:

   ![IP Whitelist 1](https://files.buildwithfern.com/https://vapi.docs.buildwithfern.com/28fc4f67da31cdaa1c6d966771b589247e782d2e1bcaa5ff50c196c502b39e74/static/images/sip/sip-twilio-ip-1.png)

   ![IP Whitelist 2](https://files.buildwithfern.com/https://vapi.docs.buildwithfern.com/f454aefcc0e7a46a54b94390d9bdca2f7524f6ba4e392f39f2aab10dfe4fa214/static/images/sip/sip-twilio-ip-2.png)

3. **Purchase or Move Numbers to Elastic SIP Trunk**

   After creating the Elastic SIP trunk, purchase new numbers or move existing numbers to this trunk.

   ![Number Attachment](https://files.buildwithfern.com/https://vapi.docs.buildwithfern.com/1e30eb19fd0a7d281fe9534466c4403e357602ecaceb34d4c328dce16c75fba4/static/images/sip/sip-twilio-number-attach.png)

### Vapi Configuration

1. **Retrieve Your Vapi API Key**

   Log in to your Vapi.ai account and retrieve your API key from the Organization Settings.

2. **Create a SIP Trunk Credential**

   Use the following API call to create a SIP trunk credential, replacing the gateway IP with your Twilio Termination SIP URI:

   ```bash
   curl -X POST https://api.vapi.ai/credential \
   -H "Content-Type: application/json" \
   -H "Authorization: Bearer YOUR_VAPI_API_KEY" \
   -d '{
     "provider": "byo-sip-trunk",
     "name": "Twilio Trunk",
     "gateways": [
       {
         "ip": "YOUR_TWILIO_GATEWAY_ID",
         "inboundEnabled": false
       }
     ],
     "outboundLeadingPlusEnabled": true
   }'
   ```

   Note the `id` (credentialId) from the response for the next step.

3. **Register Your Phone Number**

   Associate your Twilio number with the SIP trunk:

   ```bash
   curl -X POST https://api.vapi.ai/phone-number \
   -H "Content-Type: application/json" \
   -H "Authorization: Bearer YOUR_VAPI_API_KEY" \
   -d '{
     "provider": "byo-phone-number",
     "name": "Twilio SIP Number",
     "number": "YOUR_SIP_PHONE_NUMBER",
     "numberE164CheckEnabled": false,
     "credentialId": "YOUR_CREDENTIAL_ID"
   }'
   ```

   Note the phone number ID from the response for making calls.

4. **Make Outbound Calls**

   You can make outbound calls in two ways:

   **Using the Vapi Dashboard:**

   The phone number will appear in your dashboard. Select your assistant and enter the destination number you want to call.

   **Using the API:**

   ```bash
   curl --location 'https://api.vapi.ai/call/phone' \
   --header 'Authorization: Bearer YOUR_VAPI_API_KEY' \
   --header 'Content-Type: application/json' \
   --data '{
     "assistantId": "YOUR_ASSISTANT_ID",
     "customer": {
       "number": "DESTINATION_PHONE_NUMBER",
       "numberE164CheckEnabled": false
     },
     "phoneNumberId": "YOUR_PHONE_NUMBER_ID"
   }'
   ```

## Inbound Calls (Vapi to Twilio)

### Twilio Configuration

1. **Set Up Origination (Inbound Calls)**

   Navigate to the Origination section in your Twilio SIP Trunk settings.

   ![Origination Settings](https://files.buildwithfern.com/https://vapi.docs.buildwithfern.com/b78c16024555e4d1db5cf31228da93aa9ee318113889234f72a6a6a52453eb00/static/images/sip/sip-twilio-origination.png)

   Add your Vapi SIP URI in the following format: `sip:YOUR_PHONE_NUMBER@<credential_id>.sip.vapi.ai`, where "YOUR\_PHONE\_NUMBER" is your chosen SIP number that you will attach to this trunk.

   ![Origination Creation](https://files.buildwithfern.com/https://vapi.docs.buildwithfern.com/2f12aa7c277e8dfd92e3737522692b8cb8f2544707f8f87a1cfdcece4fdc0d93/static/images/sip/sip-twilio-origination-creation.png)

### Vapi Configuration

1. **Create and Configure a Vapi Assistant**

   * Create an assistant following the steps in our [Phone Quickstart](/quickstart/phone#create-your-first-voice-assistant)
   * In the assistant settings, link it to the phone number you created

   Now when someone calls your Twilio number, the call will be routed to your Vapi assistant.