Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

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.


Trunk Properties

trunk-properties page anchor
Resource properties
account_sidtype: SID<AC>Not PII

domain_nametype: stringNot PII

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(link takes you to an external page) for more information.


disaster_recovery_methodtype: enum<HTTP METHOD>Not PII

The HTTP method we use to call the disaster_recovery_url. Can be: GET or POST.

Possible values:
HEADGETPOSTPATCHPUTDELETE

disaster_recovery_urltype: string<URI>PII MTL: 30 days

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(link takes you to an external page) for more information.


friendly_nametype: stringNot PII

The string that you assigned to describe the resource.


securetype: booleanNot PII

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(link takes you to an external page) for more information.


recordingtype: objectNot PII

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(link takes you to an external page) for more information.


transfer_modetype: enum<STRING>Not PII

The call transfer settings for the trunk. Can be: enable-all, sip-only and disable-all. See Transfer(link takes you to an external page) for more information.

Possible values:
disable-allenable-allsip-only

transfer_caller_idtype: enum<STRING>Not PII

Caller Id for transfer target. Can be: from-transferee (default) or from-transferor.

Possible values:
from-transfereefrom-transferor

cnam_lookup_enabledtype: booleanNot PII

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(link takes you to an external page) for more information.


auth_typetype: stringNot PII

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_settype: string[]Not PII

Reserved.


date_createdtype: string<DATE TIME>Not PII

The date and time in GMT when the resource was created specified in RFC 2822(link takes you to an external page) format.


date_updatedtype: string<DATE TIME>Not PII

The date and time in GMT when the resource was last updated specified in RFC 2822(link takes you to an external page) format.


sidtype: SID<TK>Not PII

The unique string that we created to identify the Trunk resource.


urltype: string<URI>Not PII

The absolute URL of the resource.


linkstype: object<URI MAP>Not PII

The URLs of related resources.


POST https://trunking.twilio.com/v1/Trunks

Parameters

create-parameters page anchor
Request body parameters
FriendlyNametype: stringNot PII

A descriptive string that you create to describe the resource. It can be up to 64 characters long.


DomainNametype: stringNot PII

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(link takes you to an external page) for more information.


DisasterRecoveryUrltype: string<URI>PII MTL: 30 days

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(link takes you to an external page) for more information.


DisasterRecoveryMethodtype: enum<HTTP METHOD>Not PII

The HTTP method we should use to call the disaster_recovery_url. Can be: GET or POST.

Possible values:
HEADGETPOSTPATCHPUTDELETE

TransferModetype: enum<STRING>Not PII

The call transfer settings for the trunk. Can be: enable-all, sip-only and disable-all. See Transfer(link takes you to an external page) for more information.

Possible values:
disable-allenable-allsip-only

Securetype: booleanNot PII

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(link takes you to an external page) for more information.


CnamLookupEnabledtype: booleanNot PII

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(link takes you to an external page) for more information.


TransferCallerIdtype: enum<STRING>Not PII

Caller Id for transfer target. Can be: from-transferee (default) or from-transferor.

Possible values:
from-transfereefrom-transferor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.trunking.v1.trunks.create().then(trunk => console.log(trunk.sid));

Output

_27
{
_27
"sid": "TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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
"secure": false,
_27
"cnam_lookup_enabled": false,
_27
"recording": {
_27
"mode": "do-not-record",
_27
"trim": "do-not-trim"
_27
},
_27
"transfer_mode": "disable-all",
_27
"transfer_caller_id": "from-transferee",
_27
"auth_type": "",
_27
"auth_type_set": [],
_27
"date_created": "2015-01-02T11:23:45Z",
_27
"date_updated": "2015-01-02T11:23:45Z",
_27
"url": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"links": {
_27
"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OriginationUrls",
_27
"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CredentialLists",
_27
"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IpAccessControlLists",
_27
"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers"
_27
}
_27
}


GET https://trunking.twilio.com/v1/Trunks/{Sid}

URI parameters
Sidtype: SID<TK>Not PII
Path Parameter

The unique string that we created to identify the Trunk resource to fetch.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.trunking.v1.trunks('TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.fetch()
_10
.then(trunk => console.log(trunk.domainName));

Output

_27
{
_27
"sid": "TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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
"secure": false,
_27
"cnam_lookup_enabled": false,
_27
"recording": {
_27
"mode": "do-not-record",
_27
"trim": "do-not-trim"
_27
},
_27
"transfer_mode": "disable-all",
_27
"transfer_caller_id": "from-transferor",
_27
"auth_type": "",
_27
"auth_type_set": [],
_27
"date_created": "2015-01-02T11:23:45Z",
_27
"date_updated": "2015-01-02T11:23:45Z",
_27
"url": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"links": {
_27
"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OriginationUrls",
_27
"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CredentialLists",
_27
"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IpAccessControlLists",
_27
"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers"
_27
}
_27
}


Read multiple Trunk resources

read-multiple-trunk-resources page anchor
GET https://trunking.twilio.com/v1/Trunks

URI parameters
PageSizetype: integerNot PII
Query Parameter

How many resources to return in each list page. The default is 50, and the maximum is 1000.


Pagetype: integerNot PII
Query Parameter

The page index. This value is simply for client state.


PageTokentype: stringNot PII
Query Parameter

The page token. This is provided by the API.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.trunking.v1.trunks
_10
.list({limit: 20})
_10
.then(trunks => trunks.forEach(t => console.log(t.sid)));

Output

_40
{
_40
"meta": {
_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
"page_size": 50,
_40
"key": "trunks",
_40
"next_page_url": "https://trunking.twilio.com/v1/Trunks?PageSize=50&Page=1",
_40
"page": 0,
_40
"previous_page_url": "https://trunking.twilio.com/v1/Trunks?PageSize=50&Page=0"
_40
},
_40
"trunks": [
_40
{
_40
"sid": "TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_40
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_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
"secure": false,
_40
"cnam_lookup_enabled": false,
_40
"recording": {
_40
"mode": "do-not-record",
_40
"trim": "do-not-trim"
_40
},
_40
"transfer_mode": "disable-all",
_40
"transfer_caller_id": "from-transferee",
_40
"auth_type": "",
_40
"auth_type_set": [],
_40
"date_created": "2015-01-02T11:23:45Z",
_40
"date_updated": "2015-01-02T11:23:45Z",
_40
"url": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_40
"links": {
_40
"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OriginationUrls",
_40
"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CredentialLists",
_40
"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IpAccessControlLists",
_40
"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers"
_40
}
_40
}
_40
]
_40
}


POST https://trunking.twilio.com/v1/Trunks/{Sid}

URI parameters
Sidtype: SID<TK>Not PII
Path Parameter

The unique string that we created to identify the OriginationUrl resource to update.


Request body parameters
FriendlyNametype: stringNot PII

A descriptive string that you create to describe the resource. It can be up to 64 characters long.


DomainNametype: stringNot PII

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(link takes you to an external page) for more information.


DisasterRecoveryUrltype: string<URI>PII MTL: 30 days

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(link takes you to an external page) for more information.


DisasterRecoveryMethodtype: enum<HTTP METHOD>Not PII

The HTTP method we should use to call the disaster_recovery_url. Can be: GET or POST.

Possible values:
HEADGETPOSTPATCHPUTDELETE

TransferModetype: enum<STRING>Not PII

The call transfer settings for the trunk. Can be: enable-all, sip-only and disable-all. See Transfer(link takes you to an external page) for more information.

Possible values:
disable-allenable-allsip-only

Securetype: booleanNot PII

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(link takes you to an external page) for more information.


CnamLookupEnabledtype: booleanNot PII

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(link takes you to an external page) for more information.


TransferCallerIdtype: enum<STRING>Not PII

Caller Id for transfer target. Can be: from-transferee (default) or from-transferor.

Possible values:
from-transfereefrom-transferor
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.trunking.v1.trunks('TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10
.update({friendlyName: 'friendly_name'})
_10
.then(trunk => console.log(trunk.domainName));

Output

_27
{
_27
"sid": "TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"domain_name": "test.pstn.twilio.com",
_27
"disaster_recovery_method": "GET",
_27
"disaster_recovery_url": "http://updated-recovery.com",
_27
"friendly_name": "updated_name",
_27
"secure": true,
_27
"cnam_lookup_enabled": true,
_27
"recording": {
_27
"mode": "do-not-record",
_27
"trim": "do-not-trim"
_27
},
_27
"transfer_mode": "disable-all",
_27
"transfer_caller_id": "from-transferor",
_27
"auth_type": "",
_27
"auth_type_set": [],
_27
"date_created": "2015-01-02T11:23:45Z",
_27
"date_updated": "2015-01-02T11:23:45Z",
_27
"url": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_27
"links": {
_27
"origination_urls": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/OriginationUrls",
_27
"credential_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/CredentialLists",
_27
"ip_access_control_lists": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/IpAccessControlLists",
_27
"phone_numbers": "https://trunking.twilio.com/v1/Trunks/TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers"
_27
}
_27
}


DELETE https://trunking.twilio.com/v1/Trunks/{Sid}

URI parameters
Sidtype: SID<TK>Not PII
Path Parameter

The unique string that we created to identify the Trunk resource to delete.

Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl

_10
// Download the helper library from https://www.twilio.com/docs/node/install
_10
// Find your Account SID and Auth Token at twilio.com/console
_10
// and set the environment variables. See http://twil.io/secure
_10
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_10
const authToken = process.env.TWILIO_AUTH_TOKEN;
_10
const client = require('twilio')(accountSid, authToken);
_10
_10
client.trunking.v1.trunks('TKXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX').remove();


Rate this page: