Docs

Guides

Phone verification

Send a one-time code to a user's phone number and check it, in the sandbox and in live.

A user is created with an unverified phone number in live. Two routes let you verify it with a one-time code sent by WhatsApp, with an automatic fallback to SMS:

  1. Send a verification code, POST /v1/users/{id}/verification
  2. Check the verification code, POST /v1/users/{id}/verification/check

On success the user's verified field becomes true. No event is emitted for it: read the user to see the result.

# 1. Send the code
curl -X POST "https://sdk.tilt-pay.com/v1/users/4821/verification" \
  -H "Authorization: Bearer $TILT_PAY_API_KEY"

# 2. Check what the user typed
curl -X POST "https://sdk.tilt-pay.com/v1/users/4821/verification/check" \
  -H "Authorization: Bearer $TILT_PAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"code": "123456"}'

The first call returns a verification object with status: "pending", expires_at and resend_available_at. Once the code is accepted the check returns status: "approved".

Sandbox#

Nothing is sent. The code is always 123456, there is no resend delay, and the hourly limits are ten times higher. Users created with a sandbox key are already verified, so you only need these routes to test your flow end to end: create a user, then send and check the code.

Live#

Note Live phone verification is switched on per platform by Tilt Pay. When it is not enabled, calls made with a live key answer 403 live_feature_unavailable. Check that your organization has live access first (see Going live).
  • A code is valid for 10 minutes and is invalidated after 5 incorrect attempts. Sending a new code replaces any pending one.
  • Limits: 60 seconds between two codes for the same user, 5 codes per user per hour, 20 per IP address per hour and 300 per project per hour. Above them you get 429 rate_limit_exceeded with a Retry-After header.
  • The code is 4 to 10 digits. Your user types it in your app: never display it from the API (it is never returned).
  • The answers never reveal whether a number exists elsewhere.

Errors#

StatusCodeMeaning and what to do
409already_verifiedThe number is already verified (live). Nothing to do.
409no_pending_verificationNo code is pending: send one first.
409user_suspendedThe user is suspended.
422invalid_verification_codeWrong code. The message tells how many attempts remain; param is code.
422verification_expiredThe code is older than 10 minutes: send a new one.
422verification_attempts_exceeded5 wrong attempts: send a new code.
429rate_limit_exceededResend delay or hourly limit: wait for Retry-After seconds.
403live_feature_unavailableLive verification is not enabled for the platform.
503verification_unavailableThe messaging service is unavailable. Retry shortly: a failed check does not use an attempt.

Both routes accept an Idempotency-Key. See Errors for the full list of codes.