Guides / Twilio test credentials

Twilio test credentials: limits and alternatives for E2E tests

Updated October 8, 2026
Short answer

Twilio test credentials let you call the Messages API without sending, using magic numbers that return fixed results. Nothing is stored for your test to read, and Verify is not covered, so a login flow cannot complete. A Twilio-compatible mock inbox keeps the same SDK calls and lets the test read the code.

What test credentials do

Twilio gives each account a separate test Account SID and Auth Token. Requests made with them are validated and answered, but no message is sent and you are not charged. Magic phone numbers such as +15005550006 as a sender trigger specific outcomes, for example success or an invalid-number error.

Where they stop

They are good for checking that your request is well formed. They are not enough for a test that has to type a code into the UI.

Using a Twilio-compatible mock instead

otpmock implements the Twilio Messages and Verify v2 endpoints. In test environments the Twilio SDK sends its requests to otpmock; messages are stored per number and Verify checks are approved when the right code is submitted. Setup is on the Twilio provider page, and the full Verify walkthrough is in Test Twilio Verify without sending real SMS.

Twilio test credentialsotpmock
Real SMS sentNoNo
Test can read the messageNoYes
Verify v2 start and checkNoYes
Any recipient numberMagic numbersYes
CostFreeFree up to 100 messages a month

FAQ

Do I need to change my Twilio code?

No. Only the client construction changes in test environments, by passing a custom HTTP client. Your messages.create and verify calls stay the same.

Is otpmock affiliated with Twilio?

No. otpmock is an independent service that implements a compatible API for testing.

Product names are trademarks of their owners; otpmock is not affiliated with them. Descriptions of other products reflect their public documentation as of October 2026. Check their sites for current features and pricing.

Try it on your own suite

The free plan includes 100 messages a month. No card required.

Get a free API key

Related guides