Documentation
Testing in sandbox
Use a test key to build and test your integration end to end without sending real messages or spending balance.
Every test key (otp_test_…) runs in the sandbox. The full flow works exactly as
in production, but nothing is delivered and nothing is charged, so you can wire up
send and verify with confidence before going live.
What the sandbox does
POST /otp/sendreturns a realotp_idand apendingstatus, but no message is delivered.POST /otp/verifyaccepts the fixed code123456as correct. Any other code is treated as a miss, so you can test both the success and failure paths. (The code is the digits counting up, sized to your account’s own code length, so an account moved off the 6-digit default verifies with1234rather than123456.)- On the WhatsApp channel in a link mode, send returns a sample
action_urlso you can see the shape. The link is not live and no code is delivered over WhatsApp in the sandbox, so the OTP stayspending. To finish a sandbox flow, move it onto SMS with a resend ({"channel":"sms"}, code is then the fixed123456), or use a live key against your business number to test WhatsApp end to end. completionis always"code"in the sandbox, whatever WhatsApp mode your account runs. The Inbound approve flow can only be exercised with a live key. Under the Template mode a sandbox send has noaction_urland the fixed123456verifies directly, as on SMS. See WhatsApp verification.- Resend and status behave as in production, minus real delivery.
A full sandbox run
# send (sandbox: no real message)
curl -X POST https://api.otp.com/api/v1/otp/send \
-H "Authorization: Bearer otp_test_•••" \
-H "Content-Type: application/json" \
-d '{"recipient":"+14155552671","locale":"en"}'
# -> { "otp_id": "9f3c1b2a-…", "status": "pending", "channel": "sms", "completion": "code" }
# verify with the fixed sandbox code
curl -X POST https://api.otp.com/api/v1/otp/verify \
-H "Authorization: Bearer otp_test_•••" \
-H "Content-Type: application/json" \
-d '{"otp_id":"9f3c1b2a-…","code":"123456"}'
# -> { "otp_id": "9f3c1b2a-…", "status": "approved", "matched": true }
Testing the failure path
Send any code other than 123456 to POST /otp/verify to see matched: false
and exercise your retry and error handling. Exhaust the attempts to see the OTP
move to failed.
Going live
When your integration works in the sandbox, create a live key (otp_live_…) on the
API Keys screen and swap it in. The requests are identical; only the key
changes. There is no separate base URL and no code path to flip.
Test numbers
App Store and Google Play reviewers, and your own testers, run your live build with its live key, so the sandbox cannot help them and they will not receive a real SMS. For them, register test numbers on the Test Numbers tab of the API Keys screen: up to 10 per app, each a phone number or an email address with a fixed code. Let us generate the code or set your own (digits at your account’s code length), and add a label and an expiry if you want them.
When a live key (otp_live_… or otp_pk_live_…) starts an OTP for a test number:
- No message is sent and nothing is charged. If you change your account’s code length, update each test number’s code (edit the entry and set a new code, or regenerate it); until then, sends to it go out as real, billed messages.
POST /otp/sendreturns the normal response. It never contains the code.POST /otp/verifyaccepts the fixed code, and theotp.approvedandotp.failedwebhooks carrytest_recipient: true.- Rate limits, fraud protection and your country and channel settings still apply, as on a real send. A phone number in a country that is closed for the app cannot be registered.
- If the test number is removed or expires while an OTP is in flight, a resend is
refused with
409 ResendNotAllowedError. Start a new OTP instead.
Test keys (otp_test_…, otp_pk_test_…) ignore test numbers and keep the sandbox
behavior above.
Anyone with the number and its code can sign in to your live app as that user, so remove the entry when the review ends, or set an expiry.