Skip to content

Commit 5ba0092

Browse files
committed
docs: clarify Twilio inbound SIP gateways
1 parent 84724c5 commit 5ba0092

2 files changed

Lines changed: 68 additions & 12 deletions

File tree

‎fern/advanced/sip/sip-twilio.mdx‎

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ This guide walks you through setting up both outbound and inbound SIP trunking b
6666

6767
2. **Create a SIP Trunk Credential**
6868

69-
Use the following API call to create a SIP trunk credential, replacing the gateway IP with your Twilio Termination SIP URI:
69+
Use the following API call to create a SIP trunk credential. Configure the
70+
Twilio termination hostname as an outbound-only gateway. Configure Twilio's
71+
published signaling networks as separate inbound-only gateways.
72+
73+
The example below uses a Dublin termination hostname with Twilio's Ireland
74+
and Frankfurt signaling networks:
7075

7176
```bash
7277
curl -X POST https://api.vapi.ai/credential \
@@ -77,13 +82,48 @@ This guide walks you through setting up both outbound and inbound SIP trunking b
7782
"name": "Twilio Trunk",
7883
"gateways": [
7984
{
80-
"ip": "YOUR_TWILIO_GATEWAY_ID",
81-
"inboundEnabled": false
85+
"ip": "YOUR_TRUNK_NAME.pstn.dublin.twilio.com",
86+
"port": 5060,
87+
"inboundEnabled": false,
88+
"outboundEnabled": true
89+
},
90+
{
91+
"ip": "54.171.127.192",
92+
"netmask": 30,
93+
"port": 5060,
94+
"inboundEnabled": true,
95+
"outboundEnabled": false
96+
},
97+
{
98+
"ip": "35.156.191.128",
99+
"netmask": 30,
100+
"port": 5060,
101+
"inboundEnabled": true,
102+
"outboundEnabled": false
82103
}
83104
],
84105
"outboundLeadingPlusEnabled": true
85106
}'
86107
```
108+
109+
<Warning>
110+
Replace the example hostname and networks with the values for your Twilio
111+
trunk's selected edges. Add every primary and failover signaling network
112+
that can originate calls. Use Twilio's current [Elastic SIP Trunking IP
113+
address list](https://www.twilio.com/docs/sip-trunking/ip-addresses) as the
114+
source of truth.
115+
</Warning>
116+
117+
A termination hostname can be used for outbound routing because Vapi
118+
resolves it when placing a call. It cannot identify inbound traffic: Vapi
119+
must match the source of an incoming SIP request against a numeric IPv4
120+
network. The `netmask` value represents the CIDR prefix, so a `/30` network
121+
is configured as `"netmask": 30`.
122+
123+
If you are adding inbound gateways to an existing credential, send a
124+
`PATCH /credential/YOUR_CREDENTIAL_ID` request with the complete `gateways`
125+
array, including the existing outbound gateway and the new inbound
126+
networks.
87127

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

@@ -158,3 +198,10 @@ This guide walks you through setting up both outbound and inbound SIP trunking b
158198
- In the assistant settings, link it to the phone number you created
159199

160200
Now when someone calls your Twilio number, the call will be routed to your Vapi assistant.
201+
202+
<Note>
203+
If inbound calls do not reach Vapi, verify that the credential includes the
204+
numeric Twilio signaling networks for every origination edge you configured.
205+
Adding only the Twilio termination hostname enables outbound routing but does
206+
not allowlist inbound SIP traffic.
207+
</Note>

‎fern/advanced/sip/troubleshoot-sip-trunk-credential-errors.mdx‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,17 @@ Look at your gateway configuration. If `inboundEnabled` is `true` (or omitted, s
5050

5151
You have two options depending on whether you need inbound calling:
5252

53-
**If you need inbound calling**, resolve the hostname to its IPv4 address:
53+
**If you need inbound calling**, use the source signaling networks published by
54+
your SIP provider. Providers can use different addresses for outbound routing
55+
and inbound signaling, so do not assume that resolving an outbound hostname
56+
returns the addresses that will originate inbound calls.
5457

5558
<Steps>
56-
<Step title="Look up the IP address">
59+
<Step title="Find the provider's signaling networks">
5760

58-
Run one of the following commands to resolve your SIP provider's hostname to an IPv4 address:
61+
Check your provider's SIP trunking documentation for its inbound signaling IP
62+
addresses or CIDR ranges. If your provider explicitly documents a stable
63+
hostname as the source of inbound traffic, you can resolve it with:
5964

6065
```bash title="Terminal"
6166
dig +short sip.example.com A
@@ -65,23 +70,26 @@ dig +short sip.example.com A
6570
nslookup sip.example.com
6671
```
6772

68-
This returns one or more IPv4 addresses, for example `203.0.113.10`.
73+
This returns one or more IPv4 addresses, for example `203.0.113.10`. Include
74+
all primary and failover networks that can originate calls.
6975

7076
</Step>
7177

7278
<Step title="Use the resolved IP in your API request">
7379

74-
Replace the hostname with the numeric IPv4 address in your gateway configuration:
80+
Represent each provider network as a numeric IPv4 network address and, for a
81+
CIDR range, set `netmask` to its prefix length:
7582

7683
```json title="Gateway configuration"
7784
{
7885
"provider": "byo-sip-trunk",
7986
"name": "my sip trunk",
8087
"gateways": [
8188
{
82-
"ip": "203.0.113.10",
89+
"ip": "203.0.113.8",
90+
"netmask": 30,
8391
"port": 5060,
84-
"outboundEnabled": true,
92+
"outboundEnabled": false,
8593
"inboundEnabled": true
8694
}
8795
]
@@ -92,8 +100,9 @@ Replace the hostname with the numeric IPv4 address in your gateway configuration
92100
</Steps>
93101

94102
<Note>
95-
If your provider's IP address changes, you need to update the gateway
96-
configuration with the new address.
103+
In this example, `203.0.113.8/30` is written as `"ip": "203.0.113.8"` and
104+
`"netmask": 30`. If your provider changes its signaling networks, update the
105+
gateway configuration to match.
97106
</Note>
98107

99108
**If you only need outbound calling**, you can keep the hostname and disable inbound:

0 commit comments

Comments
 (0)