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
account_sidSID<AC>
Not PII

The SID of the Account(link takes you to an external page) that created the Trunk resource.

Pattern: ^AC[0-9a-fA-F]{32}$Min length: 34Max length: 34

domain_namestring

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_methodenum<http-method>

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

Possible values:
GETPOST

disaster_recovery_urlstring<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_namestring

The string that you assigned to describe the resource.


secureboolean

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.


recordingobject

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_modeenum<string>

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_idenum<string>

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

Possible values:
from-transfereefrom-transferor

cnam_lookup_enabledboolean

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_typestring

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_setarray[string]

Reserved.


date_createdstring<date-time>

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


date_updatedstring<date-time>

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


sidSID<TK>

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

Pattern: ^TK[0-9a-fA-F]{32}$Min length: 34Max length: 34

urlstring<uri>

The absolute URL of the resource.


linksobject<uri-map>

The URLs of related resources.


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

Request body parameters

request-body-parameters page anchor
FriendlyNamestring

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


DomainNamestring

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.


DisasterRecoveryUrlstring<uri>

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.


DisasterRecoveryMethodenum<http-method>

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

Possible values:
GETPOST

TransferModeenum<string>

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

Secureboolean

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.


CnamLookupEnabledboolean

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.


TransferCallerIdenum<string>

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

Possible values:
from-transfereefrom-transferor

Create Trunk

create-trunk page anchor
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}

SidSID<TK>required

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

Pattern: ^TK[0-9a-fA-F]{32}$Min length: 34Max length: 34
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

PageSizeinteger

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

Minimum: 1Maximum: 1000

Pageinteger

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

Minimum: 0

PageTokenstring

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}

SidSID<TK>required

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

Pattern: ^TK[0-9a-fA-F]{32}$Min length: 34Max length: 34
FriendlyNamestring

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


DomainNamestring

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.


DisasterRecoveryUrlstring<uri>

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.


DisasterRecoveryMethodenum<http-method>

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

Possible values:
GETPOST

TransferModeenum<string>

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

Secureboolean

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.


CnamLookupEnabledboolean

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.


TransferCallerIdenum<string>

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}

SidSID<TK>required

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

Pattern: ^TK[0-9a-fA-F]{32}$Min length: 34Max length: 34
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: