# Lookup Flow

**Note:** This feature requires an additional permission and must be explicitly requested

The "Lookp Flow" it's the same as the "Enrollment Flow" with the only difference that the first step is not the automatic scanning of a document through the camera phone but the user is asked to manually type in some information of the document that can be used to perform the lookup on the government database. Only one document at the time is supported. Other features like facial recognition and background check can be enabled in the same way as per the "Enrollment Flow". Note that not all the documents are supported.

In order to use our SDK you need an authorization token. Please check our API "[Authorisation](https://docs.uqudo.com/docs/kyc/uqudo-api/authorisation)" in this regard.

The following method should be called when the application is initiated:

```kotlin
UqudoSDK.init(applicationContext)
```

The Uqudo SDK provides a builder class to initiate the "Lookup Flow". See the example below:

```kotlin
try {
   val uqudoIntent = UqudoBuilder.Lookup()
            .setToken(authorizationToken)
            .setDocumentType(DocumentType.NGA_DL)
            .enableFacialRecognition(
                     FacialRecognitionConfigurationBuilder()
                              .setLookupMinimumMatchLevel(4)
                              .build()
            )
            .enableBackgroundCheck(
                     BackgroundCheckConfigurationBuilder()
                              .skipView()
                              .build()
            )
            .build(this)
        startActivityForResult(uqudoIntent, 101)
} catch( e: Exception ){
    ...
}
```

## **Uqudo Lookup Builder Configuration**

In order to check if the document type supports the "Lookup Flow" you can use the following method:

```kotlin
DocumentType.NGA_DL.lookupSupported
```

Configuration options provided in the Uqudo Lookup builder are:

<table><thead><tr><th width="183">Property</th><th width="104">Type</th><th width="102">Optional</th><th width="93">Default</th><th>Description</th></tr></thead><tbody><tr><td>setToken(token)</td><td>String</td><td>No</td><td>null</td><td>See <a href="../../../uqudo-api/authorisation">Authorisation</a></td></tr><tr><td>setNonce(nonce)</td><td><p>String</p><p>(max size 64 chars)</p></td><td>Yes</td><td>null</td><td>Nonce provided by the customer mobile application when the SDK is initiated. It is useful to make sure the process has been initiated by the customer mobile application. It should be generated server side.</td></tr><tr><td>setSessionId(sessionId)</td><td><p>String</p><p>(UUID v4)</p></td><td>Yes</td><td>Auto generated</td><td><strong>Note</strong>: make sure to create always a new session id when you trigger the SDK flow</td></tr><tr><td>disableSecureWindow()</td><td>None</td><td>Yes</td><td>false</td><td>Whether to allow users to take screenshots and capture screen recording or not.</td></tr><tr><td>enableFacialRecognition()</td><td>None</td><td>Yes</td><td>None</td><td>Enable facial recognition with a default configuration, see <a href="#facial-recognition-configuration">Facial Recognition Configuration</a>.</td></tr><tr><td>enableFacialRecognition(configuration)</td><td>FacialRecognitionSpecification</td><td>Yes</td><td>None</td><td>Enable facial recognition with a custom configuration, see <a href="#facial-recognition-configuration">Facial Recognition Configuration</a>.</td></tr><tr><td>enableBackgroundCheck(configuration)</td><td>BackgroundCheckSpecification</td><td>Yes</td><td>None</td><td>Enable background check with a custom configuration, see <a href="#background-check-configuration">Background Check Configuration</a>.</td></tr><tr><td>setDocumentType(document)</td><td>Document</td><td>No</td><td>None</td><td>Set the document type. Please refer to the Scan API for <a href="../../../uqudo-api/scan">supported Document Types</a>.</td></tr><tr><td>returnDataForIncompleteSession()</td><td>None</td><td>Yes</td><td>false</td><td>When enabled, if the user or the SDK drops the session before completion, the SDK will return the partial data together with the SessionStatus object (see <a href="#handling-the-result">Handling the Result</a>). Please note that you can expect some data only if the user passes at least the lookup step</td></tr></tbody></table>

## **Facial Recognition Configuration**

In order to check if the document type supports facial recognition you can use the following method:

```kotlin
DocumentType.NGA_DL.lookupFacialRecognitionSupported
```

By default the facial recognition is disabled. You need to enable Facial Recognition explicitly. See the example below:

```kotlin
...
        .enableFacialRecognition(
           FacialRecognitionConfigurationBuilder()
              .setLookupMinimumMatchLevel(4)
              .build()
        )
```

Facial Recognition configuration options available:

<table><thead><tr><th width="179">Property</th><th width="76">Type</th><th width="100">Optional</th><th width="89">Default</th><th>Description</th></tr></thead><tbody><tr><td>setLookupMinimumMatchLevel(matchLevel)</td><td>Int</td><td>Yes</td><td>None</td><td>Defines the minimum match level that the facial recognition has to meet for pictures from the government database</td></tr><tr><td>setMaxAttempts(maxAttempts)</td><td>Int</td><td>Yes</td><td>3</td><td>Set the max failed facial recognition attempts before dropping the session.<br><strong>Note</strong>: only values between 1 and 3 are taken into consideration.</td></tr><tr><td>allowClosedEyes()</td><td>None</td><td>Yes</td><td>False</td><td>Allows to have closed eyes during facial recognition.</td></tr><tr><td>enableOneToNVerification()</td><td>None</td><td>Yes</td><td>False</td><td>Once activated, following a successful facial recognition (confirming liveness and matching the face), the system initiates a search for the user's selfie within your tenant. If the selfie is not found, it is added, and the indexed facial features are stored in the database. The SDK result includes a unique ID in the face object, along with an indication of whether there was a match with a previously onboarded selfie. It's essential to store this unique ID in your system alongside the user's record, facilitating future searches for users with the same ID. Please be aware that this option requires a specific permission, otherwise, it will be disregarded</td></tr><tr><td>enableActiveLiveness(disableLivenessGesture)</td><td>LivenessGesture</td><td>Yes</td><td>Not enabled</td><td><p>Enable active liveness when performing facial recognition. There are three gestures:</p><ul><li>LivenessGesture.FACE_MOVE</li><li>LivenessGesture.FACE_TILT</li><li>LivenessGesture.FACE_TURN</li></ul><p>Every gesture has two actions associated resulting in a total of six possible actions (move closer, move further, tilt right, tilt left, turn right, turn left). During verification, the SDK will randomly prompt the user to perform one of these actions to continue.<br>The configuration allows you to disable one gesture type, reducing the pool to four actions.<br><strong>Warning</strong>: We recommend enabling this feature only if required for regulatory or compliance purposes, as it may significantly impact user conversion rates.</p></td></tr></tbody></table>

## **Background Check Configuration**

**Note:** This feature requires an additional permission and must be explicitly requested

By default the Background Check is disabled. You need to enable Background Check explicitly. See the example below:

```kotlin
...
        .enableBackgroundCheck(
             BackgroundCheckConfigurationBuilder()
               .skipView()
               .build()
         )
```

Background Check configuration options available:

<table><thead><tr><th width="180">Property</th><th width="113">Type</th><th width="99">Optional</th><th width="95">Default</th><th>Description</th></tr></thead><tbody><tr><td>disableConsent()</td><td>None</td><td>Yes</td><td>false</td><td>Disable consent option for the user</td></tr><tr><td>setBackgroundCheckType(type)</td><td>BackgroundCheckType</td><td>Yes</td><td>RDC</td><td>Sets the background check type</td></tr><tr><td>enableMonitoring()</td><td>None</td><td>Yes</td><td>false</td><td>Enable continuous monitoring</td></tr><tr><td>skipView()</td><td>None</td><td>Yes</td><td>false</td><td>If enabled, the step will be skipped, and the SDK will trigger the background check without any user interaction.</td></tr></tbody></table>

## **Handling Exceptions**

The Uqudo SDK will throw certain exceptions which need to be handled by the application. The Exceptions are:

1. IllegalStateException - e.g. enabling the "Lookup Flow" for a document that doesn’t support it or because facial recognition is enabled and the documcent doesn't support it or because of some required configuration missing

## **Handling the Result**

The enrollment result will be available to the application in the calling Activity’s onActivityResult method:

```kotlin
...
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
   super.onActivityResult(requestCode, resultCode, data)
   if (resultCode == Activity.RESULT_OK) {
       val result = data?.getStringExtra("data")
   } else if (resultCode == Activity.RESULT_CANCELED) {
       if (data != null) {
         val sessionStatus = data.getParcelableExtra("key_session_status") as SessionStatus
         println("Enrollment failed due to ${sessionStatus.sessionStatusCode.message} at ${sessionStatus.sessionTask.name()}")
       }
   }
}
```

If the resultCode is equals to Activity.RESULT\_OK you can find the SDK result in the data attribute. The string is the JWS, see "[SDK result](https://docs.uqudo.com/docs/kyc/uqudo-sdk/sdk-result)" for details.

If the resultCode is equals to Activity.RESULT\_CANCELED you can find the **SessionStatus** object result in the data attribute under the key “**key\_session\_status**”. The **SessionStatus** contains the following properties:

**sessionStatusCode** as SessionStatusCode enum that contains the following error codes:

1. **USER\_CANCELLED** = User canceled the enrollment process
2. **SESSION\_EXPIRED** = Session expired or not found
3. **UNEXPECTED\_ERROR** = Something went wrong
4. **SESSION\_INVALIDATED\_OTP\_TOO\_MANY\_ATTEMPTS** = Some documents require an OTP step. The error is trigger if for example the OTP expires multiple times and the user is not moving forward
5. **SESSION\_INVALIDATED\_FACE\_RECOGNITION\_TOO\_MANY\_ATTEMPTS** = Session gets invalidated because of too many failed facial recognition attempts

**sessionTask** as SessionTask enum that contains the following codes:

1. **LOOKUP** = The lookup task
2. **FACE** = The facial recognition task
3. **BACKGROUND\_CHECK** = The background check task (only if skipView() is not enabled)

**data** as String that contains the JWS object with the partial data of an incomplete KYC session. Returning the partial data for an incomplete KYC session is disabled by default, please see the related option in the [Lookup Configuration Builder](#uqudo-builder-lookup-configuration) for details.
