Skip to contentSkip to navigationSkip to topbar
On this page

ByocTrunk Resource


The ByocTrunks resource describes a trunk that can be configured to send/receive traffic to/from a PSTN Carrier.


ByocTrunk Properties

byoctrunk-properties page anchor
Property nameTypeRequiredDescriptionChild properties
account_sidSID<AC>

Optional

Not PII

The SID of the Account that created the BYOC Trunk resource.

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

sidSID<BY>

Optional

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

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

friendly_namestring

Optional

The string that you assigned to describe the resource.


voice_urlstring<uri>

Optional

PII MTL: 30 days

The URL we call using the voice_method when the BYOC Trunk receives a call.


voice_methodenum<http-method>

Optional

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

Possible values:
GETPOST

voice_fallback_urlstring<uri>

Optional

The URL that we call when an error occurs while retrieving or executing the TwiML requested from voice_url.


voice_fallback_methodenum<http-method>

Optional

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

Possible values:
GETPOST

status_callback_urlstring<uri>

Optional

The URL that we call to pass status parameters (such as call ended) to your application.


status_callback_methodenum<http-method>

Optional

The HTTP method we use to call status_callback_url. Either GET or POST.

Possible values:
GETPOST

cnam_lookup_enabledboolean

Optional

Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC 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.


connection_policy_sidSID<NY>

Optional

The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.

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

from_domain_sidSID<SD>

Optional

The SID of the SIP Domain that should be used in the From header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to "call back" an incoming call, configure this with a SIP Domain to ensure proper routing. If not configured, the from domain will default to "sip.twilio.com".

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

date_updatedstring<date-time>

Optional

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


urlstring<uri>

Optional

The absolute URL of the resource.


Create a ByocTrunk resource

create-a-byoctrunk-resource page anchor
POST https://voice.twilio.com/v1/ByocTrunks

Request body parameters

request-body-parameters page anchor
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestring

Optional

A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.


VoiceUrlstring<uri>

Optional

The URL we should call when the BYOC Trunk receives a call.


VoiceMethodenum<http-method>

Optional

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

Possible values:
GETPOST

VoiceFallbackUrlstring<uri>

Optional

The URL that we should call when an error occurs while retrieving or executing the TwiML from voice_url.


VoiceFallbackMethodenum<http-method>

Optional

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

Possible values:
GETPOST

StatusCallbackUrlstring<uri>

Optional

The URL that we should call to pass status parameters (such as call ended) to your application.


StatusCallbackMethodenum<http-method>

Optional

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

Possible values:
GETPOST

CnamLookupEnabledboolean

Optional

Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC 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.


ConnectionPolicySidSID<NY>

Optional

The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.

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

FromDomainSidSID<SD>

Optional

The SID of the SIP Domain that should be used in the From header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to "call back" an incoming call, configure this with a SIP Domain to ensure proper routing. If not configured, the from domain will default to "sip.twilio.com".

Pattern: ^SD[0-9a-fA-F]{32}$Min length: 34Max length: 34
Create a ByocTrunkLink to code sample: Create a ByocTrunk
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function createByocTrunk() {
11
const byocTrunk = await client.voice.v1.byocTrunks.create();
12
13
console.log(byocTrunk.accountSid);
14
}
15
16
createByocTrunk();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"sid": "BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"friendly_name": "friendly_name",
5
"voice_url": "https://byoc.example.com/twilio/app",
6
"voice_method": "POST",
7
"voice_fallback_method": "POST",
8
"voice_fallback_url": "https://byoc.example.com/twilio/fallback",
9
"status_callback_method": "POST",
10
"status_callback_url": "https://byoc.example.com/twilio/status_callback",
11
"cnam_lookup_enabled": false,
12
"connection_policy_sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"from_domain_sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"date_created": "2020-03-18T23:31:36Z",
15
"date_updated": "2020-03-18T23:31:36Z",
16
"url": "https://voice.twilio.com/v1/ByocTrunks/BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
17
}

Fetch a ByocTrunk resource

fetch-a-byoctrunk-resource page anchor
GET https://voice.twilio.com/v1/ByocTrunks/{Sid}

Property nameTypeRequiredPIIDescription
SidSID<BY>required

The Twilio-provided string that uniquely identifies the BYOC Trunk resource to fetch.

Pattern: ^BY[0-9a-fA-F]{32}$Min length: 34Max length: 34
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function fetchByocTrunk() {
11
const byocTrunk = await client.voice.v1
12
.byocTrunks("BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.fetch();
14
15
console.log(byocTrunk.accountSid);
16
}
17
18
fetchByocTrunk();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"sid": "BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"friendly_name": "friendly_name",
5
"voice_url": "https://byoc.example.com/twilio/app",
6
"voice_method": "POST",
7
"voice_fallback_method": "POST",
8
"voice_fallback_url": "https://byoc.example.com/twilio/fallback",
9
"status_callback_method": "POST",
10
"status_callback_url": "https://byoc.example.com/twilio/status_callback",
11
"cnam_lookup_enabled": false,
12
"connection_policy_sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
13
"from_domain_sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"date_created": "2020-03-18T23:31:36Z",
15
"date_updated": "2020-03-18T23:31:37Z",
16
"url": "https://voice.twilio.com/v1/ByocTrunks/BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
17
}

Read multiple ByocTrunk resources

read-multiple-byoctrunk-resources page anchor
GET https://voice.twilio.com/v1/ByocTrunks

Property nameTypeRequiredPIIDescription
PageSizeinteger

Optional

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

Minimum: 1Maximum: 1000

Pageinteger

Optional

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

Minimum: 0

PageTokenstring

Optional

The page token. This is provided by the API.

1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function listByocTrunk() {
11
const byocTrunks = await client.voice.v1.byocTrunks.list({ limit: 20 });
12
13
byocTrunks.forEach((b) => console.log(b.accountSid));
14
}
15
16
listByocTrunk();

Output

1
{
2
"meta": {
3
"page": 0,
4
"page_size": 50,
5
"first_page_url": "https://voice.twilio.com/v1/ByocTrunks?PageSize=50&Page=0",
6
"previous_page_url": null,
7
"url": "https://voice.twilio.com/v1/ByocTrunks?PageSize=50&Page=0",
8
"next_page_url": null,
9
"key": "byoc_trunks"
10
},
11
"byoc_trunks": [
12
{
13
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"sid": "BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"friendly_name": "friendly_name",
16
"voice_url": "https://byoc.example.com/twilio/app",
17
"voice_method": "POST",
18
"voice_fallback_method": "POST",
19
"voice_fallback_url": "https://byoc.example.com/twilio/fallback",
20
"status_callback_method": "POST",
21
"status_callback_url": "https://byoc.example.com/twilio/status_callback",
22
"cnam_lookup_enabled": false,
23
"connection_policy_sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
24
"from_domain_sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
25
"date_created": "2020-03-18T23:31:36Z",
26
"date_updated": "2020-03-18T23:31:37Z",
27
"url": "https://voice.twilio.com/v1/ByocTrunks/BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
28
}
29
]
30
}

Update a ByocTrunk resource

update-a-byoctrunk-resource page anchor
POST https://voice.twilio.com/v1/ByocTrunks/{Sid}

Property nameTypeRequiredPIIDescription
SidSID<BY>required

The Twilio-provided string that uniquely identifies the BYOC Trunk resource to update.

Pattern: ^BY[0-9a-fA-F]{32}$Min length: 34Max length: 34
Encoding type:application/x-www-form-urlencoded
SchemaExample
Property nameTypeRequiredDescriptionChild properties
FriendlyNamestring

Optional

A descriptive string that you create to describe the resource. It is not unique and can be up to 255 characters long.


VoiceUrlstring<uri>

Optional

The URL we should call when the BYOC Trunk receives a call.


VoiceMethodenum<http-method>

Optional

The HTTP method we should use to call voice_url

Possible values:
GETPOST

VoiceFallbackUrlstring<uri>

Optional

The URL that we should call when an error occurs while retrieving or executing the TwiML requested by voice_url.


VoiceFallbackMethodenum<http-method>

Optional

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

Possible values:
GETPOST

StatusCallbackUrlstring<uri>

Optional

The URL that we should call to pass status parameters (such as call ended) to your application.


StatusCallbackMethodenum<http-method>

Optional

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

Possible values:
GETPOST

CnamLookupEnabledboolean

Optional

Whether Caller ID Name (CNAM) lookup is enabled for the trunk. If enabled, all inbound calls to the BYOC 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.


ConnectionPolicySidSID<NY>

Optional

The SID of the Connection Policy that Twilio will use when routing traffic to your communications infrastructure.

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

FromDomainSidSID<SD>

Optional

The SID of the SIP Domain that should be used in the From header of originating calls sent to your SIP infrastructure. If your SIP infrastructure allows users to "call back" an incoming call, configure this with a SIP Domain to ensure proper routing. If not configured, the from domain will default to "sip.twilio.com".

Pattern: ^SD[0-9a-fA-F]{32}$Min length: 34Max length: 34
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function updateByocTrunk() {
11
const byocTrunk = await client.voice.v1
12
.byocTrunks("BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.update({ friendlyName: "FriendlyName" });
14
15
console.log(byocTrunk.accountSid);
16
}
17
18
updateByocTrunk();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"sid": "BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"friendly_name": "FriendlyName",
5
"voice_url": "https://byoc.example.com/twilio_updated/app",
6
"voice_method": "GET",
7
"voice_fallback_method": "GET",
8
"voice_fallback_url": "https://byoc.example.com/twilio_updated/fallback",
9
"status_callback_method": "GET",
10
"status_callback_url": "https://byoc.example.com/twilio_updated/status_callback",
11
"cnam_lookup_enabled": true,
12
"connection_policy_sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
13
"from_domain_sid": "SDaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab",
14
"date_created": "2020-03-18T23:31:36Z",
15
"date_updated": "2020-03-18T23:31:37Z",
16
"url": "https://voice.twilio.com/v1/ByocTrunks/BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
17
}

Delete a ByocTrunk resource

delete-a-byoctrunk-resource page anchor
DELETE https://voice.twilio.com/v1/ByocTrunks/{Sid}

Property nameTypeRequiredPIIDescription
SidSID<BY>required

The Twilio-provided string that uniquely identifies the BYOC Trunk resource to delete.

Pattern: ^BY[0-9a-fA-F]{32}$Min length: 34Max length: 34
1
// Download the helper library from https://www.twilio.com/docs/node/install
2
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
3
4
// Find your Account SID and Auth Token at twilio.com/console
5
// and set the environment variables. See http://twil.io/secure
6
const accountSid = process.env.TWILIO_ACCOUNT_SID;
7
const authToken = process.env.TWILIO_AUTH_TOKEN;
8
const client = twilio(accountSid, authToken);
9
10
async function deleteByocTrunk() {
11
await client.voice.v1
12
.byocTrunks("BYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.remove();
14
}
15
16
deleteByocTrunk();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.