Skip to main content

How verification works

SafePassage is built on a shared age-verification platform. The verification flow, the Sessions API, the JavaScript SDK and the webhook format described in this documentation are platform capabilities, and they behave the same way in every integration. What is specific to SafePassage (your account, plans and billing, sandbox allowance, support and the addresses you call) is listed in SafePassage plans, billing and limits.

Read this page once before you integrate. Every guide uses the terms defined here.

The integration in one picture​

Your website (browser) Your server SafePassage
────────────────────── ─────────── ──────────────
1. User clicks "Verify age" ──▶ 2. Create a session
(secret key) ─────────────▶ returns sessionId + verifyUrl
3. Browser goes to verifyUrl ◀── redirect ◀──────────────────
4. User completes the hosted SafePassage verification (camera, maybe ID)
5. Browser returns to your returnUrl?sessionId=…&status=…
──▶ 6. Confirm the result
(secret key) ─────────────▶ returns verified / failed / …
7. Record the result against
the user and grant access
◀── signed webhook (optional, recommended)

Two rules make the integration safe:

  1. The browser never decides access. The status parameter on the return URL, the SDK callbacks and anything else the browser reports are notifications. A user can type ?status=verified into the address bar.
  2. Your server decides access, using one of two trusted signals:
    • the Validate Session API call made with your secret key, or
    • a webhook whose signature your server has checked.

Terms used in this documentation​

TermMeaning
AccountYour SafePassage organisation in the Dashboard. Keys, configuration, webhooks, usage and billing belong to the account. The API calls this the tenant, and returns its identifier as merchantId.
Publishable key (pk_…)A key that is safe to put in browser code. It can start a session using your account's configured policy. It cannot confirm a result.
Secret key (sk_…)A server-only key. It can start sessions, set a per-session policy and confirm results. Never put it in browser code, a mobile app or a public repository.
Key pairA publishable key and a secret key created together. Webhook endpoints can be limited to one key pair, for example one per website.
SessionOne verification attempt, identified by sessionId. A session lasts 10 minutes. Its result is kept after it ends.
Verification link (verifyUrl)The hosted SafePassage page for a session. Use it exactly as returned.
Return URL (returnUrl)Your page that the user comes back to. SafePassage adds sessionId, status and timestamp to it.
Confirm the resultCall POST /api/v1/sessions/validate with your secret key. This is the authoritative result.
External user ID (externalUserId)Your own identifier for the user, attached to the session so results, webhooks and Dashboard records can be matched to your user.
Verification modeL1 (selfie age estimate, with an ID check only when needed) or L2 (ID check every time). See Age policy and verification modes.
Challenge ageThe age the selfie estimate must reach in L1. It does not change the ID check, which always checks for 18+.
SandboxThe allowance of free, unbilled verifications a new account uses for testing. Sandbox verifications are real verifications. See Test your integration.

What happens to the user​

  1. The user opens the verification link and allows camera access.
  2. A liveness check confirms a real person is present.
  3. Depending on your verification mode:
    • L1: SafePassage estimates age from the selfie. If the estimate is at or above your challenge age, the user passes without an ID. Otherwise the user is asked for an ID.
    • L2: the user is always asked for an ID.
  4. When an ID is used, the document is checked, the date of birth is read and the user's face is compared with the ID photo (unless face matching is switched off for the session).
  5. After a successful verification the user returns to your return URL. A user who starts on a computer can scan a QR code to finish on their phone; the computer's page follows along and returns when the phone finishes. A user who does not pass can try again on the hosted page, or leave with Return to site.

Session outcomes​

StatusMeaningWhat your site should do
verifiedThe user passed.Grant access after confirming the result on your server.
pendingNot finished. This includes users who are retrying after an unsuccessful attempt, and users who left without finishing.Offer to continue the same session, or check again shortly.
cancelledThe user cancelled, for example by closing a new-tab verification window.Offer to start again.
failedThe session ended in an unrecoverable error. Rare: an unsuccessful attempt (an ID showing an age under 18, an unreadable document, a face that does not match) does not end the session; the user can retry until it expires.Do not grant access. Offer a new attempt.
ExpiredThe 10-minute session ended without a successful result. Validate returns 400 Session has expired.Offer a new attempt.

A result does not expire when the session's 10 minutes end. You can confirm a finished session's result again later; doing so does not create another verification, charge or webhook.

Choosing how to integrate​

MethodWho it suitsWhat runs where
Server integration (recommended)Any site with server-side code: Node.js, PHP, Python, Ruby, .NET, and so on.Your server creates the session and confirms the result. No SafePassage code runs in the browser.
JavaScript SDK plus server confirmationSites that want to start verification from browser code, popups or single-page apps.The browser starts the session with a publishable key. Your server still confirms the result.
WordPressWordPress sites. Someone who can upload a file and edit wp-config.php adds one code file from the guide.WordPress (PHP) creates sessions, confirms results and receives webhooks.

There is no integration that is safe without server-side code. If you cannot add code to your site, see Get started.