LogoLogo
Useful links
  • Home
  • Product guides
  • API
  • SDKs
  • Overview
  • First steps
  • ANDROID
    • Getting Started with the SDK
    • Standalone Modules
      • Document Detector
        • Release Notes
        • Current Version
        • Requirements
        • Gradle Dependencies
        • Gradle Source Code
        • Setting up the SDK
          • Setting properties
          • Capture Stages
          • Messages Settings
          • Customization
          • Security Settings
          • Detection Steps
          • Upload Mode
          • Advanced Settings
            • Proxy configuration
            • Preview configuration
        • Start Document Detection
        • Source Code
        • Google security form
        • Reduce SDKs size
        • SDKs response
        • References
        • FAQ
      • Face Liveness
        • Release Notes
        • Current Version
        • Requirements
        • Gradle Dependencies
        • Gradle Source Code
        • SDK Lifecycle
        • Building the SDK
        • Start Liveness Verification
        • Source Code
        • References
        • Advanced Features
        • FAQ
      • Face Authenticator
        • Release Notes
      • Smart Auth
        • Release Notes
        • Current Version
        • Requirements
        • Gradle Dependencies
        • Gradle Source Code
        • Permissions
        • SDK Lifecycle
        • Building the SDK
        • Start Smart Authentication
        • Source Code
        • References
        • FAQ
      • Face Liveness (deprecated)
        • Release Notes
  • iOS
    • Getting Started with the SDK
    • Standalone Modules
      • Document Detector
        • Release Notes
        • Current Version
        • Requirements
        • Installing the SDK
        • Setting up the SDK
          • Setting properties
          • Messages Settings
          • Customization
          • Detection Steps
          • Upload Mode
          • Advanced Settings
            • Proxy configuration
            • Preview configuration
        • Start Document Detection
        • References
        • FAQ
      • Face Liveness
        • Release Notes
        • Installation
        • Current Version
        • Requirements
        • SDK Lifecycle
        • Building the SDK
        • Start Liveness Verification
        • Source Code
        • References
        • FAQ
      • Face Authenticator
        • Release Notes
        • Installation
        • Current Version
        • Requirements
        • Building the SDK
        • Start the SDK
        • References
        • FAQ
      • Smart Auth
        • Release Notes
        • Installation
        • Current Version
        • Requirements
        • SDK Lifecycle
        • Building the SDK
        • Start Smart Authentication
        • Source Code
        • References
        • FAQ
      • Face Liveness (deprecated)
        • Release Notes
  • REACT NATIVE
    • Standalone Modules
      • Document Detector
        • Release Notes
        • Current Version
        • Requirements
        • Installation
        • Hooks
        • Start Document Verification
        • Source Code
        • TypeScript References
        • Customizing Style
        • FAQ
      • Face Liveness
        • Release Notes
        • Current Version
        • Requirements
        • Installation
        • Hooks
        • Start Liveness Verification
        • Source Code
        • TypeScript References
        • FAQ
      • Face Authenticator
        • Release Notes
        • Current Version
        • Requirements
        • Installation
        • Hooks
        • Start Authentication Verification
        • Source Code
        • TypeScript References
        • FAQ
      • Smart Auth
        • Getting started
        • Release notes
        • Using Native Modules
          • Requirements
          • Gradle Source Code
          • Podfile Source Code
          • Native Module Android
          • Native Module iOS
          • Import Native Modules
          • Source Code
          • TypeScript References
          • FAQ
        • Using Expo Modules
          • Requirements
          • Create Local Expo Module
          • Gradle Source Code
          • Podspec Source Code
          • Native Module Android
          • Native Module iOS
          • Import Expo Modules
          • Source Code
          • TypeScript References
          • FAQ
  • WEB (JAVASCRIPT)
    • Standalone Modules
      • Document Detector
        • Getting started
        • SDK builder options
          • Analytics
          • Appearance
          • Messages
        • SDK methods
        • Event listeners
        • Customization
        • Release notes
      • Face Liveness
        • Customization
        • Release notes
      • Face Authenticator
        • Customization
        • Release notes
      • Smart Auth
        • SDK errors
        • Customization
        • Release notes
LogoLogo

2025 © Caf. - All rights reserved

On this page
  • initialize
  • capture
  • Input
  • Output
  • close
  • dispose
  • isSupported
  • getIsInitialized
  • loadAiModel
  1. WEB (JAVASCRIPT)
  2. Standalone Modules
  3. Document Detector

SDK methods

Last updated 2 months ago

This section provides detailed documentation for each SDK method. Scroll down to learn more about how to use each method, including their parameters, usage examples, and important notes.

initialize

The initialize method is used to initialize the SDK. This method sets up internal variables and downloads the necessary resources for the SDK to function.

Important

  • The initialization process can take a few seconds. It is recommended to call this function as early as possible in your flow to ensure a smooth user experience.

Example

await sdk.initialize();

capture

The capture method is used to load the SDK onto the screen and perform document capture. It initializes the video stream (requesting permissions if needed) and loads it into the container.

For more information on input parameters and output results, refer to the lists below:

Input

The capture method takes one parameter:

const captureResult = await documentDetector.capture(options);

This parameter is an object containing the capture options. The following table lists the available capture options:

Parameter

Type

Required?

Default Value

expectedDocument

Type and side of the document expected to be detected by the SDK. If value is "any" then any type of document will be accepted.

"rg_front" | "rg_back" | "rg_full" | "cnh_front" | "cnh_back" | "cnh_full" | "crlv" | "rne_front" | "rne_back" | "passport" | "ctps_front" | "ctps_back" | "any"

Yes.

-

mode

The capture mode. Can be "automatic", "manual" or "upload".

If the option enableFramingAnalyzer was manually set to false, the capture mode will be forced to manual regardless of the value passed in this parameter.

"automatic" | "manual" | "upload"

Yes.

-

automaticCaptureMaxDuration

The maximum duration in seconds for the automatic capture. If the duration is exceeded, the manual capture will be triggered.

number

No.

60

uploadFileType

The type of the file to be uploaded. The value can be "IMAGE", "PDF" or undefined. If the value is undefined, both image and PDF files can be uploaded.

"IMAGE" | "PDF" | undefined

No.

Both "IMAGE" and "PDF".

personID

The ID of the person (used for tracking purposes).

string

No.

undefined

forceEndWhenInvalid

Determines whether the capture should be forcefully finished when it is invalid.

boolean

No.

false

Output

The output parameters are returned as an object containing the following fields:

Parameter

Type

Example

image.url

string

"image-url-here"

image.blob

Blob

image-blob-here

image.storageInfo.key

string

"s3-bucket-key-here"

image.storageInfo.bucket

string

"s3-bucket-here"

detectedDocument.type

"blank" | "rg" | "rg_new" | "cnh" | "cnh_new" | "cin" | "rne" | "rnm" | "ctps" | "passport" | "crlv" | "generic"

"passport"

detectedDocument.side

"front" | "back" | "both" | "not_applicable"

"front"

isCaptureValid

boolean

true

Example

// Load the SDK onto the screen and perform document capture.
const result = await documentDetector.capture({
  expectedDocument: "cnh_front",
  mode: "automatic",
  automaticCaptureMaxDuration: 30,
  personID: "my-person-id",
});
// Destructure fields from the SDK result
const {
  image, // example: { url: "image-url-here", blob: image-blob-here, storageInfo: { key: "s3-bucket-key-here", bucket: "s3-bucket-here" } }
  detectedDocument, // example: { type: "cnh", side: "front" }
  isCaptureValid, // example: true
} = result;
// Example usage of the destructured fields
console.log("Captured Image URL:", image.url);
console.log("Detected Document Type:", detectedDocument.type);
console.log("Is Capture Valid:", isCaptureValid);

close

The close method is used to remove the SDK from the screen, removing its visual elements from the DOM.

Example

await sdk.close();

dispose

The dispose method is used to de-initialize the SDK. It stops the video stream and clears the SDK's internal variables.

Example

await sdk.dispose();

isSupported

The isSupported method checks if the browser supports the SDK.

Example

const isSupported: boolean = sdk.isSupported();

getIsInitialized

The getIsInitialized method checks if the SDK is initialized.

Example

const isInitialized: boolean = sdk.getIsInitialized();

loadAiModel

If the option enableFramingAnalyzer was manually set to false, this method will have no effect when called.

The loadAiModel method is optional, but it can greatly enhance the SDK's loading performance. For optimal results, we recommend invoking it as early as possible in your workflow, ideally before reaching the SDK's loading screen. However, if this is not feasible or does not align with the specific requirements of your integration, the initialize method will automatically handle all necessary initialization tasks to ensure the SDK operates correctly.

Example

await documentDetector.loadAiModel();

initialize
capture
close
dispose
isSupported
getIsInitialized
loadAiModel
Go back to the top
Go back to the top
Go back to the top
Go back to the top
Go back to the top
Go back to the top
Go back to the top