Skip to main content

Method Signature

FAD_SDK.startAcuant(
  credentials: AcuantCredentials,
  idData: boolean,
  idPhoto: boolean,
  manualCapture: boolean,
  configuration?: Configuration
): Promise<AcuantResponse>

Description

The startAcuant() method initiates the Acuant document verification module for capturing and validating identification documents. This method provides document authentication, OCR data extraction, and photo extraction capabilities.

Parameters

credentials
AcuantCredentials
required
Acuant service credentials for authentication
idData
boolean
required
Whether to extract OCR data from the document
  • true - Extract OCR data from the document
  • false - Skip OCR data extraction
idPhoto
boolean
required
Whether to extract the photo from the identification document
  • true - Extract the face photo from the ID
  • false - Skip photo extraction
manualCapture
boolean
required
Capture mode selection
  • true - Manual capture mode (user controls when to take the photo)
  • false - Automatic capture mode (captures when document is detected)
configuration
Configuration
Optional configuration object for customizing the module’s behavior and appearance

Returns

AcuantResponse
Promise<object>
A promise that resolves with the Acuant module response

Code Example

import FadSDK from '@fad-producto/fad-sdk';

const CREDENTIALS = {
  username: 'YOUR_ACUANT_USERNAME',
  password: 'YOUR_ACUANT_PASSWORD',
  subscription: 'YOUR_SUBSCRIPTION_ID'
};

const TOKEN = 'YOUR_FAD_TOKEN';

const CONFIGURATION = {
  views: {
    instructions: true,
    preview: true,
  },
  customization: {
    fadCustomization: {
      colors: {
        primary: '#0066CC',
      },
      buttons: {
        primary: {
          backgroundColor: '#0066CC',
          labelColor: '#ffffff',
        },
      },
    },
  },
};

async function captureWithAcuant() {
  const options = {
    environment: FadSDK.getFadEnvironments().UATHA
  };

  const FAD_SDK = new FadSDK(TOKEN, options);
  
  try {
    const idData = true;        // Extract OCR data
    const idPhoto = true;       // Extract face photo
    const manualCapture = true; // Manual capture mode

    const moduleResponse = await FAD_SDK.startAcuant(
      CREDENTIALS,
      idData,
      idPhoto,
      manualCapture,
      CONFIGURATION
    );

    // Process the results
    console.log('Front image:', moduleResponse.data.id.front.image.data);
    
    if (moduleResponse.data.id?.back?.image?.data) {
      console.log('Back image:', moduleResponse.data.id.back.image.data);
    }
    
    console.log('Face photo:', moduleResponse.data.idPhoto);
    console.log('OCR data:', moduleResponse.data.idData.ocr);

  } catch (error) {
    if (error.code === FadSDK.Errors.Acuant.UNSUPPORTED_CAMERA) {
      console.error('Camera not supported');
    } else if (error.code === FadSDK.Errors.Acuant.FAIL_INITIALIZATION) {
      console.error('Failed to initialize Acuant');
    } else if (error.code === FadSDK.Errors.Acuant.FAIL_GET_OCR) {
      console.error('Failed to get OCR data');
    } else if (error.code === FadSDK.Errors.Acuant.FAIL_GET_FACE_IMAGE) {
      console.error('Failed to extract face image');
    } else {
      console.error('Error:', error);
    }
  } finally {
    FAD_SDK.end();
  }
}

Error Handling

The method may throw errors that can be identified using FadSDK.Errors.Acuant:
  • UNSUPPORTED_CAMERA - Camera is not supported on this device
  • FAIL_INITIALIZATION - Failed to initialize the Acuant SDK
  • FAIL_GET_OCR - Failed to extract OCR data from the document
  • FAIL_GET_FACE_IMAGE - Failed to extract face image from the document
  • FACE_IMAGE_URL_NOT_FOUND - Face image URL not found in response
  • FACE_IMAGE_NOT_FOUND - Face image not found in the document
See the Acuant Error Codes page for a complete list of error codes.
Always call FAD_SDK.end() in a finally block to properly clean up resources after the module completes or fails.

Build docs developers (and LLMs) love