Trunk Resource
The Trunk resource represents a SIP Trunk in your Twilio account. A Trunk can have associated Credential Lists , IP Access Control Lists , Origination URLs , and Phone Numbers .
To learn how to create and use SIP Trunks, check out our getting started guide .
Property name Type PII Description
The SID of the Account that created the Trunk resource.
Pattern: ^AC[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and -
and must end with pstn.twilio.com
. See Termination Settings for more information.
disaster_recovery_method enum<http-method> The HTTP method we use to call the disaster_recovery_url
. Can be: GET
or POST
.
disaster_recovery_url string<uri> The URL we call using the disaster_recovery_method
if an error occurs while sending SIP traffic towards the configured Origination URL. We retrieve TwiML from this URL and execute the instructions like any other normal TwiML call. See Disaster Recovery for more information.
The string that you assigned to describe the resource.
Whether Secure Trunking is enabled for the trunk. If enabled, all calls going through the trunk will be secure using SRTP for media and TLS for signaling. If disabled, then RTP will be used for media. See Secure Trunking for more information.
The recording settings for the trunk. Can be: do-not-record
, record-from-ringing
, record-from-answer
. If set to record-from-ringing
or record-from-answer
, all calls going through the trunk will be recorded. The only way to change recording parameters is on a sub-resource of a Trunk after it has been created. e.g./Trunks/[Trunk_SID]/Recording -XPOST -d'Mode=record-from-answer'
. See Recording for more information.
transfer_mode enum<string> The call transfer settings for the trunk. Can be: enable-all
, sip-only
and disable-all
. See Transfer for more information.
Possible values: disable-all
enable-all
sip-only
transfer_caller_id enum<string> Caller Id for transfer target. Can be: from-transferee
(default) or from-transferor
.
Possible values: from-transferee
from-transferor
cnam_lookup_enabled boolean Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the SIP Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See CNAM Lookups for more information.
The types of authentication mapped to the domain. Can be: IP_ACL
and CREDENTIAL_LIST
. If both are mapped, the values are returned in a comma delimited list. If empty, the domain will not receive any traffic.
auth_type_set array[string] date_created string<date-time> The date and time in GMT when the resource was created specified in RFC 2822 format.
date_updated string<date-time> The date and time in GMT when the resource was last updated specified in RFC 2822 format.
The unique string that we created to identify the Trunk resource.
Pattern: ^TK[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
The absolute URL of the resource.
The URLs of related resources.
POST https://trunking.twilio.com/v1/Trunks
Property name Type Required PII Description
FriendlyName string Optional A descriptive string that you create to describe the resource. It can be up to 64 characters long.
The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and -
and must end with pstn.twilio.com
. See Termination Settings for more information.
DisasterRecoveryUrl string<uri> Optional The URL we should call using the disaster_recovery_method
if an error occurs while sending SIP traffic towards the configured Origination URL. We retrieve TwiML from the URL and execute the instructions like any other normal TwiML call. See Disaster Recovery for more information.
DisasterRecoveryMethod enum<http-method> Optional The HTTP method we should use to call the disaster_recovery_url
. Can be: GET
or POST
.
TransferMode enum<string> Optional The call transfer settings for the trunk. Can be: enable-all
, sip-only
and disable-all
. See Transfer for more information.
Possible values: disable-all
enable-all
sip-only
Whether Secure Trunking is enabled for the trunk. If enabled, all calls going through the trunk will be secure using SRTP for media and TLS for signaling. If disabled, then RTP will be used for media. See Secure Trunking for more information.
CnamLookupEnabled boolean Optional Whether Caller ID Name (CNAM) lookup should be enabled for the trunk. If enabled, all inbound calls to the SIP Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See CNAM Lookups for more information.
TransferCallerId enum<string> Optional Caller Id for transfer target. Can be: from-transferee
(default) or from-transferor
.
Possible values: from-transferee
from-transferor
_16 // Download the helper library from https://www.twilio.com/docs/node/install
_16 const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16 // Find your Account SID and Auth Token at twilio.com/console
_16 // and set the environment variables. See http://twil.io/secure
_16 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16 const authToken = process.env.TWILIO_AUTH_TOKEN;
_16 const client = twilio(accountSid, authToken);
_16 async function createTrunk() {
_16 const trunk = await client.trunking.v1.trunks.create();
_16 console.log(trunk.accountSid);
_27 "sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27 "domain_name": "test.pstn.twilio.com",
_27 "disaster_recovery_method": "POST",
_27 "disaster_recovery_url": "http://disaster-recovery.com",
_27 "friendly_name": "friendly_name",
_27 "cnam_lookup_enabled": false,
_27 "mode": "do-not-record",
_27 "trim": "do-not-trim"
_27 "transfer_mode": "disable-all",
_27 "transfer_caller_id": "from-transferee",
_27 "date_created": "2015-01-02T11:23:45Z",
_27 "date_updated": "2015-01-02T11:23:45Z",
_27 "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27 "origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",
_27 "credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",
_27 "ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",
_27 "phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"
GET https://trunking.twilio.com/v1/Trunks/{Sid}
Property name Type Required PII Description
The unique string that we created to identify the Trunk resource to fetch.
Pattern: ^TK[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_18 // Download the helper library from https://www.twilio.com/docs/node/install
_18 const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18 // Find your Account SID and Auth Token at twilio.com/console
_18 // and set the environment variables. See http://twil.io/secure
_18 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18 const authToken = process.env.TWILIO_AUTH_TOKEN;
_18 const client = twilio(accountSid, authToken);
_18 async function fetchTrunk() {
_18 const trunk = await client.trunking.v1
_18 .trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18 console.log(trunk.accountSid);
_27 "sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27 "domain_name": "test.pstn.twilio.com",
_27 "disaster_recovery_method": "POST",
_27 "disaster_recovery_url": "http://disaster-recovery.com",
_27 "friendly_name": "friendly_name",
_27 "cnam_lookup_enabled": false,
_27 "mode": "do-not-record",
_27 "trim": "do-not-trim"
_27 "transfer_mode": "disable-all",
_27 "transfer_caller_id": "from-transferor",
_27 "date_created": "2015-01-02T11:23:45Z",
_27 "date_updated": "2015-01-02T11:23:45Z",
_27 "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27 "origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",
_27 "credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",
_27 "ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",
_27 "phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"
Read multiple Trunk resources GET https://trunking.twilio.com/v1/Trunks
Property name Type Required PII Description
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Minimum: 1
Maximum: 1000
The page index. This value is simply for client state.
Minimum: 0
The page token. This is provided by the API.
_16 // Download the helper library from https://www.twilio.com/docs/node/install
_16 const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16 // Find your Account SID and Auth Token at twilio.com/console
_16 // and set the environment variables. See http://twil.io/secure
_16 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16 const authToken = process.env.TWILIO_AUTH_TOKEN;
_16 const client = twilio(accountSid, authToken);
_16 async function listTrunk() {
_16 const trunks = await client.trunking.v1.trunks.list({ limit: 20 });
_16 trunks.forEach((t) => console.log(t.accountSid));
_40 "first_page_url": "https://trunking.twilio.com/v1/Trunks?PageSize=50&Page=0",
_40 "url": "https://trunking.twilio.com/v1/Trunks?PageSize=50&Page=0",
_40 "next_page_url": null,
_40 "previous_page_url": null
_40 "sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_40 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_40 "domain_name": "test.pstn.twilio.com",
_40 "disaster_recovery_method": "POST",
_40 "disaster_recovery_url": "http://disaster-recovery.com",
_40 "friendly_name": "friendly_name",
_40 "cnam_lookup_enabled": false,
_40 "mode": "do-not-record",
_40 "trim": "do-not-trim"
_40 "transfer_mode": "disable-all",
_40 "transfer_caller_id": "from-transferee",
_40 "date_created": "2015-01-02T11:23:45Z",
_40 "date_updated": "2015-01-02T11:23:45Z",
_40 "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_40 "origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",
_40 "credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",
_40 "ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",
_40 "phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"
POST https://trunking.twilio.com/v1/Trunks/{Sid}
Property name Type Required PII Description
The unique string that we created to identify the OriginationUrl resource to update.
Pattern: ^TK[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
Property name Type Required PII Description
FriendlyName string Optional A descriptive string that you create to describe the resource. It can be up to 64 characters long.
The unique address you reserve on Twilio to which you route your SIP traffic. Domain names can contain letters, digits, and -
and must end with pstn.twilio.com
. See Termination Settings for more information.
DisasterRecoveryUrl string<uri> Optional The URL we should call using the disaster_recovery_method
if an error occurs while sending SIP traffic towards the configured Origination URL. We retrieve TwiML from the URL and execute the instructions like any other normal TwiML call. See Disaster Recovery for more information.
DisasterRecoveryMethod enum<http-method> Optional The HTTP method we should use to call the disaster_recovery_url
. Can be: GET
or POST
.
TransferMode enum<string> Optional The call transfer settings for the trunk. Can be: enable-all
, sip-only
and disable-all
. See Transfer for more information.
Possible values: disable-all
enable-all
sip-only
Whether Secure Trunking is enabled for the trunk. If enabled, all calls going through the trunk will be secure using SRTP for media and TLS for signaling. If disabled, then RTP will be used for media. See Secure Trunking for more information.
CnamLookupEnabled boolean Optional Whether Caller ID Name (CNAM) lookup should be enabled for the trunk. If enabled, all inbound calls to the SIP Trunk from the United States and Canada automatically perform a CNAM Lookup and display Caller ID data on your phone. See CNAM Lookups for more information.
TransferCallerId enum<string> Optional Caller Id for transfer target. Can be: from-transferee
(default) or from-transferor
.
Possible values: from-transferee
from-transferor
_18 // Download the helper library from https://www.twilio.com/docs/node/install
_18 const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18 // Find your Account SID and Auth Token at twilio.com/console
_18 // and set the environment variables. See http://twil.io/secure
_18 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18 const authToken = process.env.TWILIO_AUTH_TOKEN;
_18 const client = twilio(accountSid, authToken);
_18 async function updateTrunk() {
_18 const trunk = await client.trunking.v1
_18 .trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18 .update({ friendlyName: "FriendlyName" });
_18 console.log(trunk.accountSid);
_27 "sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27 "account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27 "domain_name": "test.pstn.twilio.com",
_27 "disaster_recovery_method": "GET",
_27 "disaster_recovery_url": "http://updated-recovery.com",
_27 "friendly_name": "FriendlyName",
_27 "cnam_lookup_enabled": true,
_27 "mode": "do-not-record",
_27 "trim": "do-not-trim"
_27 "transfer_mode": "disable-all",
_27 "transfer_caller_id": "from-transferor",
_27 "date_created": "2015-01-02T11:23:45Z",
_27 "date_updated": "2015-01-02T11:23:45Z",
_27 "url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_27 "origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",
_27 "credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",
_27 "ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",
_27 "phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"
DELETE https://trunking.twilio.com/v1/Trunks/{Sid}
Property name Type Required PII Description
The unique string that we created to identify the Trunk resource to delete.
Pattern: ^TK[0-9a-fA-F]{32}$
Min length: 34
Max length: 34
_16 // Download the helper library from https://www.twilio.com/docs/node/install
_16 const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_16 // Find your Account SID and Auth Token at twilio.com/console
_16 // and set the environment variables. See http://twil.io/secure
_16 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_16 const authToken = process.env.TWILIO_AUTH_TOKEN;
_16 const client = twilio(accountSid, authToken);
_16 async function deleteTrunk() {
_16 await client.trunking.v1
_16 .trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")