# Phone number verification

> Confirm that a number belongs to the customer, for example on their profile or before saving a delivery number.

The general pattern behind every other guide:

1. **Send:** your server sends a code to the number (`purpose: "verify"`) and stores `{ id, number }` against the user or session.
2. **Check:** the customer types the code; your server checks it with the stored `id`.
3. **Record:** on `valid: true`, your server saves the stored number as verified, with the time.

## Where to keep the pending verification

| Your app | Store `{ id, number }` in |
|---|---|
| Server-rendered site with sessions (PHP, Laravel, Django, Rails, Express) | The server-side session |
| Next.js / serverless | A signed, httpOnly cookie (see the [Next.js example](/docs/examples/nextjs)) or your database |
| Mobile app with an API | Your database, keyed by the user; the app only gets "code sent" |

Never let the browser or app send back the number or the `id` at step 2: otherwise someone can verify one number and claim another.

## Changing a verified number

Keep the old number active until the new one is verified, then switch. Notify the old number (by text or email) that it was replaced, if your business needs that level of protection.
