Skip to Content

SIP trunks

Connect your carrier, PBX, or Twilio account so your agents can answer and place phone calls.

A trunk connects us to whoever carries your calls. You need one before you can put a phone number on an agent — the phone quickstart is the short version of this page.

Two kinds:

  • twilio_automated — give us your Twilio credentials and we configure the Twilio side for you.
  • sip — bring your own carrier or PBX, and tell us how it authenticates in each direction.
{
  "name": "Carrier A",
  "provider": "sip",
  "sip_signaling_mode": "static_peer",
  "inbound_auth_mode": "ip_allowlist",
  "inbound_allowed_addresses": [
    "203.0.113.0/24"
  ],
  "outbound_address": "sip.carrier.example:5061",
  "outbound_transport": "tls",
  "outbound_auth_mode": "credentials",
  "auth_username": "kejue-api",
  "auth_password": "write-only-value"
}

Over the API: POST /v1/sip-trunks.

A new trunk starts out provisioning. Poll GET /v1/sip-trunks/{id} until it's active or error.

What to give your carrier

Your carrier needs our addresses, and we publish them per deployment:

Over the API: GET /v1/sip-trunks/runtime-info.

{
  "sip_egress_cidrs": [
    "63.182.149.4/32",
    "18.184.38.187/32"
  ],
  "public_sip_uris": [
    "sip:63.182.149.4:5060;transport=tcp",
    "sip:18.184.38.187:5060;transport=tcp"
  ],
  "registration_domain": "63.182.149.4",
  "registrar_sip_address": null
}

Read these from the API, not from this page — they're specific to your deployment.

Use every address, in both directions. We answer on more than one SIP address. Add an origination route for every entry in public_sip_uris at equal priority, and allowlist every range in sip_egress_cidrs.

A carrier pointed at only the first address drops inbound calls whenever that address is down for maintenance, and rejects outbound calls that leave from any other one. The list can grow — re-read it before a carrier change and never hardcode a single address.

Use every edge, in both directions

We answer on more than one SIP address. Production runs two today, and each one is an independent, self-contained edge: if one is restarting or unreachable, the other keeps answering.

That only helps you if your carrier knows about all of them.

  • Inbound. Add one origination route per entry in public_sip_uris, at equal priority and weight. A carrier pointed at a single address loses inbound calls whenever that address is down for maintenance.
  • Outbound. Allowlist every entry in sip_egress_cidrs. Calls we place leave from any edge, so a carrier that trusts only the first address rejects everything sent from the second.

The list can grow. Treat it as a list, re-read it before a carrier change, and never hardcode a single address.

Signaling modes

sip_signaling_mode decides who finds whom:

ModeUse it whenYou supply
static_peer (default)Both ends have fixed addressesInbound auth, and an outbound address if you dial out
registered_peerYour PBX or device registers to usA registrar username and password
remote_registered_peerWe register to your PBX or carrierCredentials and your registrar's address

Registering to a hosted PBX

For remote_registered_peer, the realm has to match what your PBX challenges with. Left empty it defaults to the PBX domain, which is wrong for most hosted PBXs — Yeastar challenges with YSAsterisk. A mismatched realm fails every registration, and the trunk will show registration_status: failed.

Changing the realm means resending the credentials with it:

{
  "remote_register_realm": "YSAsterisk",
  "auth_username": "6701",
  "auth_password": "..."
}

Over the API: PATCH /v1/sip-trunks/{id}.

If outbound calls through a registered PBX come back 603 Decline, the PBX has no outbound route matching the number format. We dial numbers exactly as the call request gives them — usually E.164 with a + — so add a route whose dial pattern matches, for example +971. with the + stripped.

You can watch registration health on the trunk: registration_status, registration_contact, and registration_expires_at.

A carrier that only accepts port 5060

Some carriers answer anything else with 403 Forbidden. Set outbound_advanced_settings.via_proxy: true and outbound calls leave from port 5060. Needs a sip trunk with static peering and UDP or TCP transport.

Stopping toll fraud

On the trunk's outbound settings, allowed_prefixes and allowed_sip_hosts are default-deny once you set them: anything that doesn't match is refused before we dial. If you only ever call one country, say so here — it's the cheapest protection against an agent being talked into dialing a premium-rate number.

Declaring your carrier's limits

So the outbound dialer never overruns what your carrier will accept:

FieldWhat it means
outbound_capacity_modeunknown (default), fixed, or unlimited
max_concurrent_outboundSimultaneous outbound calls
max_outbound_cpsCalls per second
outbound_cps_burstA short burst above the CPS limit
outbound_capacity_profile_idShare one limit across trunks on the same provider account

See Calling policy for how this interacts with campaigns.

Calls that never became calls

When an INVITE is refused at the SIP layer, no call record exists — so there's nowhere obvious to look. This is that place:

GET /v1/sip-trunks/{id}/rejections.

Each entry says when, which direction, the SIP status and reason, the numbers involved, and the captured INVITE headers. The stage tells you why:

stageWhat happened
trunk_authAuthentication failed
no_trunkNo trunk matched where the call came from
no_dispatch_ruleNo phone number on the trunk matched the number dialed
admissionCalling is disabled or blocked for the workspace
capacityYou were at your concurrent-call limit
quotaYour call-minute quota is exhausted
carrier_rejectedYour carrier refused an outbound call

This is the first place to look when someone says "it just rings" or "my carrier says they sent it".

Advanced per-leg settings

Allowed numbers, media encryption (disable, allow, or require), ringing and maximum call durations, and static SIP header maps.

To get caller context from SIP headers into your prompts, set include_headers: "x" to expose received X-* headers, or use headers_to_attributes to map specific headers to friendlier names. See Instructions & variables.

Routing calls by header

Each number on a trunk can route inbound calls to different agents based on a SIP header — language, for example. Configure it on the number: see Route by SIP header.

Failure modes

Reads expose a stable last_error_code and sanitized last_error. Raw provider diagnostics, stored passwords, and Twilio credentials are never returned.

Changing and removing a trunk

Editing provider-facing settings puts the trunk back into provisioning; keep polling until it's active again. Automated Twilio trunks don't accept bring-your-own allowlist or credential changes — archive and recreate.

A trunk with active phone numbers on it can't be archived. Reassign or archive the numbers first.

See also

Phone numbers · Outbound calls · Calling policy

On this page