Web SDK
Web SDK installation
Two ways to add the widget, plus the options and callbacks.
Ways to integrate
- A script tag in a plain JavaScript page: load the widget script, then call
window.KYCWidget.setupKYC({...}). - A script tag in a React application: load the same script in an effect and call
setupKYCfrom a handler. - A direct link: the platform hosts the verification page for a scenario. You build the link with the scenario identifier and the encrypted client key.
The samples below use placeholders. The integration documentation tab of your scenario in the dashboard shows the exact script address for your account. See working with clientKey for the encrypted key.
Before you launch
- Add your domain to the allowed domains. In the dashboard, open Access and then Allowed domains, and add every domain where the widget is embedded. See allowed domains.
- Serve the page over HTTPS. Browsers give camera access only to secure pages.
- Put the widget on the main page of your site, not inside an iframe. Browsers block the camera inside a cross-origin iframe.
Plain JavaScript
<button id="btn" disabled>Loading...</button>
<script>
const btn = document.getElementById("btn");
const script = document.createElement("script");
script.src = "<WIDGET_SCRIPT_URL>";
script.onload = () => { btn.disabled = false; btn.textContent = "Open verification"; };
script.onerror = () => { btn.textContent = "Could not load the widget"; };
document.body.appendChild(script);
btn.addEventListener("click", () => {
window.KYCWidget.setupKYC({
scenarioId: "<your scenario id>",
clientKey: "<encrypted client key from your server>",
clientUser: "<your user id>",
theme: "light",
closeCb: () => console.log("closed"),
successCb: (sessionJson) => console.log("success", sessionJson),
finalizedCb: ({ status }) => console.log("already finalized", status),
});
});
</script>
React, with the script tag
import { useState, useEffect } from "react";
export default function Verify({ clientKey }) {
const [loaded, setLoaded] = useState(false);
useEffect(() => {
if (window.KYCWidget) { setLoaded(true); return; }
const script = document.createElement("script");
script.src = "<WIDGET_SCRIPT_URL>";
script.defer = true;
script.onload = () => setLoaded(true);
document.head.appendChild(script);
}, []);
const open = () =>
window.KYCWidget.setupKYC({
scenarioId: "<your scenario id>",
clientKey,
theme: "light",
closeCb: () => {},
successCb: (sessionJson) => console.log("success", sessionJson),
});
return loaded ? <button onClick={open}>Open verification</button> : null;
}
Options
| Option | Type | Required | Description |
|---|---|---|---|
scenarioId | string | yes | The scenario identifier, from the KYC section of the dashboard. |
clientKey | string | yes | Your identifier for the person, encrypted with the secret key of the scenario. The raw value is at most 36 characters. |
clientUser | string | no | Your identifier of the user, at most 36 characters. It need not be unique: pass the same value across sessions to find all attempts of one user later. |
theme | light or dark | no | The color theme. The default is the one set in the scenario. |
questionnaireSessionUuid | string | no | The identifier of a stage-one questionnaire record, for a verification that follows a questionnaire. See two-stage questionnaire, then KYC. |
mountElementId | string | no | Script-tag integration only. When set, the widget mounts inline in the element with this identifier instead of covering the page. Give that element explicit dimensions. It does not work inside a cross-origin iframe. |
stickySession | boolean | no | When true, the widget remembers the client key per scenario in the browser for 15 minutes, and reopening within that time resumes the previous session. |
topOffset | number | no | Top padding, in pixels. |
bottomOffset | number | no | Bottom padding, in pixels. |
blurHost | boolean | no | When true, the background is a frosted-glass overlay over your page. |
closeCb | function | no | Called when the widget is closed. |
successCb | function | no | Called when verification succeeds. Receives the session result as a JSON string. |
finalizedCb | function | no | Called when the widget is opened for a session that was finalized earlier. Receives an object with status. |
Do not call setupKYC from inside closeCb: repeated detection can recurse.
Decide on the server
The callbacks run in the browser of the user, so a user can tamper with them. Decide on the customer from the status your server reads with session status, or from the SESSION_COMPLETE webhook. The shape of the result is described in the session object.
Direct link
Instead of embedding the widget you can send the user to the verification page that the platform hosts. The link has the form <verification page>/<scenarioId>/<encrypted clientKey>, with the client key URL-encoded because the encrypted value is Base64 and can contain / and +. An optional last segment carries the clientUser. Single-use links for a batch of users are generated in the dashboard. See KYC and AML in the platform user guide.
Next
Parameters shows how to brand the widget in the editor.
Questions, answered plainly
The widget does not open on my page. What do I check first?
Check that the domain is in the allowed domains, that the page is served over HTTPS, and that the widget is not inside a cross-origin iframe.
Can I put the widget inside a frame?
Not inside a cross-origin iframe: the browser blocks the camera there. Use the main page, or the inline mode with mountElementId.