Question
How can I override the SIP From domain for outbound SIP calls via the Twilio API?
Product
Programmable Voice (SIP Interface, Voice API)
Answer
Twilio’s Programmable Voice API does not support customizing the domain portion of the SIP From header for outbound calls. When initiating a call via the REST API, Twilio requires the From parameter to be a valid E.164 phone number or a Client Identity not a SIP URI.
Technical Constraints:
-
The From Parameter: Must only contain the username or number (e.g.,
+123456789). Including an@symbol or domain (e.g.,sip:+1234@mydomain.sip.twilio.com) will trigger Error 21212: "The caller address is not a user name". -
Automatic Domain Assignment: Twilio automatically appends its own infrastructure domain (e.g.,
@sip.us1.twilio.comor@sip.de1.twilio.com) to the From header in outbound SIP INVITEs. - SIP Domain Use Case: Custom SIP Domains created in the Twilio Console are used for inbound call routing and SIP Registration; they cannot be used to "brand" the domain of outbound API calls.
Workaround: Using Custom Headers, If you need to pass your custom domain or identity to the receiving system for logging or routing purposes, you can include it as a custom SIP header within the To URI:
To=sip:destination@host?X-Source-Domain=mydomain.sip.twilio.com
For more details, see Pass Headers in your SIP URI
Additional Information
-
Error 21212: This error prevents malformed SIP URIs from being passed into the
Fromfield. - Interoperability: If your receiving SIP endpoint requires a specific domain for security (ACLs), you must configure the endpoint to trust/accept Twilio’s regional SIP domains rather than a custom one.