Sending and Verifying OTPs
1
Send an OTP
To verify a user’s phone number, you’ll first need to send them an OTP.
The
name parameter is optional, but recommended. It customizes the message to say “Your [name] code is…”, e.g. “Your Twilio code is…”2
Verify the Code
When your user inputs the code, verify it using the OTP ID from the previous step.
The verification will return a boolean (true/false). OTPs expire 15 minutes after sending.
3
Resend if Needed
If needed, you can resend an OTP using the original OTP ID.
Resending an OTP does not renew its expiry time.
Parameters
otp.send(params)
Response
otp.verify(params)
Response
Indicates whether the OTP was successfully verified. Returns
true if valid, false if invalid or expired.otp.resend(params)
Response
Reverse OTP
Reverse OTP verifies a phone number by having the user send a code to you. Initiate a session withcontiguity.otp.reverse.initiate():
number to require that exact sender:
service to "sms" or "imessage". It defaults to "sms" when omitted. iMessage requires an active iMessage-capable leased number and an iMessage entitlement.
Use the returned otp_id to check or cancel the session:
otp.reverse.initiate(params?)
Optional expected sender phone number in E.164. Omit to discover the number from the inbound message.
Optional destination number the user sends the code to. Required as a leased iMessage-capable number when
service is "imessage".Optional webhook URL called after verification. Falls back to your configured webhook preferences.
Supported Languages
Contiguity currently supports 33 languages for OTPs, including:English (en), Afrikaans (af), Arabic (ar), Catalan (ca), Chinese / Mandarin (zh), Cantonese (zh-hk), Croatian (hr), Czech (cs), Danish (da), Dutch (nl), Finnish (fi), French (fr), German (de), Greek (el), Hebrew (he), Hindi (hi), Hungarian (hu), Indonesian (id), Italian (it), Japanese (ja), Korean (ko), Malay (ms), Norwegian (nb), Polish (pl), Portuguese - Brazil (pt-br), Portuguese (pt), Romanian (ro), Russian (ru), Spanish (es), Swedish (sv), Tagalog (tl), Thai (th), Turkish (tr), and Vietnamese (vi)
