Onboarding (KYC/KYB)
5 min read
The JavaScript SDK launches the Footprint onboarding flow for KYC (Know Your Customer) and KYB (Know Your Business) from your JavaScript or TypeScript app. By the end, your app opens the flow and receives a validation token when the user completes it.
@onefootprint/footprint-js version 5.0.0 or higher.By default the flow opens in a modal. To embed it in your page instead, see Inline integration.
Start an onboarding
Get an onboarding token. Start the onboarding with POST /onboardings and take the token it returns, such as
obtok_UxM6Vbvk2Rcy1gzcSuXgk3sj3L9I0pAnNH.Initialize the flow. Trigger Footprint, for example when a button is clicked, and pass the
onboardingSessionTokenand anonCompletecallback toinitialize.
javascript
- Handle completion. When the user completes the flow,
onCompletereceives thevalidationToken. Post it to your backend for further processing.
A complete example lives in onefootprint/examples.
Listen to events
The SDK fires events as the user acts in the flow. Pass the handlers to initialize (modal) or initializeInline:
typescript1import { onboarding } from "@onefootprint/footprint-js";
2
3onboarding.initialize({
4 onboardingSessionToken: "obtok_UxM6Vbvk2Rcy1gzcSuXgk3sj3L9I0pAnNH",
5 onComplete: (validationToken) => {
6 console.log(validationToken);
7 },
8 onError: (error) => {
9 console.log(error);
10 },
11 onAuth: (validationToken) => {
12 console.log(validationToken);
13 },
14 onCancel: () => {
15 console.log("User canceled the flow");
16 },
17 onClose: () => {
18 console.log("User closed the flow");
19 },
20});
Track flow progress
onRequirementChange is available from version 5.6.0.Pass onRequirementChange to track the flow's progress from your page, for example to drive your own stepper while the flow runs inline. It fires whenever the requirement being executed changes, and again when the flow moves to a different screen within the same requirement:
typescript1import { onboarding } from "@onefootprint/footprint-js";
2
3onboarding.initializeInline({
4 onboardingSessionToken: "obtok_UxM6Vbvk2Rcy1gzcSuXgk3sj3L9I0pAnNH",
5 containerId: "footprint-container",
6 onComplete: (validationToken) => {
7 console.log(validationToken);
8 },
9 onRequirementChange: ({ kind, page }) => {
10 console.log(kind); // e.g. "collect_business_data"
11 console.log(page); // e.g. "business_owners", or undefined
12 },
13});
Possible kind values are collect_business_data, collect_data (personal information), collect_document, liveness (passkey registration), link_bank_account, collect_investor_profile, collect_card_data, collect_custom_data, collect_document_data, confirm_verified_prefill, register_auth_method and process. New kinds may be added over time, so handle unknown values gracefully.
When a requirement spans more than one distinct screen, the payload also carries a page field. Today it is set to business_owners while the beneficial owners screen of collect_business_data is shown, so a stepper can distinguish it from the business details screen of the same requirement. It is omitted everywhere else, and new page values may be added over time.
Inline integration
initializeInline is available from version 5.1.0.To embed the flow in your page instead of opening a modal, call initializeInline. It needs a container element in your DOM, where the flow renders:
javascript1import "@onefootprint/footprint-js/dist/footprint-js.css";
2import { onboarding } from "@onefootprint/footprint-js";
3
4const App = () => {
5 const launchInline = () => {
6 onboarding.initializeInline({
7 onboardingSessionToken: "obtok_UxM6Vbvk2Rcy1gzcSuXgk3sj3L9I0pAnNH",
8 containerId: "footprint-container",
9 onComplete: (validationToken) => {
10 console.log(validationToken);
11 },
12 });
13 };
14
15 return (
16 <div>
17 <button type="button" onClick={launchInline}>Launch Footprint Inline</button>
18 <div id="footprint-container" style={{ height: '600px', width: '100%' }}></div>
19 </div>
20 );
21}
The inline integration takes the same event handlers and customization options as the modal. Give the container enough height; the recommended minimum is 600px.
Customize the appearance
Pass an appearance object to initialize (modal) or initializeInline to restyle the flow:
typescript1import { onboarding } from "@onefootprint/footprint-js";
2
3onboarding.initialize({
4 onboardingSessionToken: "obtok_UxM6Vbvk2Rcy1gzcSuXgk3sj3L9I0pAnNH",
5 onComplete: (validationToken) => {
6 console.log(validationToken);
7 },
8 appearance: {
9 variables: {
10 borderRadius: "8px",
11 colorSuccess: "#10b981",
12 colorError: "#F87171",
13 buttonPrimaryBg: "#5550e9",
14 },
15 },
16});
The customization guide lists every variable.
Available props
| Variable | Description |
|---|---|
onboardingSessionToken | The onboarding session token you created. |
onComplete | Fires after the user completes the onboarding flow, with a validationToken your backend exchanges with Footprint for the fp_id, the login method used, and the KYC status. |
onAuth | Optional. Fires after the user logs in, before the user has finished onboarding, with a validationToken your backend exchanges with Footprint for the fp_id and the login method used. |
onError | Optional. Fires on an unrecoverable error while initializing the onboarding flow, with an error string that carries the details. |
onCancel | Fires when the user abandons the flow, for example by clicking the close button inside the iframe. |
onClose | Fires when the user closes the flow, whether completed or canceled. |
onRequirementChange | Optional. Fires when the requirement being executed changes, with { kind, page? } so your page can track the flow's progress. |
appearance | Optional. A FootprintAppearance object that customizes the look of your integration. |
l10n | Optional. Sets the language and locale; see Localization configuration. |
containerId | Required for inline integration only. The ID of the DOM element the onboarding flow renders into. |