Use cases
Customer registration
Verify a new customer's mobile number while they create an account.
- The sign-up form collects the number with the rest of the details.
- Your server validates the details, then sends a code with
purpose: "signup". Create the account as unverified, or keep the sign-up data in the session until the number is confirmed. - Show a code box. Your server checks the code with the verification
idfrom the session. - On
valid: true, setphone_verified_aton the account. Use the number the server sent the code to, not one sent by the browser.
Details that matter
- One account per number: check that no other account owns the number before sending a code, so you don't pay to verify a number you'll refuse anyway.
- Unverified accounts: decide what they can do (e.g. browse but not order), and remove ones that never verify.
- Changing the number later: treat it as a new verification (phone verification), and keep the old number until the new one is confirmed.
- Abuse: sign-up forms are public. Add a CAPTCHA or a per-IP limit before the send, so bots can't make you pay for messages to random numbers.