Your test credentials allow you to test API requests to the phone number resource without creating a number for your account.
You will use these credentials in the same way as your live credentials. However, when you authenticate with your test credentials, we will not charge your account or purchase a phone number for you. This way, you can pretend to buy a phone number without actually doing so.
Send a POST
request to the normal phone number purchase API endpoint using your test credentials to authenticate, and your TestAccountSid
in the URL as seen below:
POST https://api.twilio.com/2010-04-01/Accounts/{TestAccountSid}/IncomingPhoneNumbers
Parameters
All the existing phone number purchase parameters will work. In addition, we provide some specific values for the PhoneNumbers
and AreaCode
parameters to help you generate success and failure cases. Any extra parameter such as VoiceUrl
or FriendlyName
will be returned in the response.
PhoneNumbers
AreaCode
Value | Description | Error Code |
---|---|---|
533 | This area code doesn't have any available phone numbers. | 21452 |
500 | This area code has an available number. | No error. |
Encoding-type
The body parameters must be encoded using the application/x-www-form-urlencoded
encoding type. This means that the request headers must use this encoding-type as the content-type
field. Here is an example below:
content-type: application/x-www-form-urlencoded
.
Use the API playground in this page test each parameter values for when:
- The phone number or area code is unavailable.
- The phone number is invalid.
- The phone number and area code are valid and available respectively.