Workflow Integration

Use workflows to integrate the Web SDK.

Overview

This guide walks you through integrating the Web SDK with ComplyCube workflows.

circle-info

For a quick copy-paste example, use our integration assistantarrow-up-right.

Integration flow

The Web SDK runs as part of your frontend but relies on your backend to create secure tokens. Here’s how it works:

1

Create a client

Register a new client (i.e. customer) using the ComplyCube API

2

Generate an SDK token

Your backend requests a JWT token tied to that client.

3

Import and mount the SDK

Add the JS and CSS files, then mount the SDK in your web app.

4

Capture documents, videos, and selfies

The SDK guides your customer through the required steps.

5

Perform verification checks

Captured data is securely sent to ComplyCube for verification checks, and results are delivered in real time through the API or webhooks.

Web SDK Integration via Workflows Guide

Integration guide

1

Create a client

Every verification flow starts with a client (i.e. customer). Use the API to create the client.

Example request

Example response

The response will contain an id (the Client ID). It is required for the next step.

circle-info

See Clients API Reference to learn more.

2

Generate an SDK token

Your backend must create an SDK token for each new flow. This token links the SDK session to the client. Tokens are short-lived and must not be reused.

Example request

Example response

circle-info

See SDK Token API Reference to learn more.

3

Import the SDK

To import our Web SDK, you need to include it in your target page HTML:

chevron-rightLoading the SDK with Integrity (Optional)hashtag

For additional security, you can optionally load the ComplyCube Web SDK using Subresource Integrity (SRI). This allows the browser to verify that the JavaScript and CSS files have not been modified by validating them against cryptographic checksums.

Retrieve the latest SDK integrity values

To ensure you always use the latest supported SDK version and integrity hashes, retrieve the asset metadata from the Web SDK info endpoint.

Example request

Example response

The response includes the URLs and corresponding integrity values for both the JavaScript and CSS assets.

Import the SDK using integrity attributes

Use the returned values to load the SDK in your HTML with integrity and crossorigin attributes:

circle-info

Notes

  • Using SRI is optional, but recommended for environments with stricter security requirements.

  • The crossorigin="anonymous" attribute is required when using SRI with assets served from a different origin.

  • Integrity values may change when the SDK is updated. Always retrieve the latest values from the endpoint.

circle-info

The links to complycube.min.js and style.css can be found in your developers portalarrow-up-right.

4

Mount the SDK

As part of mounting the Web SDK, you are required to specify a workflow template IDarrow-up-right. The SDK will automatically run the active version of the selected workflow.

Once the verification flow is complete, customers are redirected back to the return URL you specify.

With the generated token, the Web SDK can be initialised in your frontend using the following Javascript code:

circle-info

The SDK mount parameters are described in the SDK Settings section below.

circle-info

Referrer policy

To enable successful communication between the SDK and our servers, your web page's Referrer Policy header should be set to strict-origin-when-cross-origin. This ensures that the referrer information is securely transmitted during HTTP requests.

You can either do it programmatically or add it directly to the web page as follows: <meta name="referrer" content="strict-origin-when-cross-origin">

5

Perform verification checks

Once your customer starts the flow, a workflow session is automatically created. This session contains all captured data (documents, images, and videos) as well as progress tracking. You can view all of them through the workflow sessions pagearrow-up-right on the portal or through the API.

When the flow finishes, the SDK triggers the onComplete callback. The callback provides a data object that includes the workflowSessionId. Your backend should use this ID to notify ComplyCube that the workflow has completed, which in turn runs the verification checks defined in the workflow.

If you have set up webhooks arrow-up-rightas described in our webhooks guidearrow-up-right, you will be notified once a workflow session completes.

You can retrieve the details of a workflow session by calling the retrieve workflow session request.

Example of a complete workflow session request

SDK reference

This section describes all configurable settings, callbacks, lifecycle methods, and branding options available in the ComplyCube Web SDK.

Settings

Option
Description

token

The SDK token generated by your backend. This is required. Type: string

workflowTemplateId

The ID of the workflow templatearrow-up-right to load for this the session. This is required.

Type: string

containerId

The ID of the container element where the SDK mounts. This must be an empty element.

Type: string Default value: complycube-mount

useModal

This defines whether the UI screens load into a modal instead of inline. Type: boolean Default value: true

disableClientAnalytics

This defines whether we track client analytics or not.

Type: boolean Default value: false

Callback

Callbacks let you respond to SDK lifecycle events.

Option
Description

onComplete

Triggered after the customer completes the verification flow. This is used to invoke a workflow session complete request.

onError

Triggered when an error occurs. The error object has two attributes:

  • type: This can be:

    • exception

    • token_expired : indicates the token has expired. When this occurs, a new SDK token must be provided.

  • message: Description of the error.

onExit

This callback is triggered when your client exits before completing the flow. It will return the exit reason, e.g., USER_CONSENT_NOT_GRANTED.

onModalClose

Triggered when the customer tries to close the modal. You can allow or prevent closure by updating the isModalOpen attribute using updateSettings.

Updating settings

A number of settings can be updated at runtime as follows:

Unmounting the SDK

If you are using the SDK in a Single Page Application (SPA), you can call the unmount function to remove the SDK and reset its state.

Branding

You can customise the SDK’s look and feel with the branding object. It comprises of the attributes outlined below.

Appearance

The appearance object allows you to customize the color scheme of the SDK with CSS values (e.g. RGBA, Hex). Customizable attributes include:

Attribute
Description

infoPopupColor

Warning popup background color.

infoPopupTextColor

Warning popup background color.

infoPopupLinkHoverColor

Warning popup fallback Link on hover background color.

infoPopupLinkActiveColor

Warning popup fallback Link active background color.

errorPopupColor

Error popup background color.

errorPopupTextColor

Error popup text color.

errorPopupLinkHoverColor

Error popup fallback Link on hover background color.

errorPopupLinkActiveColor

Error popup fallback Link active background color.

cameraButtonHoverColor

Camera button on hover background color.

cameraButtonActiveColor

Camera button active background color.

iconButtonActiveColor

Icon button active background color.

iconButtonHoverColor

Icon button on hover background color.

primaryButtonColor

Primary button background color.

primaryButtonTextColor

Primary button text color.

primaryButtonActiveColor

Primary button active background color.

primaryButtonHoverColor

Primary button on hover background color.

primaryButtonBorderColor

Primary button border color.

secondaryButtonColor

Secondary button background color.

secondaryButtonTextColor

Secondary button text color.

secondaryButtonActiveColor

Secondary button active background color.

secondaryButtonHoverColor

Secondary button on hover background color.

secondaryButtonBorderColor

Secondary button border color.

documentSelectorColor

Document selector background color.

documentSelectorTextColor

Document selector text color.

documentSelectorActiveBorderColor

Document selector active background color.

documentSelectorHoverBorderColor

Document selector on the hover background color.

linkHoverColor

Link on the hover background color.

linkActiveColor

Link active background color.

linkUnderlineColor

Link underline color.

linkHoverTextColor

Link on the hover text color.

bodyTextColor

SDK content text color.

headingTextColor

SDK heading text color.

subheadingTextColor

SDK subheading text color.

The logo object has the following attributes:

  • lightLogoUrl: URL for your logo's light version.

  • darkLogoUrl: URL for your logo's dark version.

Example of logo branding

Text Brand

The textBrand attribute represents the textual format of your brand.

Example of text branding

circle-info

If logo and textBrand attributes are specified at the same time, logo takes precedence.