Messaging Service PhoneNumber Resource
The PhoneNumber subresource of a Service instance represents a phone number you have associated to the Service.
When sending a message with your Messaging Service, Twilio will select a phone number from the service for delivery.
Inbound messages received on any phone number associated to a Messaging Service are passed to the inbound request URL of the Service with the TWiML parameters that describe the message .
Resource properties sid
type: SID<PN>
The unique string that we created to identify the PhoneNumber resource.
date_created
type: string<date-time>
date_updated
type: string<date-time>
phone_number
type: string<phone-number>
capabilities
type: array[string]
An array of values that describe whether the number can receive calls or messages. Can be: Voice
, SMS
, and MMS
.
url
type: string<uri>
The absolute URL of the PhoneNumber resource.
POST https://messaging.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers
Add a Phone Number to your Messaging Service by creating a PhoneNumber resource.
Each Service can have no more than 400 phone numbers by default. If you think you might need a higher limit, contact Twilio Support(link takes you to an external page) about a Messaging Service number limit increase, and include an explanation of your use case.
URI parameters Request body parameters PhoneNumberSid
type: SID<PN> Required
The SID of the Phone Number being added to the Service.
Create a PhoneNumber Resource to add it to a Messaging Service
_13 // Download the helper library from https://www.twilio.com/docs/node/install
_13 // Find your Account SID and Auth Token at twilio.com/console
_13 // and set the environment variables. See http://twil.io/secure
_13 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_13 const authToken = process.env.TWILIO_AUTH_TOKEN;
_13 const client = require('twilio')(accountSid, authToken);
_13 client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_13 phoneNumberSid: 'PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
_13 .then(phone_number => console.log(phone_number.sid));
_11 "sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11 "service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11 "date_created": "2015-07-30T20:12:31Z",
_11 "date_updated": "2015-07-30T20:12:33Z",
_11 "phone_number": "+987654321",
_11 "country_code": "US",
_11 "url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers/PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
GET https://messaging.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers/{Sid}
URI parameters Sid
type: string
The SID of the PhoneNumber resource to fetch.
_11 // Download the helper library from https://www.twilio.com/docs/node/install
_11 // Find your Account SID and Auth Token at twilio.com/console
_11 // and set the environment variables. See http://twil.io/secure
_11 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11 const authToken = process.env.TWILIO_AUTH_TOKEN;
_11 const client = require('twilio')(accountSid, authToken);
_11 client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .phoneNumbers('PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .then(phone_number => console.log(phone_number.sid));
_11 "sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11 "service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_11 "date_created": "2015-07-30T20:12:31Z",
_11 "date_updated": "2015-07-30T20:12:33Z",
_11 "phone_number": "12345",
_11 "country_code": "US",
_11 "url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers/PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
GET https://messaging.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers
URI parameters PageSize
type: integer
How many resources to return in each list page. The default is 50, and the maximum is 1000.
Page
type: integer
The page index. This value is simply for client state.
PageToken
type: string
The page token. This is provided by the API.
_11 // Download the helper library from https://www.twilio.com/docs/node/install
_11 // Find your Account SID and Auth Token at twilio.com/console
_11 // and set the environment variables. See http://twil.io/secure
_11 const accountSid = process.env.TWILIO_ACCOUNT_SID;
_11 const authToken = process.env.TWILIO_AUTH_TOKEN;
_11 const client = require('twilio')(accountSid, authToken);
_11 client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_11 .then(phoneNumbers => phoneNumbers.forEach(p => console.log(p.sid)));
_24 "first_page_url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers?PageSize=20&Page=0",
_24 "previous_page_url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers?PageSize=20&Page=0",
_24 "next_page_url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers?PageSize=20&Page=1",
_24 "key": "phone_numbers",
_24 "url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers?PageSize=20&Page=0"
_24 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24 "service_sid": "MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24 "sid": "PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_24 "date_created": "2015-07-30T20:12:31Z",
_24 "date_updated": "2015-07-30T20:12:33Z",
_24 "phone_number": "+987654321",
_24 "country_code": "US",
_24 "url": "https://messaging.twilio.com/v1/Services/MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX/PhoneNumbers/PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
DELETE https://messaging.twilio.com/v1/Services/{ServiceSid}/PhoneNumbers/{Sid}
Warning Removing a phone number from the Service does not release the number from your account. You must release a phone number from your Account to disassociate and delete the phone number from the Service.
Returns a "204 NO CONTENT" if the phone number was successfully removed from the service.
URI parameters Sid
type: string
The SID of the PhoneNumber resource to delete.
_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 client.messaging.v1.services('MGXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
_10 .phoneNumbers('PNXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')