Skip to contentSkip to navigationSkip to topbar
On this page

ConnectionPolicy Resource


The ConnectionPolicies resource describes a list of URI Entries that are used to route Origination traffic to a PSTN Carrier over a BYOC Trunk.


ConnectionPolicy Properties

connectionpolicy-properties page anchor
Property nameTypeRequiredDescriptionChild properties
account_sidSID<AC>Optional
Not PII

The SID of the Account that created the Connection Policy resource.

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

sidSID<NY>Optional

The unique string that we created to identify the Connection Policy resource.

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

friendly_namestringOptional

The string that you assigned to describe the resource.


date_updatedstring<date-time>Optional

The date and time in GMT when 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.


linksobject<uri-map>Optional

The URLs of related resources.


Create a ConnectionPolicy resource

create-a-connectionpolicy-resource page anchor
POST https://voice.twilio.com/v1/ConnectionPolicies

Request body parameters

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

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

Create a ConnectionPolicyLink to code sample: Create a ConnectionPolicy
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 createConnectionPolicy() {
11
const connectionPolicy = await client.voice.v1.connectionPolicies.create();
12
13
console.log(connectionPolicy.accountSid);
14
}
15
16
createConnectionPolicy();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"friendly_name": "friendly_name",
5
"date_created": "2020-03-18T23:31:36Z",
6
"date_updated": "2020-03-18T23:31:36Z",
7
"url": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"links": {
9
"targets": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Targets"
10
}
11
}

Fetch a ConnectionPolicy resource

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

Property nameTypeRequiredPIIDescription
SidSID<NY>required

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

Pattern: ^NY[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 fetchConnectionPolicy() {
11
const connectionPolicy = await client.voice.v1
12
.connectionPolicies("NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.fetch();
14
15
console.log(connectionPolicy.accountSid);
16
}
17
18
fetchConnectionPolicy();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"friendly_name": "friendly_name",
5
"date_created": "2020-03-18T23:31:36Z",
6
"date_updated": "2020-03-18T23:31:37Z",
7
"url": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"links": {
9
"targets": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Targets"
10
}
11
}

Read multiple ConnectionPolicy resources

read-multiple-connectionpolicy-resources page anchor
GET https://voice.twilio.com/v1/ConnectionPolicies

Property nameTypeRequiredPIIDescription
PageSizeintegerOptional

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

Minimum: 1Maximum: 1000

PageintegerOptional

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

Minimum: 0

PageTokenstringOptional

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 listConnectionPolicy() {
11
const connectionPolicies = await client.voice.v1.connectionPolicies.list({
12
limit: 20,
13
});
14
15
connectionPolicies.forEach((c) => console.log(c.accountSid));
16
}
17
18
listConnectionPolicy();

Output

1
{
2
"meta": {
3
"page": 0,
4
"page_size": 50,
5
"first_page_url": "https://voice.twilio.com/v1/ConnectionPolicies?PageSize=50&Page=0",
6
"previous_page_url": null,
7
"url": "https://voice.twilio.com/v1/ConnectionPolicies?PageSize=50&Page=0",
8
"next_page_url": null,
9
"key": "connection_policies"
10
},
11
"connection_policies": [
12
{
13
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
14
"sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
15
"friendly_name": "friendly_name",
16
"date_created": "2020-03-18T23:31:36Z",
17
"date_updated": "2020-03-18T23:31:37Z",
18
"url": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
19
"links": {
20
"targets": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Targets"
21
}
22
}
23
]
24
}

Update a ConnectionPolicy resource

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

Property nameTypeRequiredPIIDescription
SidSID<NY>required

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

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

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

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 updateConnectionPolicy() {
11
const connectionPolicy = await client.voice.v1
12
.connectionPolicies("NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.update({ friendlyName: "FriendlyName" });
14
15
console.log(connectionPolicy.accountSid);
16
}
17
18
updateConnectionPolicy();

Output

1
{
2
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
3
"sid": "NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
4
"friendly_name": "FriendlyName",
5
"date_created": "2020-03-18T23:31:36Z",
6
"date_updated": "2020-03-18T23:31:37Z",
7
"url": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
8
"links": {
9
"targets": "https://voice.twilio.com/v1/ConnectionPolicies/NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Targets"
10
}
11
}

Delete a ConnectionPolicy resource

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

Property nameTypeRequiredPIIDescription
SidSID<NY>required

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

Pattern: ^NY[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 deleteConnectionPolicy() {
11
await client.voice.v1
12
.connectionPolicies("NYaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
13
.remove();
14
}
15
16
deleteConnectionPolicy();

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.