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

Phone Number


With Twilio Proxy, you associate phone numbers (this resource) and short codes directly with a Proxy Service. All added numbers go into the Phone Number Pool associated with a given Proxy Service.

A Twilio number cannot be associated with more than one Proxy Service, but it can be associated with a Messaging Service, for example, to complete US A2P 10DLC registration (see below for important details about how to do this).

For more information on managing the phone numbers in your Proxy Phone Number Pool, refer to our Phone Number Management guide.


"Reserved" numbers in Proxy

In a Proxy service, phone numbers can be marked as Reserved. Reserved numbers will not be included in the set of numbers Proxy considers when choosing a number for a participant, but they can be manually assigned as Proxy Numbers for participants (e.g., in a lead tracking use-case).


Proxy Number Pool Size Limit

Phone Number Pools are limited to 5000 reserved phone numbers and 500 unreserved phone numbers per Proxy Service. Numbers can be distributed across multiple Proxy Services if you need more of numbers.


Adding Proxy Phone Numbers to Messaging Services

It is possible to associate Twilio Proxy numbers with a Messaging Service, although there are some limitations to be aware of. This capability is especially important for customers who use US long code numbers to send messages to US recipients because adding numbers to a Messaging Service is required in order to complete A2P 10DLC registration.

Currently, a number that is already associated with a Messaging Service cannot be added to a Proxy Service via the Proxy Console or API.

However, Twilio numbers that are already associated with a Proxy Service can be associated with a Messaging Service. Before doing this, you must ensure that your Messaging Service is configured correctly. Your Messaging Service must have its Incoming Message handling behavior set to "Defer to sender's webhook" to ensure that your numbers continue to use Proxy after they are added to the Service.

Step-by-step instructions to associate Proxy numbers with a Messaging Service:

  1. Set up your Messaging Service, but do not add any phone numbers to it yet. Ensure that the Incoming Message handling is set to "Defer to sender's webhook." This setting can be found in the "Integration" settings for the Messaging Service in the Twilio Console.
  2. Ensure that all numbers you plan to add to the Messaging Service are already associated with a Proxy Service.
  3. Add your Proxy numbers to the Messaging Service, either using the Twilio Console or the Messaging Service API PhoneNumber endpoint.

PhoneNumber Properties

Property nameTypePIIDescription
sidSID<PN>
Not PII

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

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

account_sidSID<AC>

The SID of the Account that created the PhoneNumber resource.

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

service_sidSID<KS>

The SID of the PhoneNumber resource's parent Service resource.

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

date_createdstring<date-time>

The ISO 8601 date and time in GMT when the resource was created.


date_updatedstring<date-time>

The ISO 8601 date and time in GMT when the resource was last updated.


phone_numberstring<phone-number>

The phone number in E.164 format, which consists of a + followed by the country code and subscriber number.


friendly_namestring

The string that you assigned to describe the resource.


iso_countrystring

The ISO Country Code for the phone number.


capabilitiesobject<phone-number-capabilities>

The capabilities of the phone number.


urlstring<uri>

The absolute URL of the PhoneNumber resource.


is_reservedboolean

Whether the phone number should be reserved and not be assigned to a participant using proxy pool logic. See Reserved Phone Numbers for more information.


in_useinteger

The number of open session assigned to the number. See the How many Phone Numbers do I need? guide for more information.


Add a Phone Number to a Proxy Service

POST https://proxy.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers

Path parameters

Property nameTypeRequiredPIIDescription
ServiceSidSID<KS>required

The SID parent Service resource of the new PhoneNumber resource.

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

Request body parameters

Property nameTypeRequiredPIIDescription
SidSID<PN>Optional

The SID of a Twilio IncomingPhoneNumber resource that represents the Twilio Number you would like to assign to your Proxy Service.

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

PhoneNumberstring<phone-number>Optional

The phone number in E.164 format. E.164 phone numbers consist of a + followed by the country code and subscriber number without punctuation characters. For example, +14155551234.


IsReservedbooleanOptional

Whether the new phone number should be reserved and not be assigned to a participant using proxy pool logic. See Reserved Phone Numbers for more information.

Add a Phone Number

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

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function createPhoneNumber() {
_18
const phoneNumber = await client.proxy.v1
_18
.services("KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
_18
.phoneNumbers.create({ sid: "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" });
_18
_18
console.log(phoneNumber.sid);
_18
}
_18
_18
createPhoneNumber();

Output

_17
{
_17
"sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"service_sid": "KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"date_created": "2015-07-30T20:00:00Z",
_17
"date_updated": "2015-07-30T20:00:00Z",
_17
"phone_number": "+1987654321",
_17
"friendly_name": "Friendly Name",
_17
"iso_country": "US",
_17
"capabilities": {
_17
"sms_outbound": true,
_17
"voice_inbound": false
_17
},
_17
"url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"is_reserved": false,
_17
"in_use": 0
_17
}

Add a Reserved Phone Number

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

_21
// Download the helper library from https://www.twilio.com/docs/node/install
_21
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_21
_21
// Find your Account SID and Auth Token at twilio.com/console
_21
// and set the environment variables. See http://twil.io/secure
_21
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_21
const authToken = process.env.TWILIO_AUTH_TOKEN;
_21
const client = twilio(accountSid, authToken);
_21
_21
async function createPhoneNumber() {
_21
const phoneNumber = await client.proxy.v1
_21
.services("KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
_21
.phoneNumbers.create({
_21
isReserved: true,
_21
sid: "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_21
});
_21
_21
console.log(phoneNumber.sid);
_21
}
_21
_21
createPhoneNumber();

Output

_17
{
_17
"sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"service_sid": "KSXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_17
"date_created": "2015-07-30T20:00:00Z",
_17
"date_updated": "2015-07-30T20:00:00Z",
_17
"phone_number": "+1987654321",
_17
"friendly_name": "Friendly Name",
_17
"iso_country": "US",
_17
"capabilities": {
_17
"sms_outbound": true,
_17
"voice_inbound": false
_17
},
_17
"url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"is_reserved": true,
_17
"in_use": 0
_17
}

(information)

Info

Note: You should pass a PhoneNumber or a Sid (identifying a phone number on your account). Only one of them is required. Passing both will return an error.


Fetch a PhoneNumber resource

GET https://proxy.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers/{Sid}

Path parameters

Property nameTypeRequiredPIIDescription
ServiceSidSID<KS>required

The SID of the parent Service of the PhoneNumber resource to fetch.

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

SidSID<PN>required

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

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

Fetch a PhoneNumber

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

_19
// Download the helper library from https://www.twilio.com/docs/node/install
_19
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19
_19
// Find your Account SID and Auth Token at twilio.com/console
_19
// and set the environment variables. See http://twil.io/secure
_19
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19
const authToken = process.env.TWILIO_AUTH_TOKEN;
_19
const client = twilio(accountSid, authToken);
_19
_19
async function fetchPhoneNumber() {
_19
const phoneNumber = await client.proxy.v1
_19
.services("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.phoneNumbers("PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.fetch();
_19
_19
console.log(phoneNumber.sid);
_19
}
_19
_19
fetchPhoneNumber();

Output

_17
{
_17
"sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"date_created": "2015-07-30T20:00:00Z",
_17
"date_updated": "2015-07-30T20:00:00Z",
_17
"phone_number": "12345",
_17
"friendly_name": "Friendly Name",
_17
"iso_country": "US",
_17
"capabilities": {
_17
"sms_outbound": true,
_17
"voice_inbound": false
_17
},
_17
"url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"is_reserved": false,
_17
"in_use": 0
_17
}


Get the list of Phone Numbers associated with a Proxy Service

GET https://proxy.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers

Path parameters

Property nameTypeRequiredPIIDescription
ServiceSidSID<KS>required

The SID of the parent Service of the PhoneNumber resources to read.

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

Query parameters

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.

List multiple PhoneNumbers

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

_18
// Download the helper library from https://www.twilio.com/docs/node/install
_18
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_18
_18
// Find your Account SID and Auth Token at twilio.com/console
_18
// and set the environment variables. See http://twil.io/secure
_18
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_18
const authToken = process.env.TWILIO_AUTH_TOKEN;
_18
const client = twilio(accountSid, authToken);
_18
_18
async function listPhoneNumber() {
_18
const phoneNumbers = await client.proxy.v1
_18
.services("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_18
.phoneNumbers.list({ limit: 20 });
_18
_18
phoneNumbers.forEach((p) => console.log(p.sid));
_18
}
_18
_18
listPhoneNumber();

Output

_30
{
_30
"meta": {
_30
"page": 0,
_30
"page_size": 50,
_30
"first_page_url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers?PageSize=50&Page=0",
_30
"previous_page_url": null,
_30
"next_page_url": null,
_30
"key": "phone_numbers",
_30
"url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers?PageSize=50&Page=0"
_30
},
_30
"phone_numbers": [
_30
{
_30
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_30
"service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_30
"sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_30
"date_created": "2015-07-30T20:00:00Z",
_30
"date_updated": "2015-07-30T20:00:00Z",
_30
"phone_number": "+1987654321",
_30
"friendly_name": "Friendly Name",
_30
"iso_country": "US",
_30
"capabilities": {
_30
"sms_outbound": true,
_30
"voice_inbound": false
_30
},
_30
"url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_30
"is_reserved": false,
_30
"in_use": 0
_30
}
_30
]
_30
}


Update a PhoneNumber resource

POST https://proxy.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers/{Sid}

Path parameters

Property nameTypeRequiredPIIDescription
ServiceSidSID<KS>required

The SID of the parent Service of the PhoneNumber resource to update.

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

SidSID<PN>required

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

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

Request body parameters

Property nameTypeRequiredPIIDescription
IsReservedbooleanOptional

Whether the phone number should be reserved and not be assigned to a participant using proxy pool logic. See Reserved Phone Numbers for more information.

Update a PhoneNumber

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

_19
// Download the helper library from https://www.twilio.com/docs/node/install
_19
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_19
_19
// Find your Account SID and Auth Token at twilio.com/console
_19
// and set the environment variables. See http://twil.io/secure
_19
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_19
const authToken = process.env.TWILIO_AUTH_TOKEN;
_19
const client = twilio(accountSid, authToken);
_19
_19
async function updatePhoneNumber() {
_19
const phoneNumber = await client.proxy.v1
_19
.services("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.phoneNumbers("PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_19
.update({ isReserved: false });
_19
_19
console.log(phoneNumber.sid);
_19
}
_19
_19
updatePhoneNumber();

Output

_17
{
_17
"sid": "PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"account_sid": "ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"service_sid": "KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"date_created": "2015-07-30T20:00:00Z",
_17
"date_updated": "2015-07-30T20:00:00Z",
_17
"phone_number": "12345",
_17
"friendly_name": "Friendly Name",
_17
"iso_country": "US",
_17
"capabilities": {
_17
"sms_outbound": true,
_17
"voice_inbound": false
_17
},
_17
"url": "https://proxy.twilio.com/v1/Services/KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/PhoneNumbers/PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_17
"is_reserved": false,
_17
"in_use": 0
_17
}


Remove a Phone Number from a Proxy Service

DELETE https://proxy.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers/{Sid}

Path parameters

Property nameTypeRequiredPIIDescription
ServiceSidSID<KS>required

The SID of the parent Service of the PhoneNumber resource to delete.

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

SidSID<PN>required

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

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

Delete a PhoneNumber

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

_17
// Download the helper library from https://www.twilio.com/docs/node/install
_17
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_17
_17
// Find your Account SID and Auth Token at twilio.com/console
_17
// and set the environment variables. See http://twil.io/secure
_17
const accountSid = process.env.TWILIO_ACCOUNT_SID;
_17
const authToken = process.env.TWILIO_AUTH_TOKEN;
_17
const client = twilio(accountSid, authToken);
_17
_17
async function deletePhoneNumber() {
_17
await client.proxy.v1
_17
.services("KSaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_17
.phoneNumbers("PNaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")
_17
.remove();
_17
}
_17
_17
deletePhoneNumber();


Rate this page: