Private Phone Numbers for SMS Testing
Choose a private SMS test number, assign it to your test user, receive the right verification text and manage number reuse safely across automated tests.
A signup test needs somewhere to receive its verification text. A phone-number-shaped string can check the form, but it cannot complete the SMS journey. With MailSlurp, you assign a private phone number to a test user, receive the application's message and use its code to finish verification.
A disposable phone number in this workflow is a controlled testing resource. You choose when to reuse or retire it. It is a rented real number, so creating and deleting one for every test is a different decision from creating a temporary email inbox.
Choose the right kind of test phone number
Start with what you need to prove:
- A format-only test value checks validation, required fields or country-code formatting. Use the test values documented for your application or provider; do not send SMS to an arbitrary plausible number.
- A private SMS-capable number receives real messages. Use it when the test must read an OTP, confirm a notification or process an inbound reply.
- A public shared SMS inbox does not give your test exclusive control over who reads a code or which messages arrive. MailSlurp's private numbers let you keep the recipient and its messages within your account's workflow.
For OTP and account-recovery testing, use a number assigned to a test identity you control. MailSlurp's phone-number service combines dashboard access, SMS retrieval, waits and webhooks, so you can begin manually and automate the same journey later.
Check availability and the sending route first
Choose a country and number variant that suit your application and SMS provider. Availability varies, and a sender may treat mobile, toll-free or other number types differently. Test the actual route your application uses, particularly if it sends from a short code.
The phone documentation explains current provisioning. Add the appropriate phone plan, then select a number in the dashboard. API provisioning requires a paid plan and API creation enabled on the account. Review the available country, variant and price before creating the number.
Phone creation incurs a monthly number rental; SMS usage is separate under the selected plan. Use the current phone pricing for your account instead of treating a test number as free or assuming it expires at the end of a test.
Assign one number to the whole verification flow
Keep the phone number and its MailSlurp ID together. Give the number to the application as its SMS destination. Use the ID when retrieving that number's messages through the API.
For a first manual check:
- Select your assigned MailSlurp number and use it for a test user in your development or staging app.
- Request a new verification code from that app.
- Open the resulting SMS in MailSlurp and confirm the expected sender and request.
- Submit the code to the app, preserving any leading zero.
- Check that the intended account is verified or signed in.
Receiving a text proves receipt. The final step proves that your application accepted it for the correct user. The SMS testing tutorial extends this flow to resend, expiry, reuse and failure cases, with a runnable local example of the application's OTP rules.
Reuse numbers without sharing test state
A small, managed number inventory can support repeated tests without provisioning a new rental on every run. Give each active test exclusive use of its number until the application flow has finished.
For parallel suites, phone pools and leases let a test reserve a number and release that reservation afterward. Keep the lease through the final account assertion, including any resend checks. A second worker should not use the same number while the first is still waiting for a code.
When selecting an existing number directly, use its assigned ID or an explicit lookup. Choosing the first number returned by an account-wide list can attach the test to an unrelated resource.
Also check the application's policy for reusing a number across accounts. Cleaning MailSlurp messages does not remove a phone association from your application database.
Receive the message in code or through a webhook
Use a bounded SMS wait for a test that needs the next message before continuing. Capture a start time before the app sends, and restrict retrieval to the assigned phone ID. Match the expected sender or content as well when the workflow has a known signature.
The receive-SMS API guide includes the complete explicit-number example. It also explains how to fetch a message by ID and receive a NEW_SMS webhook for an asynchronous workflow.
Unread state alone is a weak way to identify a fresh message: a dashboard read or another consumer can change it. Use the request window and message content, then submit the extracted code and assert the application's result.
For framework setup, continue with the Playwright SMS guide or Cypress SMS guide.
Keep cleanup separate from releasing the number
There are three different cleanup jobs:
- The application account: remove or reset the test identity according to your app's test-data policy.
- The SMS messages: retain only the evidence you need and delete test messages when appropriate. Avoid recording OTP bodies in general CI logs.
- The number or pool lease: release a lease when the test finishes. Retiring the rented number itself is a separate lifecycle and billing action.
Do not put number deletion into a generic message-cleanup helper. A reused number may still be assigned to another scheduled test or needed for a later recovery check.
If the verification text does not arrive
Confirm that the app requested a new SMS for the exact assigned number, in the expected country format. Check its sending provider's response, then the number's message history and your wait's time boundary.
If a normal message arrives but the app's short-code message does not, investigate that sending route and number capability. Repeated resends can invalidate earlier codes and make the diagnosis harder.
Follow the missing-message checks to distinguish a send failure, a receipt problem and a code the application rejects after receipt.
Ready to test the complete journey? Set up a private SMS number, receive your own app's verification text and check the account it signs in.