Incode WebSDK reference

Method documentation for the webSDK

create

Description:

You need to call this method before using the SDK. The method returns an instance of the SDK.

Parameters:

NameTypeDescription
apiKeystringAPI key
apiURLstringAPI URL
langstringLanguage (en or es)
encryptbooleanIndicates the use of encryption (default: false)
translationsobjectThe object with the translations. (Ask support) (optional)
opencvURLstringThe URL of opencv (optional)
facefinderURLstringThe URL of facefinder (optional)
darkModebooleanShow dark variants of all tutorials (default: false)
fingerprintApiKeystringThe fingerprint API key (optional).

Returns

  • Object:

    The SDK instance

Example:

// Get onBoarding instance
const onBoarding = OnBoarding.create({
  apiKey: "myApiKey",
  apiURL: "myApiURL",
  lang: "en",
});
// You can save it on a global variable
var onBoarding = OnBoarding.create({ apiKey: "myApiKey", apiURL: "myApiURL" });

// use the instance
onBoarding.createSession(countryCode).then((token) => {
  // save token
});

isDesktop

Description:

This function informs you if the user is using a desktop computer (it can be a laptop)

Example:

if (onBoarding.isDesktop()) {
  onBoarding.renderRedirectToMobile(containerRef.current, {
    onSuccess: () => {
      renderFinishScreen();
    },
    session: session,
    flowId: flowId,
  });
} else {
  // show mobile normal flow
  renderFrontId();
}

renderRedirectToMobile

Description:

This method renders the Redirect Component

Parameters:

NameTypeDescription
containerHTMLElement
options Objectobjectoptions object

Options:

NameTypeDescription
sessionobject*The session object you get in createSession (Mandatory)
flowIdstringID of the flow that will be used in the mobile
onSuccessfunction*Callback when the onboarding in mobile was successful and completed
urlstringURL to be redirected to
showSmsbooleanBoolean flag indicating if the SMS component should be shown
allowReEnrollmentbooleanBoolean flag indicating if user re-enrollment is allowed
externalIdstringExternal ID to concatenate to URL if needed
assetsobjectObject containing assets from the dashboard
expiredbooleanBoolean flag indicating if a session is expired
smsTextstringCustom text to be send in SMS. The URL is concatenated after this text

Example:

const flowId = "someflowid";

const session = await onBoarding.createSession("ALL", null, {
  configurationId: flowId,
});

if (onBoarding.isDesktop()) {
  onBoarding.renderRedirectToMobile(containerRef.current, {
    onSuccess: () => {
      renderFinishScreen();
    },
    session: session,
    flowId: flowId,
  });
} else {
  // show mobile normal flow
  renderFrontId();
}

renderUserConsent

Description:

Renders a privacy consent interface within a specified DOM element. This function allows for displaying a consent form that is either predefined in the dashboard or uses a default configuration.

Parameters:

NameTypeDescription
elementHTMLElementThe DOM element where the consent interface will be rendered. If null, the function will not perform any operation.
optionsobjectAn object containing configuration options for the consent interface. The options object includes the properties described below:
options.sessionSessionThe session object containing user session data, necessary for determining the consent state or user preferences.
options.onSuccess() => voidA callback function that is called when the user provides consent, facilitating further actions or analytics tracking.
options.titlestring (Optional)The title of the consent dialog. If not specified, a default title from the dashboard or predefined settings will be used.
options.textstring (Optional)The descriptive text displayed in the consent dialog, providing context or details about the consent being requested. Falls back to a default if not provided.

Example:

// Locate the DOM element where the consent dialog should be rendered
const consentElement = document.getElementById("consent-root");

// Define the onSuccess callback function
const handleConsentGiven = () => {
  console.log("User consent granted.");
};

// Define the configuration options for the consent dialog
const consentOptions = {
  session: session,
  onSuccess: handleConsentGiven,
  title: "Privacy and Cookies Consent",
  text: "We use cookies to ensure you get the best experience on our website. By continuing, you agree to our privacy policy.",
  // Optionally, provide a custom JSX component for additional consent options
  customCheck: null, // Assuming no custom JSX element is provided
};

// Call the renderUserConsent function with the defined parameters
renderUserConsent(consentElement, consentOptions);

renderCombinedConsent

Description:

Renders a combined consent interface within a specified DOM element. This function allows for displaying a consent form that is predefined in the dashboard.

Parameters:

NameTypeDescription
elementHTMLElementThe DOM element where the consent interface will be rendered. If null, the function will not perform any operation.
consentIdstringId of a consent configured in dashboard
tokenSessionThe session object get in createSession
onSuccess() => voidA callback function that is called when the user provides consent, facilitating further actions or analytics tracking.

Example:

// Locate the DOM element where the consent screen should be rendered
const consentElement = document.getElementById("consent-root");

// Define the onSuccess callback function
const handleConsentGiven = () => {
  console.log("Combined consent given.");
};

// Define the configuration options for the consent screen
const consentOptions = {
  token: session,
  onSuccess: handleConsentGiven,
  consentId: "someConsentId", // id of a consent created in dashboard
};

// Call the renderCombinedConsent function with the defined parameters
renderCombinedConsent(consentElement, consentOptions);

sendGeolocation

Description:

This is almost the same as addGeolocation with the difference being that this will automatically ask the user for the coordinates.

Parameters:

NameTypeDescription
tokenstringaccess token to be used in all other methods.

Returns:

  • Object:

    JSON object

  • JSON example:

    {
      "location": "Belgrade, Serbia"
    }
    

Example:

onBoarding.sendGeolocation({ token }).then((res) => res);

sendFingerprint

Description:

Sends relevant information about the user's device and Incode's Web SDK:

  • Browser version
  • Device model
  • Application type (Web application)
  • OS and OS version
  • Incode's Web SDK version
  • User's IP address

Parameters:

NameTypeDescription
tokenstringaccess token to be used in all other methods.

Returns:

  • Object:
{
    "success": boolean,
    "sessionStatus": string
}

Example:

onBoarding.sendFingerprint({ token: session.token }).then((response) => {
  console.log(response.success);
});

renderDocumentSelector

Description:

This method renders a Document Selector in a given container. It provides various customization options and callbacks for different stages of the document selection process. It accepts the same parameters as renderCamera, excluding type.

Parameters:

NameTypeDescription
elementReact.ReactNode | ElementThe container element or node where the document selector will be rendered.
optionsRenderCameraProps objectConfiguration options for the document selector.

Options:

NameTypeDefaultDescription
onSuccessfunctionemptyFuncCallback when the document selection is successful.
onErrorfunctionemptyFuncCallback when there is an error in the document selection process.
numberOfTriesnumber3The number of attempts allowed for document selection.
onLogfunctionemptyFuncA function for logging.
permissionMessagestringThe message shown in the permission screen.
permissionBackgroundColorstringThe background color of the permission screen.
tokenobjectThe session token.
timeoutnumber40000The timeout duration in milliseconds.
sendBase64booleantrueFlag to determine if the image should be sent in base64 format.
documentTypestringThe type of document to be selected.
showPreviewbooleanfalseFlag to show preview after document capture.
streamMediaStreamA media stream object.
nativeCamerabooleanfalseFlag to use the native camera for capture.
hideRetakebooleanfalseFlag to hide the retake option.
showTutorialbooleanfalseFlag to show a tutorial.
showPaperDLTutorialbooleanfalseFlag to show a paper driver's license tutorial.
onlyCapturebooleanfalseFlag to allow only capturing of images/documents.
scanPdf417booleanfalseFlag to scan for PDF417 barcodes.
videoTutorialSrcstringSource of the video tutorial.
showCustomCameraPermissionScreenbooleanfalseFlag to show a custom camera permission screen.
isSecondIdbooleanfalseFlag to indicate if the document is a second ID.
fullScreenbooleantrueFlag to enable full-screen mode.
assistedOnboardingbooleanfalseFlag to enable assisted onboarding.
isRecordingEnabledbooleanfalseFlag to enable recording during capture.
onRestartOnboardingfunctionreloadCallback to restart the onboarding process.
showDoublePermissionsRequestbooleanfalseFlag to show a double permissions request.
onlyAllowCapturebooleanfalseFlag to allow only capture (disables uploading of files/images).
disableFullScreenbooleanfalseFlag to disable full-screen behavior (uses container width/height).
onStreamReadyfunctionemptyFuncCallback when the stream is ready.
showAutoCaptureIDOverlaybooleanfalseFlag to show an automatic capture ID overlay.
showManualCaptureIDOverlaybooleanfalseFlag to show a manual capture ID overlay.
skipProcessFacebooleanfalseFlag to skip processing of the face in the document.
defaultHorizontalMaskbooleanfalseFlag to use a default horizontal mask for the capture.
isFixedMaskbooleanfalseFlag to indicate if the mask is fixed.
blurrinessStrictModebooleanfalseFlag to enable strict mode for blurriness detection.

Usage Example:

const element = document.getElementById("your-container-id");
const onSuccess = () => {
  /* success handler code */
};
const onError = () => {
  /* error handler code */
};

renderDocumentSelector(element, {
  onSuccess,
  onError,
  // ...other options
});

renderCamera

Description:

This method is going to render the camera with the autodetect and notifications
in the browser.

Parameters:

NameTypeDescription
typestringtype of captured image: `'front''back''selfiedocumentpassportsecondIdthirdIdinsuranceCard'`
containerHTMLElement
optionsObjectobjectoptions object

Options:

NameTypeDescription
onSuccessfunctionCallback when the detect was successful, with param object
onErrorfunctionCallback when the detect was unsuccessful
tokenObjectThe session object (optional if not presented is readed from state)
numberOfTriesNumberThe number of capturing attempts
onLogfunctionA function with a logger
permissionMessageStringThe message in the permission screen. Default: "Press "Allow" to continue."
permissionBackgroundColorStringThe background of permissions screen. Default: "#696969
sendBase64booleanIf you need to send the image in base64, set this to true (only if type = 'selfie')
timeoutnumberThe timeout in milliseconds before enabling the option for manual capture (starts only after an ID or face has been detected)
showPreviewbooleanSet to true to show capture preview. (only if type = 'selfie')
streamMediaStreamIf you send a stream, it won't ask the user again. This is an advanced option.
nativeCamerabooleanThis is only optional for documents. If set to true, it's going to use the native camera for the capture (default: false)
showTutorialbooleanOption to show the tutorial (default: false)
isRecordingEnabledbooleanOption to record the capture camera (default: false)
onRestartOnboardingfunctionCallback for the restart flow after camera access is denied (default: () => window.location.reload())
showDoublePermissionsRequestbooleanOption to show the custom permission prompt (default: false)
onlyAllowCapturebooleanOption to disable the uploading of files and images. Only works when the type is document and nativeCamera is set to true (default: false)
disableFullScreenbooleanOption to disable the full screen behaviour our SDK has. This will use the container width and height. Use this only for Desktop apps. (default:false)
showCustomCameraPermissionScreenbooleanOption to open a modal with instructions to allow camera permissions when user denies them. (default:false)

onSuccess parameters:

NameTypeDescription
classificationBooleanIs server classified image as a Id flag
correctGlareBooleanIs the glare in good range flag
correctSharpnessBooleanIs the sharpness in the good range flag
countryCodeStringValid ISO alpha-2 or alpha-3 code of the ID issuing country
glareNumberGlare level
horizontalResolutionNumberHorizontal resolution in pixels
issueNameStringName of provided ID
issueYearNumberThe year when the ID was issued
readabilityBooleanIs the data readable from the ID flag
sessionStatusStringCurrent status of the session
sharpnessNumberSharpness level
skipBackIdCaptureBooleanFlag for skipping back ID capture
typeOfIdStringType of ID (ID, Passport...)
failedReasonStringClassification fail reason.

Returns:

  • Object:

    JSON object

    NameTypeDescription
    closefunctionThis will close the camera and will unmount the component

Example:

const { close } = incode.renderCamera("front", container, {
  onSuccess: onSuccess,
  onError: onError,
});

// then you can close the SDK from your code
document.querySelector("#close-modal").addEventListener("click", () => {
  close(); // this will close the component prematurely, so use it only if you want to abort the process and close the camera
});

processId

Description:

This method should be called once the uploads of the front and back sides of the ID
are over. Incode validations, tests and OCR parsing are processed during this method.
To fetch OCR data, use the ocrData method. Parameter queueName is needed so it can
be determined in which queue the interview should go. Once this is called, the
user is no longer able to upload the ID (front, back side, passport or insurance
card)!

Parameters:

NameTypeDescription
tokenstringaccess token.

Returns:

  • Object:

    JSON object

  • JSON example:

    {
      "success": true
    }
    

Example:

const response = await onBoarding.processId({
  token,
});

renderVideoSelfie

Description:

This method renders the VideoSelfie Component.

📘

Localization not Supported

For videoSelfie to work a fixed language must be selected during /omni/start (How to Start a Session).

Please provide it along with the other parameters: {"language": "en-US"}

Parameters:

NameTypeDescription
containerHTMLElement
options Objectobjectoptions object
callback Objectobjectoptions object

Options:

NameTypeDescription
tokenStringThe token string (Mandatory)
showTutorialbooleanOption to show the tutorial (default: false)
modulesArray[String]The modules you want to perform in video selfie. Check the table to see all available modules (The default is all modules)
speechToTextCheckbooleanOption to perform the speech to text check. If this is false, the videoSelfie always will call onSuccess (default: true)
performLivenessbooleanOff/On liveness check, by default it is false
videoSelfieAsSelfiebooleanThe option to choose from which image you will make a face check, from selfie or video selfie. If it is true it will be from selfie
compareOCREnabledbooleanOption to off/on front OCR check (default: false)
compareIDEnabledbooleanOption to off/on front ID check (default: true)
compareBackOCREnabledbooleanOption to off/on back OCR check (default: false)
compareBackIDEnabledbooleanOption to off/on back ID check (default: false)
questionsCountNumberOption to set number of questions in questions module (default: 3)

Modules

NameDescription
selfieSelfie step
frontFront ID step
backBack ID step
poaProof of address step
questionsRandom questions step
speechThe user will perform an authorization. Important: this step is mandatory and needs to be the last one

Callback

NameTypeDescription
onSuccessfunctionCallback when the videoselfue was successful. If this is called it means the speech detection was successful.
onErrorfunctionCallback when the detect was unsuccessful. If this is called it means the speech detection was unsuccessful
numberOfTriesnumberThe number of tries in speech-to-text

Example:

onBoarding.renderVideoSelfie(
  container,
  {
    token: session,
    showTutorial: true,
    modules: ["front", "back", "speech", "selfie"], // you can add 'poa' and 'questions'
    speechToTextCheck: true, // this is the check for the speech
  },
  {
    onSuccess: () => alert("speech detected"),
    onError: () => alert("speech not detected"),
    numberOfTries: 3,
  }
);

renderConference

Description:

This method will render the Conference component

Parameters:

NameTypeDescription
containerHTMLElement
options Objectobjectoptions object
callback Objectobjectcallbacks object

Options:

NameTypeDescription
tokenObjectThe session object (Mandatory)
showOTPBooleanIf true, it will render the OTP screen before conference
numberOfTriesNumberThe number of tries that the user has for OTP. If you put -1 the user will have infinite tries. Default: 3
queueStringThe queue for the video conference. Default: ''

Callbacks:

NameTypeDescription
onSuccessfunctionPasses the status as a parameter. Possible statuses are: close, deny, approve
onErrorfunctionCallback when the detect was unsuccessful. Something went wrong in the conference
onConnectfunctionCallback when the conference is connected
onLogfunctionCallback for the logging

Example:

onBoarding.renderConference(
  container,
  {
    token: token,
    showOTP: false,
  },
  {
    onSuccess: (status) => {
      log(status);

      switch (status) {
        case "close":
          console.log("The conference was close");
          goToStep("closeCase");
          break;
        case "deny":
          console.log("The conference was denied");
          goToStep("denyCase");
          break;
        case "close":
          console.log("The conference was approved");
          goToStep("approveCase");
          break;
      }
    },
  }
);

renderLogin

Description:

This method renders the Face Login Component

Parameters:

NameTypeDescription
elementElementThe DOM element where the login component will be rendered.
onSuccessfunctionCallback when the detect was successful.
onErrorfunctionCallback when an error happened.
timeoutnumber (optional)Maximum time allowed for the login process, after which the onError callback is triggered.
stopAtAccessDeniedboolean (optional)Flag to trigger onError callback when access denied event happened.
stopAtErrorboolean (optional)Flag to trigger onError callback when any error event happened.
isOneToOneboolean (optional)Specifies if the login is for a one-to-one session.If true you will need to send oneToOneProps
oneToOnePropsObject (optional)Object containing additional properties for one-to-one sessions.
oneToOneProps.phonestring (optional)Phone number to use for one-to-one session authentication.
oneToOneProps.identityIdstring (optional)Identity ID for the user in one-to-one sessions. (Client Id)
oneToOneProps.emailstring (optional)Email address to use for one-to-one session authentication.
showCustomCameraPermissionScreenboolean (optional)Whether to show a custom camera permission screen instead of the default browser prompt.
isKioskboolean (optional)Indicates if the login is being used in a kiosk mode.

Example:

incode.renderLogin(container, {
  onSuccess: onSuccess,
  onError: onError,
});

renderEnterCurp

Description:

This method renders the component to enter and validate CURP.

Parameters:

NameTypeDescription
tokenstringaccess token to be used in all other methods.

Example:

incode.renderEnterCurp(document.getElementById('app'), {
  token: session.token,
  onSuccess: console.log,
  onError: console.log,,
})

renderSignature

Description:

This method will render the Signature Component.

Parameters:

NameTypeDescription
containerHTMLElement
options Objectobjectoptions object

Options:

NameTypeDescription
tokenStringThe token string (Mandatory)
onSuccessfunctionCallback when the upload of signature was successful
onErrorfunctionCallback when the upload of signature was unsuccessful
typestringType of signature. This can be used for sign contracts
initialsbooleanIf true, this will send initials and not signature
titlejsxThe title element in JSX syntax
subtitlejsxThe subtitle element in JSX syntax
canvasBackgroundColorstringThe background color of the canvas (default: '#fff')
canvasBorderColorstringThe border color of the canvas (default: '#20263d')
penColorstringThe pen color of the canvas (default: '#20263d')

Example:

onBoarding.renderSignature(document.getElementById("app"), {
  token: session.token,
  onSuccess: console.log,
  onError: console.log,
});

addPhone

Description:

Add phone number to an interview. If a customer with that phone number already exists, an error
will be thrown.

Parameters:

NameTypeDescription
tokenstringaccess token to be used in all other methods.
phonestringcustomer's phone number

Returns:

  • Object:

    JSON object

  • JSON example:

    {
      "success": true
    }
    

Example:

onBoarding.addPhone({ token, phone }).then((res) => res);

addCustomFields

Description:

This endpoint is used for adding custom fields to current onboarding session.

Parameters:

NameTypeDescription
tokenstringaccess token to be used in all other methods.
fieldsobjectObject of custom fields that will be inserted.

Returns:

  • Object:

    JSON object

  • `Parameters:

    NameTypeDescription
    successbooleanIf the call was called correctly.
  • JSON example:

    {
      "success": true
    }
    

Example:

incode.addCustomFields({
  token: session.token,
  fields: { watchlistName: name },
});

renderBiometricConsent

Description:

This method renders the component with biometric consent screen. It should be shown as a first screen if createSession function returns showMandatoryConsent with true value (in that case createSession will also return regulationType which you have to pass as param into this function).

Parameters:

NameTypeDescription
tokenobjectThe session object get in createSession
onSuccessfunctionCallback after consent is successfully given
onCancelfunctionCallback after consent is canceled
regulationTypestringState string received in createSession method if users Geo Ip Location is in California, Texas, Illinois or Washington (possible values: US_California, US_Texas, US_Illinois or US_Washington)

Example:

incode.renderBiometricConsent(document.getElementById("app"), {
  token: session,
  onSuccess: console.log,
  onCancel: console.log,
  regulationType: "US_Illinois",
});

renderMlConsent

Description:

This method will render the ML Consent component.

Parameters:

NameTypeDescription
containerHTMLElement
options Objectobjectoptions object

Options:

NameTypeDescription
tokenobjectThe token object (mandatory).
typestringML Type (Worldwide)
onSuccessfunctionCallback when the upload of signature was successful

Example:

onBoarding.renderMlConsent(document.getElementById("app"), {
  token: session,
  onSuccess() {
    console.log("ML accepted");
  },
});

renderQr

Description:

This method renders a Qr code which when scanned will open a specified URL or web flow application.

Parameters:

NameTypeDescription
containerHTMLElement
options Objectobjectoptions object

Options:

NameTypeDescription
sessionobject*The session object you get in createSession (Mandatory)
flowIdstringID of the flow that will be used in the mobile
onSuccessfunction*Callback when the onboarding in mobile was successful and completed
urlstringURL to be redirected to
primaryColorstringA hexcode string for styling, ie #000000
secondaryColorbooleanA hexcode string for styling, ie #FFFFFF
sizePxnumberA single number representing width and height in pixels

Example:

const flowId = "someflowid";

const session = await onBoarding.createSession("ALL", null, {
  configurationId: flowId,
});

if (onBoarding.isDesktop()) {
  onBoarding.renderQr(containerRef.current, {
    onSuccess: () => {
      showFinishScreen();
    },
    session: session,
    flowId: flowId,
  });
} else {
  // show mobile normal flow
  renderFrontId();
}

renderQrScanner

Description:

This method will render the QR Scanner component.

Parameters:

NameTypeDescription
containerHTMLElement
options Objectobjectoptions object

Options:

NameTypeDescription
sessionobjectThe session object (mandatory).
onSuccessfunctionCallback when the upload of signature was successful

Example:

onBoarding.renderQrScanner(document.getElementById("app"), {
  session: session,
  onSuccess() {
    console.log("QR scanned");
  },
});