Skip to main content

SIP Trunking quickstart

Get your first SIP Trunking calls working using Dynamic SIP Trunking APIs.

  • Make outbound calls from your SIP system to PSTN
  • Receive inbound calls from PSTN to your SIP system

Prerequisites

  • Exotel account with KYC completed
  • API Key, API Token, Account SID
  • At least one Exophone (DID)
  • SIP system (PBX / SBC / contact centre) with public IP or digest credentials, TCP or TLS
  • Firewall ready — see Network & firewall
export EXOTEL_API_KEY="your_api_key"
export EXOTEL_API_TOKEN="your_api_token"
export EXOTEL_ACCOUNT_SID="your_account_sid"
# India: api.in.exotel.com · Singapore: api.exotel.com
export EXOTEL_SUBDOMAIN="api.in.exotel.com"

Step 1 — Create SIP trunk

curl -s -u "$EXOTEL_API_KEY:$EXOTEL_API_TOKEN" -X POST \
"https://$EXOTEL_SUBDOMAIN/v2/accounts/$EXOTEL_ACCOUNT_SID/trunks" \
-H "Content-Type: application/json" \
-d '{
"trunk_name": "my_trunk",
"nso_code": "ANY-ANY",
"domain_name": "'"$EXOTEL_ACCOUNT_SID"'.pstn.exotel.com"
}'

Try It

Save trunk_sid.

Step 2 — Map phone number

curl -s -u "$EXOTEL_API_KEY:$EXOTEL_API_TOKEN" -X POST \
"https://$EXOTEL_SUBDOMAIN/v2/accounts/$EXOTEL_ACCOUNT_SID/trunks/<trunk_sid>/phone-numbers" \
-H "Content-Type: application/json" \
-d '{
"phone_number": "+919876543210",
"mode": "pstn"
}'

Default mode is pstn. Save the numeric id from the response.

Try It

Step 3a — Whitelist IP (outbound)

Required when your system has a static egress IP.

curl -s -u "$EXOTEL_API_KEY:$EXOTEL_API_TOKEN" -X POST \
"https://$EXOTEL_SUBDOMAIN/v2/accounts/$EXOTEL_ACCOUNT_SID/trunks/<trunk_sid>/whitelisted-ips" \
-H "Content-Type: application/json" \
-d '{ "ip": "<your_public_ip>", "mask": 32 }'

Try It

Step 3b — Digest credentials (optional)

Use for cloud platforms with dynamic IPs.

curl -s -u "$EXOTEL_API_KEY:$EXOTEL_API_TOKEN" -X POST \
"https://$EXOTEL_SUBDOMAIN/v2/accounts/$EXOTEL_ACCOUNT_SID/trunks/<trunk_sid>/credentials" \
-H "Content-Type: application/json" \
-d '{
"user_name": "SIP_USER",
"password": "SIP_PASS",
"friendly_name": "voice_ai_platform"
}'

Try It

Step 4 — Destination URI (inbound)

# IP (must be whitelisted if using IP auth)
curl -s -u "$EXOTEL_API_KEY:$EXOTEL_API_TOKEN" -X POST \
"https://$EXOTEL_SUBDOMAIN/v2/accounts/$EXOTEL_ACCOUNT_SID/trunks/<trunk_sid>/destination-uris" \
-H "Content-Type: application/json" \
-d '{
"destinations": [
{ "destination": "<your_public_ip>:5061;transport=tls" }
]
}'

Or FQDN (no IP whitelist required for destination):

curl -s -u "$EXOTEL_API_KEY:$EXOTEL_API_TOKEN" -X POST \
"https://$EXOTEL_SUBDOMAIN/v2/accounts/$EXOTEL_ACCOUNT_SID/trunks/<trunk_sid>/destination-uris" \
-H "Content-Type: application/json" \
-d '{
"destinations": [
{ "destination": "sip.yourcompany.com:5061;transport=tls" }
]
}'

Try It

Step 5 — Flow with Connect applet (inbound)

  1. App Bazaar → create a flow
  2. Add Connect applet
  3. Dial Whom: sip:<trunk_sid>
  4. Map your Exophone to this flow

Path: PSTN → Exotel DID → Flow (Connect) → SIP trunk → Destination URI → your SIP

Details: Connect Applet for inbound SIP

Step 6 — Configure your SIP system

SettingValue
SIP Domain<account_sid>.pstn.exotel.com
Port443 (TLS) or 5070 (TCP)
TransportTLS (recommended) or TCP
AuthenticationIP ACL and/or digest credentials

Open RTP UDP 10000–40000.

Step 7 — Test

DirectionTest
OutboundDial any PSTN number from your SIP system
InboundCall your Exophone from a mobile

Mode clarification

Flow typePhone number mode
Connect applet (sip:<trunk_sid>)pstn
Voicebot / other App Bazaar appletsflow

Destination URI is required in all cases.

Next