Verification
Capture
Issue a capture token and run the identity verification on the person's phone or browser with the Aqoonsi SDKs: the liveness test, the document or ID number, and the registry's code.
How capture works#
The person completes a verification on their own phone or in their browser. Your app creates the verification and a capture token with its API key, and passes only the token to the person's phone or browser.
your app (API key) person's phone or browser (capture token)
────────────────── ─────────────────────────────────────────
POST /v1/verifications
POST /v1/consents biometricProcessing
POST /v1/verifications/{id}/sessions
→ meta.secret = aqs_… ── verificationId + token ──► SDK runs the capture
GET /v1/verifications/{id} ◄── callback or webhook ─── outcomeBefore the camera opens#
Consent is yours to collect and record, in this order:
- Your app shows its notice: what is captured, why, and for how long. The person agrees.
- Your server records the consent with its API key:
POST /v1/consentswithpurpose: "biometricProcessing"(andidentityVerificationwhere a national registry is asked), and theversionof the notice the person saw. - Only then does your server issue the capture token.
A capture token can never record a consent, and Aqoonsi never records one for you. Without it, the capture is refused with 409 consent.required. The browser's camera prompt is not consent: open the camera only after step 3.
Issuing a capture token#
Call POST /v1/verifications/{id}/sessions with an Idempotency-Key. The token is returned once, in meta.secret.
curl https://api.aqoon.si/v1/verifications/$VERIFICATION_ID/sessions \
-H "Authorization: Bearer $AQOONSI_KEY" \
-H "Accept: application/vnd.api+json" \
-H "Content-Type: application/vnd.api+json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{"data":{"type":"verificationSessions","attributes":{"origin":"https://app.example.com"}}}'- The token lasts at most 30 minutes, never beyond the verification's own deadline, and stops working when the verification ends.
originbinds the token to one browser origin. Omit it for native apps, which send noOriginheader.- Pass the verification ID and the token to the phone or browser, nothing else.
A capture token can read its own verification, run its liveness test, upload its document images and answer its challenges. Every other request returns 403.
Installing the SDK#
npm install @aqoonsi/webFor React Native, install @aqoonsi/react-native, which wraps the same API. Both SDKs refuse an API key with sdk.apiKeyRefused, and require https for the API URL (plain http only on localhost).
Drop-in flow#
If you would rather not build the screens, mount from @aqoonsi/web/flow draws all of them: your notice, the instructions, the camera, the choices, progress, retry and the result. It is built on the same session as the headless SDK below.
import { mount } from "@aqoonsi/web/flow";
const flow = mount(document.getElementById("verify"), {
notice: {
text: "Sample App checks your face and your ID document to confirm who you are.",
url: "/privacy/biometrics", // or a link to the full notice
agreeLabel: "I agree",
},
// The person tapped "I agree": record the consent on your server, then return the capture token.
onAgree: async () => {
const response = await fetch("/api/verification/agree", { method: "POST" });
return response.json(); // { verificationId, token }, or just the token if you pass verificationId
},
onCancel: () => closeDialog(),
onSuccess: ({ verificationId }) => confirmVerification(verificationId),
onDone: () => closeDialog(),
});- The notice comes first. Nothing is sent to Aqoonsi and no camera opens until
onAgreeresolves. Declining callsonCancel. If the consent is missing when the capture starts, the notice is shown again. - In React, use
<VerificationFlow>from@aqoonsi/web/reactwith the same options. - In React Native, use
<VerificationFlow>from@aqoonsi/react-native/flow. It needsreact-native-vision-camera4 in your app, and asks for the camera only afteronAgreeresolves. Apps on another camera library use the headless session instead. - Text and language. The SDK ships English. Every sentence and label on screen is a key in
messages, including the liveness test's instructions, so a language is one more set of the same keys: pass a whole set (typedMessages, so no key is missed), only the keys you change, or a function over your own translations. Setlocale(defaulten) anddir(ltr, orrtl) with it; a right-to-left set mirrors the layout. - Theming uses CSS custom properties on the element or an ancestor:
--aqoonsi-color-accent,--aqoonsi-color-background,--aqoonsi-color-text,--aqoonsi-radius,--aqoonsi-fontand others. SetcolorSchemetolight,darkorauto. The flow loads no fonts, scripts or trackers, and calls nothing but the Aqoonsi API. - Accessibility. Each screen has a heading that takes focus, every field is labelled, and animation stops when the person asks for reduced motion.
onSuccessis a hint for the screen, as below: your app still confirms the verification withGET /v1/verifications/{id}.
Without a bundler#
A page with no build step loads the drop-in as one ES module, dist/aqoonsi-flow.js in the package (@aqoonsi/web/flow/standalone). It has no imports and no React. Host it on your own origin, so your Content Security Policy can stay script-src 'self'; there is no CDN copy.
<div id="verify"></div>
<script type="module">
import { mount } from "/js/aqoonsi-flow.js";
mount(document.getElementById("verify"), {
notice: { url: "/privacy/biometrics" },
onAgree: async () =>
(await fetch("/api/verify/agree", { method: "POST" })).json(),
onDone: () => location.assign("/account"),
});
</script>It takes the same options as @aqoonsi/web/flow. Copy the file again when you update the package.
Running the identity verification#
createDocumentSession runs the whole verification in order: the liveness test first, then the person's choice between photographing their document and entering their ID number (where a registry covers their nationality), the document photos, the registry's code where one applies, and the wait while Aqoonsi decides.
import { createDocumentSession, explainFailure } from "@aqoonsi/web";
import {
createBrowserImageTools,
createVideoFrameSource,
openDocumentCamera,
openFrontCamera,
previewUrl,
} from "@aqoonsi/web/browser";
await openFrontCamera(selfieVideo);
const session = createDocumentSession({
token,
verificationId,
frameSource: createVideoFrameSource(selfieVideo), // the liveness test
imageTools: createBrowserImageTools(),
review: "manual",
onChallenge: (challenge) => showInstruction(challenge.instruction),
onChoosePath: (paths) => showChoice(paths), // document, or ID number
onIdNumber: (prompt) => askForNumber(prompt.message),
onSideRequested: (side) => showCamera(side.title, side.instruction),
onReview: (review) => showPreview(previewUrl(review.image), review.issues),
onRegistryCode: (prompt) => askForCode(prompt.message),
onDeciding: (message) => showWait(message),
onSuccess: ({ verificationId }) => confirmVerification(verificationId),
onFailure: ({ reason }) => showResult(explainFailure(reason)),
onProviderUnavailable: ({ retryAfterSeconds }) =>
offerRetry(retryAfterSeconds),
onError: (error) => handle(error.kind, error.retryable),
});
const camera = await openDocumentCamera(documentVideo);
pathButtons.onclick = (e) => session.choosePath(e.target.value); // "document" or "number"
numberForm.onsubmit = () => session.submitIdNumber(numberInput.value);
shutterButton.onclick = async () =>
session.provideImage(await camera.takePhoto());
acceptButton.onclick = () => session.accept();
retakeButton.onclick = () => session.retake();
codeForm.onsubmit = () => session.submitCode(codeInput.value);
const outcome = await session.start(); // never rejects- The liveness test. The person follows a few instructions, such as look straight, turn left, turn right or blink. A frame without a face keeps the capture open with
reason: noFaceDetected; it is not a verdict. A verification allows at most three captures, and a test that already passed is not taken again. A capture that could not start because of trouble on our side is not one of the three; after five of them in 15 minutes, starting again is refused with429andRetry-Afterfor a while. - The path. The person chooses, not your app. Pass
pathonly when your own screen already asked them. - The document type. Nobody is asked. The person photographs the front of their document; Aqoonsi reads it and asks for the back only when it needs it (a passport's photo page is the whole document).
- The end.
outcome.statusissucceeded,failed,underReview(someone on your team has to look at it) ornotEligible(the person cannot be verified; the SDK never says why).
In React, useDocumentCapture from @aqoonsi/web/react wraps the same session and exposes its state, prompts and commands.
createCaptureSession runs the liveness test alone, for apps that build their own screens for the rest. Its success means a live person passed the test, nothing more.
Without the SDK#
Every step is a plain request the phone or browser can make with its capture token:
# 1. The liveness test: open a capture, then relay each step until it completes.
POST /v1/verifications/{id}/captures
PATCH /v1/captures/{captureId} {"data":{"type":"verificationCaptures","id":"…","attributes":{"payload":"…"}}}
# 2a. The document: create each image, PUT the bytes to meta.upload.url, then confirm it.
POST /v1/verifications/{id}/images {"data":{"type":"verificationImages","attributes":{"side":"front","mime":"image/jpeg","size":123456}}}
POST /v1/images/{imageId}/readings
# 2b. Or, where number is "offered", the person's ID number instead.
POST /v1/verifications/{id}/challenges {"data":{"type":"verificationChallenges","attributes":{"idNumber":"…"}}}
# 3. Where registry is "required" after the document was read, ask for the code; then send it.
POST /v1/verifications/{id}/challenges {"data":{"type":"verificationChallenges","attributes":{}}}
PATCH /v1/challenges/{challengeId} {"data":{"type":"verificationChallenges","id":"…","attributes":{"code":"…"}}}Upload the image bytes to the signed URL without the Aqoonsi token. Poll GET /v1/verifications/{id} for reading until it is read, then for status until the verification is decided. Once it has passed, the capture token gets 409 verification.completed: treat that as success.
Confirming the outcome#
The SDK's onSuccess is a hint for the screen the person sees, not proof. Your app decides from GET /v1/verifications/{id}, read with its API key after the callback or a webhook.
Sandbox#
Sandbox runs the same capture as live: give the SDK the camera, and photograph a real passport or driving licence. Sandbox asks no national registry, so it offers no national ID card and no ID number path, and its data is deleted within 24 hours. See environments.