# Verify a phone number on WhatsApp: by an inbound message, or with a code

> Two ways to prove a person owns a phone number: they send you a prefilled WhatsApp message (no paid message, no code to type), or you send a code with an authentication template and check it.

| | By an inbound message (`/verify/inbound`) | With a code (`/verify`) |
| --- | --- | --- |
| The person | taps a link (or scans a QR code) and sends the prefilled message | types the code they got on WhatsApp |
| You need | nothing else | an approved AUTHENTICATION template |
| Cost | none: they write to you | one authentication message per code |
| Done when | they send it (and tap **Yes, it was me**) | `POST /verify/{id}/check` says `approved` |

Both send `verify.completed` or `verify.failed` to your webhooks, and `GET /v1/{number}/verify/{id}` shows the status. AI agents use the MCP tools `start_inbound_verification`, `send_verification_code`, `check_verification_code` and `get_verification`.

<a id="inbound"></a>

## By an inbound message

```bash
curl -X POST "https://api.app2email.com/v1/YOUR_NUMBER/verify/inbound" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"reference": "signup-4711", "label": "MyShop"}'
```

The answer has `link` (a wa.me link with `Please verify my number. Code: K7Q3MX9P` prefilled), `qr_svg` (the same as a QR code, for a desktop page) and `id`. When the person sends the message, we ask them "You are confirming your number for <your business> (MyShop). Was that you?". If they tap **Yes, it was me**, the verification completes with their `phone`. The message itself is not forwarded by e-mail, and gets no auto reply and no agent answer.

**Protect against relay attacks.** Someone could start a verification on your site, then trick another person into sending the code, so their own session gets confirmed with the victim's number. Against that:
- keep `confirm: "button"` (the default): the victim is asked, and can say No;
- pass `expected_phone` when the person typed their number on your site: a message from any other phone fails;
- bind `id` to the browser session that started it, and never accept an id from a URL.

A code is 8 characters (no 0, O, 1, I or L), works once and only for your number, and expires after `ttl_seconds` (10 minutes unless you set it, at most an hour).

<a id="code"></a>

## With a code

```bash
curl -X POST "https://api.app2email.com/v1/YOUR_NUMBER/verify" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"to": "61412345678", "reference": "signup-4711"}'
```

Then check what the person types:

```bash
curl -X POST "https://api.app2email.com/v1/YOUR_NUMBER/verify/vf_3k9m2Lw8Rt5Yp1ZsQa7Xbw/check" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code": "482913"}'
```

| `status` | Meaning |
| --- | --- |
| `approved` | The right code. Only once: a later check answers `used`. |
| `wrong_code` | Not it; `attempts_left` says how many tries remain. |
| `too_many_attempts` | 5 wrong tries: this code is finished. Send a new one. |
| `expired` | Past `ttl_seconds` (5 minutes unless you set it, at most an hour). |

app2email keeps only a fingerprint of the code: it never appears in the message list, the Inbox, the Activity Log, the forwarded e-mail or a webhook. They show "verification code ••••••". The number needs an approved AUTHENTICATION template with a copy-code button (`409 no_auth_template` says how to create one). A sandbox key sends nothing, and the code is `000000`.

<a id="pumping"></a>

## OTP pumping: rate-limit your own form

Every code is a paid message. A known fraud drives a site's sign-up form so that it sends thousands of codes to numbers the attacker picks. Rate-limit your own form (per visitor, per number, a CAPTCHA). The [link settings](/guides/link-settings#settings) have three extra brakes, all **off** unless you set them:

| Setting | What it does |
| --- | --- |
| `verify_resend_cooldown_seconds` | No new code to the same number within this many seconds. |
| `verify_hourly_per_recipient` | At most this many codes to one number an hour. |
| `verify_allowed_calling_codes` | Codes only to numbers with these calling codes, for example `["61", "44"]`. |

<a id="errors"></a>

## Errors

| Code | Status | Meaning |
| --- | --- | --- |
| `invalid_verify_request` | 400 | A field is missing or not allowed (the message names it). |
| `verify_not_found` | 404 | No verification with that id on the number. |
| `no_auth_template` | 409 | No approved AUTHENTICATION template. |
| `verify_country_not_allowed` | 403 | Not in `verify_allowed_calling_codes`. |
| `verify_resend_too_soon` / `verify_recipient_limit` | 429 | One of the two limits above. |
| `verify_too_many_active` | 429 | 5,000 verifications are waiting on the number. |

The complete list is on [the errors page](/api/errors).
