SIP Trunking Explained for Developers

SIP trunking connects IP communications infrastructure to the PSTN using the Session Initiation Protocol, letting developers route inbound and outbound calls over broadband. This guide covers how SIP trunks work,...
SIP trunking carrying three concurrent phone channels into a single FreJun Teler trunk.
In this article

AI Summary: This article explains SIP trunking for backend and API integration engineers who need to understand how PSTN connectivity works before building or evaluating voice infrastructure in 2026. Twilio’s Elastic SIP Trunking documentation lists G.711 μ-law (PCMU) and A-law (PCMA) as its default codecs, and SIP signaling runs over UDP or TCP on port 5060, with TLS on port 5061. Developers must supply their own SIP-enabled network element, manage IP access control lists, and handle NAT traversal before a trunk carries live calls. Teler sits above the SIP layer, exposing a WebSocket media stream and call control API so teams can wire AI models to live calls without building telephony infrastructure from scratch.

Scope: This walkthrough covers SIP trunking concepts, authentication models, codec requirements, and failure modes primarily as documented by Twilio Elastic SIP Trunking, with notes on Telnyx, verified against their public documentation in September 2026. It does not cover PBX-internal dial plan configuration or carrier-specific number porting procedures.

Quick Answer: SIP trunking is a carrier-facing SIP layer that connects IP communications infrastructure to the PSTN for inbound and outbound calls in 2026. Twilio’s implementation supports G.711 (PCMU and PCMA) by default and authenticates trunks with credential lists, IP access control lists, or both. Developers must supply a SIP-enabled network element such as a session border controller or PBX before the trunk carries traffic.

SIP trunking is the mechanism that connects an organization’s IP communications infrastructure to the public switched telephone network, replacing physical phone lines with a logical SIP channel over broadband. Understanding how SIP trunking works is essential before evaluating any programmable voice platform or AI phone agent stack in 2026.

What is SIP trunking?

SIP trunking is a carrier service that provides PSTN connectivity to IP-based communications infrastructure using the Session Initiation Protocol, defined in RFC 3261. It occupies the carrier interconnect layer: above the physical telephone network and below the application logic in a PBX, session border controller, or contact center platform. A SIP trunk carries call media but does not expose raw audio frames to application code; it routes calls, negotiates sessions, and relays RTP. Developers must supply their own SIP-enabled network element, manage firewall rules and IP access control lists, and handle NAT traversal before the trunk carries live traffic. Number provisioning, codec selection, and transport security are also the developer’s responsibility to configure.

SIP trunking split: developer-supplied SBC, ACLs and NAT versus FreJun Teler media streaming and call control.

Why is SIP trunking harder than it looks?

SIP trunking looks straightforward on paper: point a SIP endpoint at a carrier URI and start making calls. In practice, the protocol surface is wide. RFC 3261 alone runs to 269 pages, and a working trunk requires correct interaction between SIP signaling, RTP media transport defined in RFC 3550, DNS-based server discovery from RFC 3263, and optional SRTP encryption from RFC 3711.

The specific engineering constraints that catch teams are codec mismatch, authentication misconfiguration, and rate limiting. Twilio’s Elastic SIP Trunking defaults to 1 call per second (CPS) per trunk per region, which can be raised in the trunk’s Termination settings. Separately, Twilio caps traffic at 30 CPS from a single customer IP to a single Twilio IP; exceeding that rate can trigger network-level anti-abuse mechanisms. SIP OPTIONS keepalives must stay below one ping every 10 to 15 seconds, or Twilio may ban the source IP. These are not edge cases; they are the first things that break in a new integration.

How does the SIP trunking audio path work?

A SIP trunk call moves through four distinct hops. Understanding which layer owns each hop tells you where to look when something breaks.

HopProtocolFormatOwner
PSTN to carrier edgeSS7 / TDMG.711 PCM, 8 kHz, 8-bitCarrier
Carrier edge to SBC/PBXSIP + RTPG.711 (PCMU / PCMA), 8 kHzSIP trunk provider
SBC/PBX to applicationSIP, WebSocket, or proprietaryDepends on PBX codec configDeveloper
Application to AI modelWebSocket or HTTPModel-specific, often 16 kHz or 24 kHz PCMDeveloper

The codec boundary between hop 2 and hop 4 is where most AI voice integrations fail. The PSTN side almost always delivers narrowband 8 kHz G.711 audio. Most speech-to-text and text-to-speech models expect 16 kHz or 24 kHz PCM. The developer must resample in the application layer, and that resampling step adds latency. Teler’s streaming service handles much of this boundary: it accepts 8 kHz carrier audio and delivers the stream at either 8 kHz or 16 kHz over WebSocket, so STT engines that accept 16 kHz can consume it directly. Models that expect 24 kHz still need a resampling step, and upsampling doesn’t restore fidelity lost at 8 kHz.

SIP trunking call setup exchanging INVITE, 180 Ringing and 200 OK between carrier and FreJun Teler.

What do you need before configuring a SIP trunk?

  • A SIP trunk account with a provider such as Twilio or Telnyx, with credentials or a static IP for authentication
  • A SIP-enabled network element: a session border controller (SBC), IP-PBX such as Asterisk or FreeSWITCH, or a contact center platform
  • A provisioned DID (Direct Inward Dialing number) in E.164 format, for example +12025551234
  • Firewall rules that allow SIP signaling on UDP/TCP port 5060 or TLS port 5061, plus RTP media ports (typically UDP 10000 to 20000, but verify with your provider)
  • Sufficient internet bandwidth: Twilio documents peak bandwidth as Max Simultaneous Calls x 100 kbps
  • DNS resolution for the carrier’s termination URI, for example yourdomain.pstn.twilio.com, or a regional edge such as yourdomain.pstn.sydney.twilio.com
  • If using Teler above the SIP layer: a Teler account, an API key, and a WebSocket endpoint your server exposes for media streaming

How do you configure SIP trunking step by step?

Step 1: Create the trunk and set the termination URI

On Twilio, create an Elastic SIP Trunk in the console or via the REST API. The trunk gets a unique domain name. Set the termination SIP URI to the generic entry point or a geographic edge closest to your infrastructure. Using a regional edge reduces signaling round-trip time for call setup.

# Twilio REST API: create a trunk
curl -X POST https://trunking.twilio.com/v1/Trunks \
  -u "$TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN" \
  -d "FriendlyName=production-trunk"

The response includes a Sid field. Store it; you need it for every subsequent trunk configuration call. See the Teler documentation for how Teler maps its own SIP trunk configuration to incoming calls.

Step 2: Configure authentication

Twilio supports two authentication models: credential-based and IP access control list (IP ACL). Telnyx uses SIP Connections for inbound authentication and Outbound Voice Profiles for outbound routing. Choose IP ACL authentication when your SBC has a stable datacenter IP; it removes the credential exchange from the SIP handshake and reduces setup latency. Use credential authentication when your infrastructure IP changes or when you are testing from a development machine.

For IP ACL on Twilio, add each allowed source IP to the trunk’s IP Access Control List. Traffic from unlisted IPs receives a 403 Forbidden response. This is the most common cause of failed trunk setup in new deployments.

# Add an IP to the trunk's ACL
curl -X POST https://trunking.twilio.com/v1/Trunks/$TRUNK_SID/IpAccessControlLists \
  -u "$TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN" \
  -d "IpAccessControlListSid=$ACL_SID"

Verify the ACL is attached before sending a test INVITE. A missing ACL entry produces a 403 that looks identical to a credential failure.

Step 3: Configure origination for inbound calls

Origination URIs tell the carrier where to send inbound calls. On Twilio, set the origination URI to your SBC or PBX’s public SIP address. On Telnyx, configure the SIP Connection with your endpoint’s address. The carrier sends a SIP INVITE to this URI when a call arrives on your DID.

If you are routing inbound calls through Teler rather than directly to a PBX, set the origination URI to Teler’s SIP endpoint and configure your WebSocket handler to receive the media stream. The Teler SIP trunking documentation covers the exact origination URI format and credential configuration.

Step 4: Configure DTMF and keepalives

Twilio documents three DTMF relay methods: rtp-nte (RFC 2833, in-band RTP events), sip-kpml, and sip-notify. Most SBCs default to rtp-nte. Confirm your SBC and the carrier agree on the same method, or DTMF digits will not arrive at the application layer.

For SIP OPTIONS keepalives, send no more than one OPTIONS ping every 10 to 15 seconds. Twilio also recommends setting Max-Forwards to 70 on outbound requests. Sending OPTIONS more frequently than the documented rate can trigger anti-abuse rate limiting that silently drops subsequent INVITEs.

Step 5: Enable secure trunking

Twilio’s Secure Trunking uses SIP TLS on port 5061 for signaling and SRTP for media, with ICE and STUN for NAT traversal. Enable it when calls traverse untrusted networks or when compliance requirements mandate encrypted media. The operational cost is certificate management and cipher negotiation on your SBC. Not all SBC firmware versions support the cipher suites Twilio requires; check the vendor’s qualified configuration guide before enabling secure trunking in production.

Most teams discover their latency problem is not the model, it is the resampling hop they added between the carrier and the STT engine. The PSTN delivers 8 kHz G.711U audio, and when you insert a software resampler between the SIP edge and your speech model without buffering it correctly, you add 80 to 120 milliseconds before the model hears a single word. Teler targets sub-100ms packet delivery precisely because that resampling boundary is where conversational AI breaks down.

– Subhash Kalluri, Founder & CEO, FreJun

What breaks in SIP trunking production deployments?

The failure modes below come from documented issues in SIP infrastructure repositories and carrier best-practice guides. Frequency is noted honestly; most are single reported incidents, not systemic patterns.

SymptomCauseFix
SIP INVITE rejected with 403 ForbiddenSource IP not in ACL, or credential mismatchVerify ACL entries match the SBC’s public IP; confirm auth credentials are correct
One-way audio after call connectsNAT traversal failure; RTP media ports blocked by firewallOpen RTP port range on firewall; configure STUN or ICE on SBC
Calls drop after 30 secondsSIP re-INVITE or OPTIONS not reaching carrier; firewall stateful timeoutIncrease firewall UDP session timeout; confirm SIP ALG is disabled
TrunkID missing on inbound callsIncoming SIP INVITE omits leading plus on the number; number parsing failsNormalize all DIDs to E.164 format with leading plus before configuring origination
Auth credentials ignored on cloud SIP pathUnresolved; reported once in LiveKit SIP issue trackerNo fix reported; fall back to IP ACL authentication
SIP channels remain open after room teardownLifecycle cleanup bug between room shutdown and SIP channel shutdownNo fix reported; implement explicit BYE on room end event

The failure that catches the most teams is the 403 on first INVITE. It looks like a credential problem but is usually a missing ACL entry. When you provision a new SBC or change datacenter, the source IP changes and the ACL entry from the previous deployment no longer matches. Check the ACL before touching credentials.

One honest limitation of Teler’s SIP trunking layer: the documentation does not specify a maximum concurrent session count or a documented SLA for SIP call setup time. Teams with strict concurrency requirements should test at target load before committing to a production configuration, and should contact FreJun directly for capacity planning. The Top 9 Best SIP Trunking Providers in the US comparison covers how different carriers handle concurrency limits if you need to evaluate alternatives.

Which SIP trunking approach fits your architecture?

ApproachWhere media terminatesLatency costOperational burdenBest for
Direct SBC-to-carrier trunkCustomer SBCLow; no extra hopsHigh; firewall, NAT, ACL managementExisting voice infrastructure
Secure trunking with TLS and SRTPCustomer SBCLow to medium; TLS handshake adds setup timeHigh; certificate and cipher managementRegulated or untrusted network paths
IP-authenticated trunk, no registrationCustomer SBCLowMedium; static IP managementStable datacenter or SBC deployments
Edge-localized trunk with DNS/SRV routingNearest carrier edgeLow; geographic proximityMedium; DNS and failover complexityMulti-region or latency-sensitive systems
Programmable voice API above SIP (Teler)Provider edge, WebSocket to developer serverLow; sub-100ms targetLow; no SBC requiredAI phone agents, rapid prototyping

If you already operate a PBX or SBC, a direct trunk to Twilio or Telnyx is the right starting point. You own the media path and the routing logic, and you pay per-minute usage without a platform abstraction layer in between. If you are building an AI phone agent from scratch and do not want to operate SIP infrastructure, a programmable voice API like Teler removes the SBC requirement entirely. The trade-off is that you give up direct SIP-level control in exchange for a WebSocket media stream and a call control API. For teams building on top of frameworks like programmable SIP infrastructure for AI agents, the abstraction layer is worth the trade-off.

Frequently asked questions

What codec does SIP trunking use?

Twilio Elastic SIP Trunking supports G.711 in both μ-law (PCMU) and A-law (PCMA) by default, with G.729, Opus, and AMR-NB available on request. G.711 is the standard narrowband telephony codec defined in ITU-T G.711, operating at 8 kHz with 8-bit samples (64 kbps). If your AI model expects 16 kHz or 24 kHz audio, you must resample in your application layer or use a platform that handles the conversion, since the PSTN side will always deliver 8 kHz audio.

Why does my SIP trunk return 403 on the first INVITE?

A 403 Forbidden on the first INVITE almost always means the source IP is not in the trunk’s access control list. Check that the SBC’s public IP matches the ACL entry exactly, including any NAT translation. If you are using credential authentication instead of IP ACL, verify the authentication ID and password are correct and that the SIP INVITE includes the correct Authorization header. This failure mode is reported frequently in SIP infrastructure issue trackers.

When should I use SIP trunking instead of a WebSocket voice API?

Use SIP trunking directly when you already operate a PBX, SBC, or contact center platform that speaks SIP natively. The trunk connects your existing infrastructure to the PSTN without adding an abstraction layer. Use a WebSocket voice API like Teler when you are building an AI phone agent from scratch and do not want to operate SIP infrastructure. The WebSocket path gives you raw audio frames and call control events without requiring an SBC, but you give up direct SIP-level routing control.

What happens to SIP trunking under high call volume?

Twilio documents a ceiling of 30 calls per second from a single customer IP to a single Twilio IP. Exceeding that rate triggers network-level anti-abuse mechanisms that drop calls. To handle higher volumes, distribute traffic across multiple customer IPs and load-balance across Twilio’s infrastructure IP addresses. Bandwidth sizing follows the formula: peak bandwidth equals max simultaneous calls multiplied by 100 kbps. The documentation does not specify a maximum concurrent session count, so test at target load before production launch.

Does SIP trunking handle DTMF automatically?

No. DTMF relay requires explicit configuration. Twilio supports three methods: rtp-nte (RFC 2833 in-band RTP events), sip-kpml, and sip-notify. Your SBC and the carrier must agree on the same method, or DTMF digits will not reach your application. Most SBCs default to rtp-nte, which is the most widely compatible option. Teler exposes DTMF events through its call control API so you do not need to parse RTP events directly.

What must I build myself when using SIP trunking for AI voice?

When connecting a SIP trunk directly to an AI model, you must build the resampling pipeline from 8 kHz G.711U to whatever sample rate your model expects, a jitter buffer to smooth RTP packet timing, DTMF parsing if your application needs keypad input, and call lifecycle management including BYE handling and transfer logic. You also need to manage the SBC or PBX that terminates the SIP session. Platforms like Teler handle these layers so your application code starts at the WebSocket audio stream rather than the SIP edge.

Is SIP trunking the same as VoIP?

SIP trunking is a specific type of VoIP service. VoIP is the broader category of voice communication over IP networks. SIP trunking specifically refers to the carrier-facing SIP interconnect that connects IP infrastructure to the PSTN. Not all VoIP services use SIP; some use proprietary protocols. SIP trunking is the standard mechanism for connecting a PBX or SBC to the public telephone network in enterprise and developer contexts.

What SIP trunking means for your voice stack in 2026

Understanding SIP trunking gives you a clear picture of where the PSTN boundary sits in any voice architecture. With that picture, you can decide whether to own the SIP layer directly or abstract it away through a programmable voice API. The decision that matters most is whether you already operate SIP infrastructure: if you do, a direct trunk to a carrier like Twilio or Telnyx is the right path; if you are building an AI phone agent from scratch, the SIP layer is complexity you can skip.

For teams evaluating providers, the comparison of SIP trunking and elastic SIP trunking covers how the two models differ in practice. Teler’s programmable voice API sits above the SIP trunking layer and handles carrier connectivity, codec conversion, and media streaming so your application code works at the WebSocket and call control level rather than at the SIP edge. Check current Teler pricing to understand the cost model before committing to an architecture.

About the Author: Subhash Kalluri is the Founder & CEO of FreJun, which he has been building since 2019. With over 8 years in voice communication and SaaS, he works on the problem of getting real-time AI onto live phone calls: raw media streaming, interruption handling, and carrier connectivity. That work became FreJun Teler, FreJun’s programmable voice API for developers building AI phone agents. Connect with him on LinkedIn.

Get started with FreJun today

In this article

Make every voice interaction count

FreJun is a real-time voice platform for automating calls and connecting AI bots.

Popular Articles
Assemblyai.com vs Elevenlabs.io Feature by Feature Comparison for AI Voice Agents

In the quest to build truly intelligent and human-like AI voice agents, developers face two fundamental challenges: understanding what is...

Voice recognition software API running 24/7 across US, UK, India and Singapore time zones.

Quick Answer: To deploy a voice recognition API globally, run speech-to-text in multiple regions, route each caller to the nearest...

Add Voice Bot Conversational AI to Your Web Stack 1 3

Building real-time voice agents is no longer about stitching speech and text together. Modern voice systems expect natural turn-taking, fast...