Web App Integration
Your back-end creates the process with the Human Plugin API and passes the returned values to the front-end. See Create a process.
A journey is the set of steps the user goes through to complete an identity verification — facial capture, liveness, document check. Unico manages the entire experience: you create the process, direct the user to it, and read the result. Everything in between is built and maintained by Unico.
Choose your integration model
| Model | Setup time | Backend required | Best for |
|---|---|---|---|
| Direct access | Minutes | Create Process only | Mobile apps with WebView, or web flows where the journey can happen outside the main page |
| Journeys SDK — Experience | ~1 hour | Create Process only | Web apps that need an integrated, seamless inline experience |
| Journeys SDK — Button | ~30 min | Create Process only | Web apps that want a ready-made button with zero UI code |
Experience is recommended for production web apps — it gives you full control over when to show the journey and keeps the user in your page. Button is the fastest path if you just need a capture trigger. Direct access is the go-to for mobile or when the journey can open in a separate page.
- Direct access
- Journeys SDK — Experience
- Journeys SDK — Button
The user is redirected to a Unico-hosted link, where the journey takes place. Upon completion,
they are returned to the URL defined during process creation (the callbackUri parameter).
This is the simplest approach: no library, no iFrame. It works well when the journey does not need to happen inside your page. The trade-off is that taking the user outside your environment tends to increase drop-off.
What the user sees

How it works
After creating a process, the API response includes the journey URL. Two ways to direct the user:
- Standard redirect — navigate to the journey URL. On completion, Unico redirects back to your
callbackUri. - New tab with
window.open()— the journey opens in a separate tab. Monitor for thecallbackUriand close the tab when done. See the MDN documentation.
Mobile — WebView with deeplink
In mobile apps, open the journey URL directly in a WebView. The callbackUri accepts a deeplink, so the journey completion triggers the right screen in your native app.
The journey runs inside your page via an iFrame managed by the SDK. The user stays in your environment throughout — less friction, lower drop-off.
What the user sees


Quick start
import { ByUnicoSDK } from 'unico-journey-sdk';
// 1. Initialize as early as possible (pre-loads assets)
ByUnicoSDK.init({ token });
// 2. Open the journey when ready
ByUnicoSDK.open({
transactionId: processId,
token,
onFinish: ({ type, transaction }) => {
if (type === 'FINISH') {
// Journey completed — call getProcess to fetch the result.
// transaction = { id, redirectUrl }
}
// type === 'CLOSE' → user closed before finishing
},
});
That's the entire integration. The sections below cover installation, configuration, and the full API.
Installation
npm install unico-journey-sdk
This package was previously published as idpay-b2b-sdk. It is the same SDK under a new name and
follows the same version line. Only 2.3.0 and later are published under unico-journey-sdk;
earlier versions remain available under the former idpay-b2b-sdk name.
The SDK follows Semantic Versioning — patch and minor updates are safe to auto-update. Major versions come with a migration guide.
Stay on the latest version for security (patches for vulnerabilities and protocol hardening) and stability (bug fixes that older versions still carry).
Before getting started, register your domains on the branch in the Human Dashboard, under Settings > Branches. All domains must use HTTPS.
CSP and Permissions-Policy
If your page sends these headers, add the following directives. If it does not, skip this step — the browser applies no restrictions by default.
Content-Security-Policy:
frame-src https://*.unico.io https://*.unico.app;
script-src https://idpay.unico.io;
style-src https://idpay.unico.io;
connect-src https://api.cadastro.unico.app;
Permissions-Policy:
camera=(self "https://human-token.unico.io" "https://cadastro.unico.app" "https://id.unico.io" "https://retry.unico.io" "https://ultimatum.unico.io"),
geolocation=(self "https://human-token.unico.io" "https://cadastro.unico.app" "https://id.unico.io" "https://retry.unico.io" "https://ultimatum.unico.io")
API reference
ByUnicoSDK.init(options)
Pre-loads the scripts and validates the domain. Call this as early as possible — ideally as soon as you know the journey will be needed.
| Parameter | Type | Required | Description |
|---|---|---|---|
token | string | Yes | Process token returned by the Create Process API |
ByUnicoSDK.init({ token });
ByUnicoSDK.open(options)
Displays the iFrame and starts the journey. Everything happens automatically from this point.
| Parameter | Type | Required | Description |
|---|---|---|---|
transactionId | string | Yes | Process ID returned by the Create Process API |
token | string | Yes | Process token returned by the Create Process API |
onFinish | function | Yes | Callback when the journey ends or is closed |
onWidgetVisibilityChange | function | No | Callback when the widget visibility state changes |
ByUnicoSDK.open({
transactionId: '9bc22bac-1e64-49a5-94d6-9e4f8ec9a1bf',
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
onFinish: ({ transaction, type }) => {
if (type === 'FINISH') {
// Journey completed (transaction = { id, redirectUrl }) — continue your flow here.
}
// type === 'CLOSE' → user closed before finishing;
},
// Optional: only needed if your app shows UI that could overlap the widget.
onWidgetVisibilityChange: (visible) => {
// suppress or restore your modal based on widget visibility
},
});
ByUnicoSDK.close()
Closes the SDK iFrame explicitly. Useful if you need to dismiss the journey programmatically.
onFinish callback
| Field | Type | Description |
|---|---|---|
type | string | 'FINISH' (completed) or 'CLOSE' (user closed before finishing) |
transaction | object | undefined | Present when type is 'FINISH'; undefined when type is 'CLOSE' |
transaction.id | string | Process identifier (same as transactionId passed in) |
transaction.redirectUrl | string | URL to redirect the user after the journey |
onFinish signals that the journey ended, not that the user was approved. The process may have failed on a validation rule. Always call getProcess or wait for the Webhook to get the actual result.
onWidgetVisibilityChange callback
Optional. Fires when the widget visibility changes. Useful when your app shows a custom modal that could overlap the Unico widget — use it to suppress your modal while the journey is active. If your app has no overlapping UI, omit it.
Sequence diagram
Sample apps
| Framework | Repository |
|---|---|
| Angular | GitHub — unico-cbu-poc-angular |
| JS Vanilla | GitHub — unico-cbu-poc-js |
| React | GitHub — unico-cbu-poc-react |
| Vue JS | GitHub — unico-cbu-poc-vuejs |
How the SDK works internally
The SDK inserts an iFrame into the page and manages the entire visual experience inside it. This isolation is intentional:
- No CSS collisions — styles inside the iFrame don't interfere with your app, and vice versa.
- No script leaks — Unico scripts run in a separate context, protected from external modification.
- Automatic updates — journey improvements ship inside the iFrame without requiring SDK updates.
Security
Security is built in layers:
- Origin validation — the iFrame validates the
postMessageorigin against a closed list of authorized domains. Messages from non-approved origins are discarded, preventing clickjacking. - Token-based authentication — the flow only proceeds with a valid, single-use JWT issued by the Unico backend. Expired, reused, or forged tokens are rejected.
- No sensitive data in transit — after the initial handshake, all communication between the SDK and the iFrame is limited to interface control (open, close, transitions). No process data is exchanged.
- Runtime integrity — the iFrame isolation prevents external scripts from accessing or modifying the Unico code at runtime.
Troubleshooting
| Symptom | Check |
|---|---|
| Unexpected behavior or broken flow | Is any script manipulating the iFrame in the DOM? The SDK manages it in body — external modifications break the lifecycle. |
| Visual experience different from expected | Are global CSS tag selectors reaching inside the iFrame? The SDK uses unico-prefixed classes, but broad rules can still leak. |
| Anomalous behavior after update | Was any SDK file modified directly? The library must be managed via npm/yarn only. Manual edits prevent Unico support from assisting. |
The simplest SDK integration. Unico renders a ready-made button in your page — when the user clicks it, the journey opens automatically. No init(), no open(), no UI code.
Available from unico-journey-sdk 2.4.0 onwards.
What the user sees

Quick start
import { ByUnicoSDK } from 'unico-journey-sdk';
const button = await ByUnicoSDK.renderButton({
container: '#unico-button',
id: processId,
token,
onFinish: ({ type, transaction }) => {
if (type === 'FINISH') {
// Journey completed — call getProcess to fetch the result.
}
},
});
That's it. The renderButton() call handles initialization, asset loading, device pre-validation, and button rendering. The sections below cover the full API.
Installation
npm install unico-journey-sdk
Before getting started, register your domains on the branch in the Human Dashboard, under Settings > Branches. All domains must use HTTPS.
CSP and Permissions-Policy
Same directives as the Experience model. If your page sends these headers, add them. Otherwise, skip this step.
Content-Security-Policy:
frame-src https://*.unico.io https://*.unico.app;
script-src https://idpay.unico.io;
style-src https://idpay.unico.io;
connect-src https://api.cadastro.unico.app;
Permissions-Policy:
camera=(self "https://human-token.unico.io" "https://cadastro.unico.app" "https://id.unico.io" "https://retry.unico.io" "https://ultimatum.unico.io"),
geolocation=(self "https://human-token.unico.io" "https://cadastro.unico.app" "https://id.unico.io" "https://retry.unico.io" "https://ultimatum.unico.io")
API reference
ByUnicoSDK.renderButton(options) → Promise<ButtonInstance>
Renders the button and returns a Promise that resolves with a ButtonInstance for lifecycle control. No separate init() call needed — renderButton handles everything.
| Parameter | Type | Required | Description |
|---|---|---|---|
container | Element or CSS selector | Yes | DOM element (or selector) where the button will be mounted |
id | string | Yes | Process ID returned by the Create Process API |
token | string | Yes | Process token returned by the Create Process API |
onReady | function | No | Fires when the button has been rendered and is visible |
onClick | function | No | Fires when the user clicks the button, before the journey opens — useful for tracking |
onFinish | function | No | Fires when the journey ends. Receives { type, transaction } — same shape as the Experience model |
onError | function | No | Fires if the button fails to render. Receives { reason } |
import { ByUnicoSDK } from 'unico-journey-sdk';
const button = await ByUnicoSDK.renderButton({
container: '#unico-button',
id: '9bc22bac-1e64-49a5-94d6-9e4f8ec9a1bf',
token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...',
onReady: () => {
// Button is visible and ready to be clicked.
},
onClick: () => {
// User clicked the button — track the event if needed.
},
onFinish: ({ type, transaction }) => {
if (type === 'FINISH') {
// Journey completed (transaction = { id, redirectUrl }) — call getProcess to fetch the result.
}
// type === 'CLOSE' → user closed before finishing;
},
onError: ({ reason }) => {
// Button failed to render — see error reasons below.
console.error(reason);
},
});
ButtonInstance methods
| Method | Description |
|---|---|
destroy() | Unmounts the button from the DOM |
refresh() | Re-renders the button in the container |
Container requirements
The element where the button is mounted must:
- Exist in the DOM at the time
renderButton()is called. - Be visible — not
display: noneor hidden by a parent. - Be a block-level element with usable width.
- Not clip its content via
overflow: hiddenor CSStransformthat hides the button area.
Custom button font
You can render the button in your own font. Set it on the branch in the Human Dashboard, next to the branch colors, with two fields:
- Font URL — an
https://link to a CSS stylesheet that declares the font, such as a Google Fonts link or your own@font-facefile. - Font family — the family name declared in that stylesheet, such as
Lobster. Letters, numbers, spaces, hyphens and underscores, up to 100 characters.
Fill in both fields: the dashboard does not save only one of them. To go back to the default font, clear both fields and save.
Font URL: https://fonts.googleapis.com/css2?family=Lobster&display=swap
Font family: Lobster
The font applies only to the button and the privacy notice below it. Once the user clicks, the journey uses Unico's standard font.
The button renders right away in the default font and switches when your font finishes downloading, so its height can change once. Do not give the container a fixed height. Use display=swap in Google Fonts links, or font-display: swap in your @font-face. If the font fails to load, the button keeps the default font and works normally; no error is raised.
Browsers fetch font files in CORS mode. If you host the font files yourself, your server must answer them with an Access-Control-Allow-Origin header (for example *). Without it, the browser blocks the font and the button falls back to the default font. The stylesheet itself needs no CORS header. Google Fonts already sends this header.
Error reasons
If the button cannot be rendered, onError fires with one of these reasons:
| Reason | Meaning |
|---|---|
DEVICE_NOT_SUPPORT | Device failed the pre-validation check |
CONTAINER_NOT_FOUND | The container element does not exist in the DOM |
CONTAINER_UNSUPPORTED | The container is hidden or has zero size |
IFRAME_BLOCKED | CSP or browser security is blocking the iFrame |
Sequence diagram
Security
The Button model shares the same security architecture as the Experience model — origin validation, token-based authentication, iFrame isolation, and runtime integrity. See the Journeys SDK — Experience tab for the full details.
Do not keep DevTools open during capture tests
The Unico application uses the Capture SDK (unico-webframe) for facial capture, which detects open DevTools as a potential fraud signal and blocks the submission. Close DevTools before running end-to-end capture tests.
The models described in this documentation — direct access, Journeys SDK Experience, and Journeys SDK Button — are the only integration approaches officially supported by Unico. Integrations that deviate from these standards may cause unexpected behavior, security flow failures, and journey interruptions, and will not be covered by Unico support.
Examples of unsupported approaches:
- Embedding the SDK inside a WebView in mobile applications. In these cases, the correct approach is to use the direct access model, opening the journey link directly in the WebView without involving the Journeys SDK.
- Loading the iFrame directly via an
<iframe>HTML tag, without going through the Journeys SDK. The iFrame is an internal implementation detail of the SDK and must not be instantiated manually. The correct approach is to use the Journeys SDK, which manages the iFrame lifecycle securely and within the expected standards.
If there is any doubt about whether an approach is within the supported standard, consult the documentation or contact support before proceeding with the implementation.