Test your SMS Application
If you'd like to test API requests to send SMS messages without charging your account or actually sending an SMS, 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, update the state of your account, or connect to real phone numbers.
To protect your production data, your test credentials can't interact with the data in your real account. As a consequence, you can't use phone numbers from your real account as the 'From' number in requests made with your test credentials.
Simulate a successful message by sending an SMS using the magic number +15005550006
as the From
number, and a regular phone number for the To
number.
_20// Download the helper library from https://www.twilio.com/docs/node/install
_20const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20// Find your Account SID and Auth Token at twilio.com/console
_20// and set the environment variables. See http://twil.io/secure
_20const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20const authToken = process.env.TWILIO_AUTH_TOKEN;
_20const client = twilio(accountSid, authToken);
_20async function createMessage() {
_20 const message = await client.messages.create({
_20 body: "All in the game, yo",
_20 from: "+15005550006",
_20 to: "+5571981265131",
_20 console.log(message.body);
_28 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_28 "api_version": "2010-04-01",
_28 "body": "All in the game, yo",
_28 "date_created": "Thu, 24 Aug 2023 05:01:45 +0000",
_28 "date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",
_28 "date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",
_28 "direction": "outbound-api",
_28 "error_message": null,
_28 "from": "+15005550006",
_28 "messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_28 "sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_28 "subresource_uris": {
_28 "media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json"
_28 "campaign_name": "Spring Sale 2022",
_28 "message_type": "cart_abandoned"
_28 "to": "+5571981265131",
_28 "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
You can simulate an attempt to send a message to a non-mobile number. Trigger this by passing the magic number +15005550009
as the To
number.
_20// Download the helper library from https://www.twilio.com/docs/node/install
_20const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";
_20// Find your Account SID and Auth Token at twilio.com/console
_20// and set the environment variables. See http://twil.io/secure
_20const accountSid = process.env.TWILIO_ACCOUNT_SID;
_20const authToken = process.env.TWILIO_AUTH_TOKEN;
_20const client = twilio(accountSid, authToken);
_20async function createMessage() {
_20 const message = await client.messages.create({
_20 body: "Hey Mr Nugget, you the bomb!",
_20 from: "+15005550006",
_20 console.log(message.body);
_28 "account_sid": "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
_28 "api_version": "2010-04-01",
_28 "body": "Hey Mr Nugget, you the bomb!",
_28 "date_created": "Thu, 24 Aug 2023 05:01:45 +0000",
_28 "date_sent": "Thu, 24 Aug 2023 05:01:45 +0000",
_28 "date_updated": "Thu, 24 Aug 2023 05:01:45 +0000",
_28 "direction": "outbound-api",
_28 "error_message": null,
_28 "from": "+15005550006",
_28 "messaging_service_sid": "MGaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_28 "sid": "SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
_28 "subresource_uris": {
_28 "media": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Media.json"
_28 "campaign_name": "Spring Sale 2022",
_28 "message_type": "cart_abandoned"
_28 "to": "+15005550009",
_28 "uri": "/2010-04-01/Accounts/ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages/SMaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa.json"
There are many more magic numbers that you can check out in our API reference.