Twilio provides you with a set of test credentials so you can
exercise parts of the REST API without charging your account. You
can find your credentials in the
Auth Tokens page of your Console.
You use these credentials in the same way as your live credentials, with one restriction being that you cannot log in to the Twilio CLI with your test credentials. However,
when you authenticate with your test credentials, we will not charge your
account, update the state of your account, or connect to real phone numbers.
You can now pretend to buy a phone number or send an SMS, without actually
doing so.
To protect your production data, your test credentials can't interact with the
data in your real account. For example, you can't use phone numbers from your
real account as the 'From' number in requests made with your test credentials.
Supported Resources
Your test credentials can currently be used to interact with the following
three resources:
Buying phone numbers:
POST /2010-04-01/Accounts/{TestAccountSid}/IncomingPhoneNumbers
Sending SMS messages:
POST /2010-04-01/Accounts/{TestAccountSid}/Messages
Making calls:
POST /2010-04-01/Accounts/{TestAccountSid}/Calls
Requests to any other resource with test credentials will receive a 403 Forbidden response. In the future, we may enable these resources for testing
as well.
When you make an API request with your test credentials, Twilio will validate
all input as though the request were made with your real credentials. However,
there are some cases when a request's validity depends on the state of Twilio.
For instance, if you are trying to buy a phone number and that phone number is
no longer available, Twilio will return an error.
To write test cases that expect and handle errors which depend on
the state of Twilio, we provide magic inputs. For the case mentioned above,
there is a magic phone number +15005550000 which if you pass it as the
'PhoneNumber' parameter in a POST to IncomingPhoneNumbers, will always return
an error saying the number is unavailable.
The full set of magic inputs is detailed below.
Test Buying A Number
If you'd like to test API requests to the phone numbers resource without
provisioning a number for your account, you can use your test
credentials.
You 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.
Just POST to the normal phone number purchase API endpoint using your test
credentials to authenticate and your TestAccountSid in the URL:
_10
POST https://api.twilio.com/2010-04-01/Accounts/{TestAccountSid}/IncomingPhoneNumbers
Parameters
All of the existing phone number purchase
parameters will work. In
addition, we provide some specific values for certain parameters to help you
generate success and failure cases.
Successfully provision a number. Purchase will always be completed successfully if
you attempt to purchase the magic number +15005550006. Any other parameters
you send with the request, such as a VoiceUrl or a StatusCallback, will be
included in the API response.
Purchase a number
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl
_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
Just specify an invalid number as your input. Twilio will try to convert
letters to numbers, but specifying a very short or very long string of either
will fail.
Attempt to purchase an invalid number
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl
_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
If you'd like to test API requests to send SMS messages without
charging your account or sending an SMS, you can use your test credentials.
Just POST to the normal SMS API endpoint using your test
credentials to authenticate and your TestAccountSid in the URL:
_10
POST https://api.twilio.com/2010-04-01/Accounts/{TestAccountSid}/Messages
Parameters
All of the existing outbound SMS
parameters will work, except for MessagingServiceSid. In addition,
we provide some specific values for certain parameters to help you generate
success and failure cases.
From
Your test credentials don't have access to any valid 'From' phone numbers on
your real account. Therefore, the only phone numbers you should use as 'From'
numbers are the magic numbers listed here.
Successfully send an SMS. Trigger this by sending an SMS using the magic number
+15005550006 as the From number, and a regular phone number for the To
number.
Create a message
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl
_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure
If you'd like to test API requests to the outbound call endpoint without
charging your account or making a call, you can use your test credentials. Note
that since no call is made, Twilio will not request the URL passed in
the 'Url' parameter and no TwiML will be executed.
Just POST to the normal outbound call API endpoint using your test
credentials to authenticate and your TestAccountSid in the URL:
_10
POST https://api.twilio.com/2010-04-01/Accounts/{TestAccountSid}/Calls
Parameters
All of the existing outbound call
parameters will work. In
addition, we provide some specific values for certain parameters to help you
generate success and failure cases.
From
Your test credentials don't have access to any valid 'From' phone numbers on
your real account. Therefore the only phone number you should use as a 'From'
number is the magic number listed here.
Attempt to call an international number in a country without permission turned
on. Trigger this by passing the magic number +15005550003 as the To number.
Making a call to an international number in a country without permissions turned on
Node.js
Python
C#
Java
Go
PHP
Ruby
twilio-cli
curl
_14
// Download the helper library from https://www.twilio.com/docs/node/install
_14
// Find your Account SID and Auth Token at twilio.com/console
_14
// and set the environment variables. See http://twil.io/secure