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.
The SID of the Account that created the Trunk resource.
^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34The 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.
The HTTP method we use to call the disaster_recovery_url. Can be: GET or POST.
GETPOSTThe 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.
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.
The call transfer settings for the trunk. Can be: enable-all, sip-only and disable-all. See Transfer for more information.
disable-allenable-allsip-onlyCaller Id for transfer target. Can be: from-transferee (default) or from-transferor.
from-transfereefrom-transferorWhether 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.
Whether Symmetric RTP is enabled for the trunk. When Symmetric RTP is disabled, Twilio will send RTP to the destination negotiated in the SDP. Disabling Symmetric RTP is considered to be more secure and therefore recommended. See Symmetric RTP for more information.
The date and time in GMT when the resource was created specified in RFC 2822 format.
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.
^TK[0-9a-fA-F]{32}$Min length: 34Max length: 34The URLs of related resources.
POST https://trunking.twilio.com/v1/Trunks
application/x-www-form-urlencodedA 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.
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.
The HTTP method we should use to call the disaster_recovery_url. Can be: GET or POST.
GETPOSTThe call transfer settings for the trunk. Can be: enable-all, sip-only and disable-all. See Transfer for more information.
disable-allenable-allsip-onlyWhether 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.
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.
Caller Id for transfer target. Can be: from-transferee (default) or from-transferor.
from-transfereefrom-transferor1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function createTrunk() {11const trunk = await client.trunking.v1.trunks.create();1213console.log(trunk.accountSid);14}1516createTrunk();
Response
1{2"sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"domain_name": "test.pstn.twilio.com",5"disaster_recovery_method": "POST",6"disaster_recovery_url": "http://disaster-recovery.com",7"friendly_name": "friendly_name",8"secure": false,9"cnam_lookup_enabled": false,10"symmetric_rtp_enabled": false,11"recording": {12"mode": "do-not-record",13"trim": "do-not-trim"14},15"transfer_mode": "disable-all",16"transfer_caller_id": "from-transferee",17"auth_type": "",18"auth_type_set": [],19"date_created": "2015-01-02T11:23:45Z",20"date_updated": "2015-01-02T11:23:45Z",21"url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",22"links": {23"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",24"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",25"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",26"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"27}28}
GET https://trunking.twilio.com/v1/Trunks/{Sid}
The unique string that we created to identify the Trunk resource to fetch.
^TK[0-9a-fA-F]{32}$Min length: 34Max length: 341// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function fetchTrunk() {11const trunk = await client.trunking.v112.trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.fetch();1415console.log(trunk.accountSid);16}1718fetchTrunk();
Response
1{2"sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"domain_name": "test.pstn.twilio.com",5"disaster_recovery_method": "POST",6"disaster_recovery_url": "http://disaster-recovery.com",7"friendly_name": "friendly_name",8"secure": false,9"cnam_lookup_enabled": false,10"symmetric_rtp_enabled": false,11"recording": {12"mode": "do-not-record",13"trim": "do-not-trim"14},15"transfer_mode": "disable-all",16"transfer_caller_id": "from-transferor",17"auth_type": "",18"auth_type_set": [],19"date_created": "2015-01-02T11:23:45Z",20"date_updated": "2015-01-02T11:23:45Z",21"url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",22"links": {23"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",24"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",25"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",26"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"27}28}
GET https://trunking.twilio.com/v1/Trunks
How many resources to return in each list page. The default is 50, and the maximum is 1000.
1Maximum: 1000The page token. This is provided by the API.
1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function listTrunk() {11const trunks = await client.trunking.v1.trunks.list({ limit: 20 });1213trunks.forEach((t) => console.log(t.accountSid));14}1516listTrunk();
Response
1{2"meta": {3"first_page_url": "https://trunking.twilio.com/v1/Trunks?PageSize=50&Page=0",4"url": "https://trunking.twilio.com/v1/Trunks?PageSize=50&Page=0",5"page_size": 50,6"key": "trunks",7"next_page_url": null,8"page": 0,9"previous_page_url": null10},11"trunks": [12{13"sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",14"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",15"domain_name": "test.pstn.twilio.com",16"disaster_recovery_method": "POST",17"disaster_recovery_url": "http://disaster-recovery.com",18"friendly_name": "friendly_name",19"secure": false,20"cnam_lookup_enabled": false,21"symmetric_rtp_enabled": false,22"recording": {23"mode": "do-not-record",24"trim": "do-not-trim"25},26"transfer_mode": "disable-all",27"transfer_caller_id": "from-transferee",28"auth_type": "",29"auth_type_set": [],30"date_created": "2015-01-02T11:23:45Z",31"date_updated": "2015-01-02T11:23:45Z",32"url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",33"links": {34"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",35"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",36"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",37"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"38}39}40]41}
POST https://trunking.twilio.com/v1/Trunks/{Sid}
The unique string that we created to identify the OriginationUrl resource to update.
^TK[0-9a-fA-F]{32}$Min length: 34Max length: 34application/x-www-form-urlencodedA 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.
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.
The HTTP method we should use to call the disaster_recovery_url. Can be: GET or POST.
GETPOSTThe call transfer settings for the trunk. Can be: enable-all, sip-only and disable-all. See Transfer for more information.
disable-allenable-allsip-onlyWhether 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.
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.
Caller Id for transfer target. Can be: from-transferee (default) or from-transferor.
from-transfereefrom-transferor1// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function updateTrunk() {11const trunk = await client.trunking.v112.trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.update({ friendlyName: "FriendlyName" });1415console.log(trunk.accountSid);16}1718updateTrunk();
Response
1{2"sid": "TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",3"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",4"domain_name": "test.pstn.twilio.com",5"disaster_recovery_method": "GET",6"disaster_recovery_url": "http://updated-recovery.com",7"friendly_name": "FriendlyName",8"secure": true,9"cnam_lookup_enabled": true,10"symmetric_rtp_enabled": true,11"recording": {12"mode": "do-not-record",13"trim": "do-not-trim"14},15"transfer_mode": "disable-all",16"transfer_caller_id": "from-transferor",17"auth_type": "",18"auth_type_set": [],19"date_created": "2015-01-02T11:23:45Z",20"date_updated": "2015-01-02T11:23:45Z",21"url": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",22"links": {23"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/OriginationUrls",24"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/CredentialLists",25"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/IpAccessControlLists",26"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers"27}28}
DELETE https://trunking.twilio.com/v1/Trunks/{Sid}
The unique string that we created to identify the Trunk resource to delete.
^TK[0-9a-fA-F]{32}$Min length: 34Max length: 341// Download the helper library from https://www.twilio.com/docs/node/install2const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";34// Find your Account SID and Auth Token at twilio.com/console5// and set the environment variables. See http://twil.io/secure6const accountSid = process.env.TWILIO_ACCOUNT_SID;7const authToken = process.env.TWILIO_AUTH_TOKEN;8const client = twilio(accountSid, authToken);910async function deleteTrunk() {11await client.trunking.v112.trunks("TKaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")13.remove();14}1516deleteTrunk();