API docs
Send a verification
Create a verification to deliver a one-time passcode. OTPRelay generates the code and sends the SMS from the OTPRelay sender, with automatic route failover.
POST
/v1/verificationsYou only need to. Everything else has a sensible default - OTPRelay generates the code and sends the SMS from the OTPRelay sender. The response is a verification object with status: "pending".
The sender is always OTPRelay and the message template is fixed - see Sender & message.
Prefer to generate your own code? Use Send a code instead - OTPRelay just delivers it.
Request body
tostringrequired- The destination phone number in E.164 format, e.g.
+966512345678. code_lengthintegeroptional- Number of digits in the code, 4-8. Defaults to 6.
expiryintegeroptional- Time-to-live for the code in seconds, 60-3600. Defaults to 600 (10 minutes).
custom_codestringoptional- A pre-generated code (sandbox or migration use). Requires custom codes enabled on the account.
webhook_urlstringoptional- An HTTPS URL to receive this verification's events. See Webhooks & events.
metadataobjectoptional- Up to 10 key/value pairs echoed back on the verification and its webhook events.
Request
POST /v1/verifications
Response
Returns 201 Created with the verification. Inspect attempts[] to see which carrier each SMS send used, including any automatic route failover.
201 Created
Send limits
A verification accepts up to 5 sendsto the same number before it's closed (
max_send_attempts). Re-sending within the expiry window delivers the samecode - it doesn't generate a new one.Next, check the code the user entered.