Provisioning a phone number is a two-step process. With the “AvailablePhoneNumbers” and “IncomingPhoneNumbers List” API resources, you can automate the process of searching for and buying Twilio phone numbers.
Searching for Twilio phone numbers
You can search for available phone numbers by making GET requests to the subresources of the AvailablePhoneNumbers API resource. Depending on your use case, you may need different types of phone numbers that provide different capabilities. For example, you may want to get a toll free number for your business so your callers can reach you for free, or you may want to get SMS-enabled mobile numbers in Europe to send messages to your customers around the world. The following subresources are available under the “AvailablePhoneNumbers” resource for different types of numbers:
- Local List Subresource: for available local numbers
- Toll Free List Subresource: for available toll free numbers
- Mobile List Subresource: for available mobile numbers
Use the query string parameters such as SmsEnabled, MmsEnabled or VoiceEnabled in the GET request to filter the list of numbers returned by Twilio to find the phone number with the capabilities you need. The “Capabilities” property is also available for each phone number instance so you can easily tell what capabilities a number carries:
<Capabilities> <Voice>true</Voice> <SMS>true</SMS> <MMS>false</SMS> </Capabilities>
Buying Twilio phone numbers
When you identify a number that you want to buy, make a POST request to the IncomingPhoneNumbers List API resource of your project. You will be charged when you provision the number, and the number will appear on the Numbers page in the console. Note that you must upgrade your Twilio project in order to provision additional phone numbers using our API.