> For the complete documentation index, see [llms.txt](https://docs.caf.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.caf.io/caf-sdk/android/standalone-modules/document-detector/sdks-response.md).

# SDKs response

## Overview

This page explains the reasons why an SDK is terminated. To do this, check the instance of the `SDKFailure` object class present in the result object.

| InstanceOf           | Description                                                                                                     | Example                                                                                                                     | Present SDKs                                                           |
| -------------------- | --------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------- |
| `null`               | The SDK was closed successfully. Your return objects are correctly filled in.                                   | When the user successfully executes the internal steps                                                                      | DocumentDetector, PassiveFaceLiveness, FaceAuthenticator               |
| `InvalidTokenReason` | The token entered is not valid for the corresponding product                                                    | Parameterize "test123" as token in the SDK builder                                                                          | DocumentDetector, PassiveFaceLiveness, FaceAuthenticator               |
| `PermissionReason`   | You are missing some mandatory permission to run the SDK                                                        | Start DocumentDetector without camera permission granted                                                                    | DocumentDetector, PassiveFaceLiveness, FaceAuthenticator, AddressCheck |
| `AvailabilityReason` | The SDK is not yet available for use. The variable `SDKFailure.getMessage()` contains instructions for the user | The device's internal storage is full when installing the app, and the face detection template cannot be installed together | PassiveFaceLiveness, FaceAuthenticator                                 |
| `NetworkReason`      | Internet connection failure                                                                                     | User was without internet during facematch in FaceAuthenticator                                                             | DocumentDetector, PassiveFaceLiveness, FaceAuthenticator, AddressCheck |
| `ServerReason`       | When an SDK request receives a status code of failure                                                           | In theory, it shouldn't happen. If you see something like this, let us know!                                                | DocumentDetector, PassiveFaceLiveness, FaceAuthenticator, AddressCheck |
| `SecurityReason`     | When the SDK cannot be started due to a security reason                                                         | When Google Security Provider is not updating                                                                               | DocumentDetector, PassiveFaceLiveness, FaceAuthenticator               |
| `StorageReason`      | There is no space on the user device's internal storage                                                         | When there is no space on the internal storage while capturing the document photo                                           | DocumentDetector, PassiveFaceLiveness, FaceAuthenticator               |
| `LibraryReason`      | When an SDK internal library cannot be started                                                                  | Forgetting to set theCompress configuration will lead to this failure in the DocumentDetector                               | DocumentDetector                                                       |
| `InvalidFaceReason`  | There is no face record for the given peopleId                                                                  | When the user authenticates with a peopleId that has no face record                                                         | FaceAuthenticator                                                      |

## Example

The following example shows how to discover and handle the shutdown reason for the DocumentDetector SDK using Kotlin:

```kotlin
    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
        super.onActivityResult(requestCode, resultCode, data)
        if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
            val result = data?.getSerializableExtra(
                DocumentDetectorResult.PARAMETER_NAME
            ) as DocumentDetectorResult

            if (!result.wasSuccessful()) {
                result.sdkFailure?.let {
                    onSdkFailure(it)
                }
                return
            }

            println("DocumentDetectorResult: $result")
        } else {
            println("The user canceled the operation")
        }
        super.onActivityResult(requestCode, resultCode, data)
    }

    private fun onSdkFailure(sdkFailure: SDKFailure?) {
        when (sdkFailure) {
            is InvalidTokenReason -> {
                println("SDKFailure: The token entered as a parameter is not valid, please revise it")
            }
            is PermissionReason -> {
                println("SDKFailure: The user did not grant the necessary permissions")
            }
            is AvailabilityReason -> {
                println("SDKFailure: Instructions are sent in: ${sdkFailure.message}")
            }
            is NetworkReason -> {
                println("SDKFailure: There was a problem with the internet connection")
            }
            is ServerReason -> {
                println("SDKFailure: There was a problem in any communication with the CAF servers, let us know!")
            }
            is SecurityReason -> {
                println("SDKFailure: There was a security problem on the user's device")
            }
            is StorageReason -> {
                println("SDKFailure: There was a problem with the internal storage of the user's device")
            }
            is LibraryReason -> {
                println("SDKFailure: There was a problem with the internal library")
            }
            else -> {
                println("SDKFailure: Unknown reason")
            }
        }
    }
```

## Security Returns

We are constantly taking actions to make the product more secure, mitigating many attacks observed in the capture processes and reducing as many identity fraud attempts as possible. The errors described here are returned in the `message` field of the `SecurityReason` class.

### Error 300

Represents the blocking of devices with developer mode active.

Developer mode allows users to access advanced settings, such as debugging apps via USB. By default, the SDKs block devices in developer mode.

To disable this validation, use the `.setUseDeveloperMode(bool use)` method in the SDK Builder.

### Error 400

Represents the blocking of devices with Android Debug Bridge (ADB) enabled.

ADB allows users to install and debug apps and access a Unix shell. By default, the SDKs block devices with ADB enabled.

To disable this validation, use the `.setUseAdb(bool use)` method in the SDK Builder.

### Error 500

Represents the blocking of devices with debug mode enabled.

Debug mode allows users to debug applications via USB, enabling them to bypass SDK flows. By default, the SDKs block devices in debug mode.

To disable this validation, use the `.setUseDebug(bool use)` method in the SDK Builder.

### Error 600

Represents the blocking of devices with fraudulent app signatures.

Signature verification blocks reverse engineering attacks and all other malicious attacks that can be done after this process in which the app has its original signature changed. Because of this, SDKs perform this blocking by default.

If you want to disable this validation, use the `.checkAppSignature(use: Boolean)` method in the SDK Builder.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.caf.io/caf-sdk/android/standalone-modules/document-detector/sdks-response.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
