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
- No message to read. The text is not delivered or stored anywhere a test can fetch it, so the code your app generated is lost.
- Verify is not covered. When Twilio Verify generates the code, test credentials give you no way to learn it or approve the check.
- Fixed recipients. Outcomes depend on magic numbers, not on the numbers your test actually enters.
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 credentials | otpmock | |
|---|---|---|
| Real SMS sent | No | No |
| Test can read the message | No | Yes |
| Verify v2 start and check | No | Yes |
| Any recipient number | Magic numbers | Yes |
| Cost | Free | Free 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.
The free plan includes 100 messages a month. No card required.
Get a free API key