Face Liveness integration guide
Add a guided video-selfie liveness check to your web or mobile app. You do not need a camera SDK: VerifyNow hosts the capture page, and your app opens it and receives the result. Add Face Verify, Face Compare or Age Estimate to the same check.
How it works
- Your server creates a liveness session with your API key and receives a
capture_urland asession_token. - Your app opens the
capture_url. The person consents and follows the prompts: centre their face, move back, move closer and hold still. Active checks also flash colours. - VerifyNow sends a signed webhook to your server, or your server polls with the
session_token. If you set areturn_url, the person is sent back to your app.
Keep your API key and session_token on your server. The app only ever handles the capture_url, which works once and expires after ten minutes if unused.
Adding liveness to your app
1. Create the session from your server. Use "mode": "sandbox" while you build; sandbox is free.
curl -X POST https://www.verifynow.co.za/api/external/v2/biometrics/liveness/sessions \
-H "x-api-key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: 4f0c2e64-9a3b-4d52-8f7e-1b2c3d4e5f60" \
-d '{
"mode": "sandbox",
"type": "hybrid",
"reference": "onboarding-1042",
"return_url": "https://app.example.co.za/onboarding/liveness-done",
"callback_url": "https://api.example.co.za/webhooks/verifynow",
"webhook_secret": "a-random-secret-of-at-least-32-characters"
}'The response:
{
"success": true,
"session_token": "lv_…", // keep on your server, never in the app
"type": "hybrid",
"expires_at": "2026-11-23T10:10:00.000Z",
"capture_url": "https://www.verifynow.co.za/biometrics/liveness#lv_…"
}2. Open the full capture_url, including everything after #, in the person's browser or an in-app browser. 3. Wait for the webhook, or poll for the result, before continuing your onboarding flow.
Web apps
Redirect in the same tab for the smoothest mobile experience, with a return_url back to your app. On desktop you can open a new tab and poll your server until the result arrives. Do not embed the capture page in an iframe.
// Your server creates the session; the browser only receives capture_url.
const { capture_url } = await fetch('/api/start-liveness', { method: 'POST' }).then(r => r.json());
// Same tab (simplest on mobile browsers): the person returns to return_url.
window.location.assign(capture_url);
// Or a new tab on desktop, then poll your server for the result.
window.open(capture_url, '_blank', 'noopener');Mobile apps
Open the capture page in the system in-app browser. It has camera access built in and needs no extra permissions in your app. Use an https return_url that your app handles (a Universal Link on iOS, an App Link on Android).
iOS
import SafariServices
// SFSafariViewController supports the camera and keeps the session secure.
let safari = SFSafariViewController(url: URL(string: captureUrl)!)
present(safari, animated: true)
// return_url should be a Universal Link (an https URL your app handles),
// so the app reopens when the check finishes. Then ask your server for the result.Android
import androidx.browser.customtabs.CustomTabsIntent
// Chrome Custom Tabs support the camera without extra WebView permissions.
CustomTabsIntent.Builder().build().launchUrl(context, Uri.parse(captureUrl))
// return_url should be an Android App Link (https) that opens your app.WebViews, React Native and Flutter
// Only if you must use an in-app WebView:
// iOS (WKWebView): iOS 14.3+, allowsInlineMediaPlayback = true, and
// NSCameraUsageDescription in Info.plist.
// Android (WebView): CAMERA permission, javaScriptEnabled, and grant
// PermissionRequest.RESOURCE_VIDEO_CAPTURE in onPermissionRequest.
// React Native / Flutter: open capture_url with an in-app browser package
// (for example react-native-inappbrowser-reborn or flutter_custom_tabs).Add-ons
Add one check to the same session. It runs only on a passing capture; a review or failed liveness result skips it and is charged at the liveness price.
- Face Verify: compares the capture with the person's Home Affairs photo. They enter their SA ID number on the capture page, or you send
verify_id_number. - Face Compare: compares the capture with an ID photo you supply. The photo is stored encrypted only until the comparison runs, then deleted.
- Age Estimate: returns an estimated age range from the same capture.
// Face Verify: compare with the Home Affairs photo (person enters their ID)
{ "mode": "production", "type": "active", "verify_id": true }
// Face Compare: compare with an ID photo you already hold
{ "mode": "production", "type": "hybrid", "addon": "face_compare",
"reference_image_base64": "<base64 JPEG or PNG, up to 3 MiB>" }
// Age Estimate: age range from the same capture
{ "mode": "production", "type": "hybrid", "addon": "age_estimate" }See pricing for each combination.
Results and webhooks
Completed results include the liveness confidence and decision, an overall decision, and the add-on result (face_verify with home_affairs, face_compare, or age_estimate). Results never contain images. Verify every webhook signature before trusting it.
import crypto from 'node:crypto';
// Express: use the raw body exactly as received.
app.post('/webhooks/verifynow', express.raw({ type: 'application/json' }), (req, res) => {
const timestamp = req.get('x-verifynow-timestamp');
const signature = req.get('x-verifynow-signature'); // "v1=<hex>"
const expected = 'v1=' + crypto
.createHmac('sha256', process.env.VERIFYNOW_WEBHOOK_SECRET)
.update(timestamp + '.' + req.body)
.digest('hex');
if (!signature || !crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expected))) {
return res.sendStatus(401);
}
const event = JSON.parse(req.body.toString('utf8'));
// Deduplicate by x-verifynow-event-id, then update your onboarding record.
res.sendStatus(200);
});Or poll from your server:
curl https://www.verifynow.co.za/api/external/v2/biometrics/liveness/sessions/SESSION_TOKEN \
-H "x-api-key: YOUR_API_KEY"Testing and going live
- Sandbox sessions skip the camera and return simulated results at no cost.
- Production requires an Idempotency-Key on every create request; reuse it when retrying.
- Test on the devices your customers use. The person completing the check needs:
- A front-facing colour camera that records at least 15 frames per second at 480 × 640 pixels or higher
- No virtual camera or camera software
- A screen of at least 4 inches with a refresh rate of 60 Hz or more
- A device that is not jailbroken or rooted
- A connection of at least 100 kbps
- One of the latest three versions of Chrome, Firefox, Safari or Edge
- On a computer, a webcam mounted on top of the screen showing the check
The hosted page shows "Powered by VerifyNow". Customers with an enterprise agreement can ask us to hide it.
Full field reference: Biometrics IDV v2 API.