> 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/react-native/standalone-modules/document-detector/typescript-references.md).

# TypeScript References

## Types

### `DocumentDetectorResponse`

| Field       | Type                                                      | Description                                                |
| ----------- | --------------------------------------------------------- | ---------------------------------------------------------- |
| `result`    | [DocumentDetectorResult](#documentdetectorresult) or null | Shows when document detector returns a successful capture. |
| `error`     | [DocumentDetectorError](#documentdetectorerror) or null   | Shows when the document detector return some error.        |
| `cancelled` | boolean                                                   | Shows when user cancel the document detector.              |

### `DocumentDetectorResult`

| Field        | Type                                                    | Description                                                                                                                                                                                                                              |
| ------------ | ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `captures`   | [DocumentDetectorCapture\[\]](#documentdetectorcapture) | The array with the respective captures of the parameterized documents                                                                                                                                                                    |
| `trackingId` | string                                                  | Identifier of this run on our servers. If possible, save this field and send it along to our API. This way we will have more data about how the user behaved during the execution                                                        |
| `type`       | string                                                  | The class of the read document stream. This parameter is useful in an integration with our OCR route. The existing types are: `["blank", "cnh", "cnh_new", "generic", "rg", "rg_new", "rne", "rnm", "ctps", "passport, crlv, crlv_new"]` |

### `DocumentDetectorError`

| Field        | Type            | Description                        |
| ------------ | --------------- | ---------------------------------- |
| `statusCode` | string          | Https code status.                 |
| `message`    | string          | Detailed error message.            |
| `error`      | [Error](#error) | Enum describing the type of error. |

### `DocumentDetectorSettings`

| Field                        | Type                                                                  | Description                                                                                                                                                                                                                                                                                                                                     |                                             Android                                            | iOS | Requerid |
| ---------------------------- | --------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------: | :-: | :------: |
| `documentSteps`              | [DocumentDetectorStep\[\]](#documentdetectorstep)                     | Defines the document capture flow.                                                                                                                                                                                                                                                                                                              |                                                ✅                                               |  ✅  |     ✅    |
| `captureStages`              | [DocumentDetectorCaptureStage\[\]](#documentdetectorcapturestage)     | Configures the requirements for each capture stage. Designed to make capture more flexible in cases where the user is unable to capture with all checks active, preventing them from getting stuck at this stage in their registration flow.                                                                                                    |                                                ✅                                               |  ❌  |     ❌    |
| `cafStage`                   | [Stage](#stage)                                                       | Change the development environment.                                                                                                                                                                                                                                                                                                             |                                                ✅                                               |  ✅  |     ❌    |
| `popupSettings`              | boolean                                                               | Enables/disables the popups displayed before each document capture.                                                                                                                                                                                                                                                                             |                                                ✅                                               |  ✅  |     ❌    |
| `networkSettings`            | number                                                                | Defines SDK's requests timeout.                                                                                                                                                                                                                                                                                                                 |                                                ✅                                               |  ✅  |     ❌    |
| `sensorSettings`             | [DocumentDetectorSensorSettings](#documentdetectorsensorsettings)     | Object of the configuration for define the sensors of the SDK.                                                                                                                                                                                                                                                                                  |                                                ✅                                               |  ✅  |     ❌    |
| `proxySettings`              | [DocumentDetectorProxySettings](#documentdetectorproxysettings)       | Defines your proxy to make requests.                                                                                                                                                                                                                                                                                                            |                                                ✅                                               |  ✅  |     ❌    |
| `previewSettings`            | [DocumentDetectorPreviewSettings](#documentdetectorpreviewsettings)   | Enables/disables and allows the configuration of the visualization of the capture performed, requesting the user's confirmation to proceed.                                                                                                                                                                                                     |                                                ✅                                               |  ✅  |     ❌    |
| `compressSettings`           | number                                                                | Allows you to configure the quality in the compression process. By default, all captures go through compression. The method expects values between 80 and 100 as a parameter, where 100 is the best quality compression.                                                                                                                        |                                                ✅                                               |  ✅  |     ❌    |
| `manualCaptureSettings`      | number                                                                | Enables/disables manual capture.                                                                                                                                                                                                                                                                                                                |                                                ❌                                               |  ✅  |     ❌    |
| `imageUrlExpireTime`         | string                                                                | <p>Sets the time the image URL will last on the server until it is expired. Expect to receive a time interval between "30m" to "30d".<br><br>Examples:<br><code>"30m"</code>: To set minutes only<br><code>"24h"</code>: To set only hour(s).<br><code>"1h 10m"</code>: To set hour(s) and minute(s).<br><code>"10d"</code>: To set day(s).</p> |                                                ✅                                               |  ✅  |     ❌    |
| `currentStepDoneDelay`       | number                                                                | Delays the activity after the completion of each step.                                                                                                                                                                                                                                                                                          |                                                ✅                                               |  ✅  |     ❌    |
| `resolutionSettings`         | [Resolution](#resolution)                                             | Allows you to set the capture resolution.                                                                                                                                                                                                                                                                                                       |                                                ✅                                               |  ✅  |     ❌    |
| `allowedPassportList`        | [CountryCodes\[\]](#countrycodes)                                     | Enables the option to allow passports from only a certain issuing country, or, a list of countries.                                                                                                                                                                                                                                             |                                                ✅                                               |  ✅  |     ❌    |
| `messageSettings`            | [DocumentDetectorMessageSettings](#documentdetectormessageesettings)  | To custom messages use this object.                                                                                                                                                                                                                                                                                                             |                                                ✅                                               |  ✅  |     ❌    |
| `uploadSettings`             | [DocumentDetectorUploadSettings](#documentdetectoruploadsettings)     | To enable the document upload functionality it is necessary to use this object.                                                                                                                                                                                                                                                                 |                                                ✅                                               |  ✅  |     ❌    |
| `style`                      | [DocumentDetectorStyle](#documentdetectorstyle)                       | Defines the primary color and feedback colors of the SDK.                                                                                                                                                                                                                                                                                       | [See example](/caf-sdk/react-native/standalone-modules/document-detector/customizing-style.md) |  ✅  |     ❌    |
| `securitySettings`           | [DocumentDetectorSecuritySettings](#documentdetectorsecuritysettings) | The SDK has some blocks that may prevent its execution in certain contexts. To disable them, you can use the methods as shown in the example below.                                                                                                                                                                                             |                                                ✅                                               |  ❌  |     ❌    |
| `useManualCaptureAsFallback` | boolean                                                               | Enables/Disables option when devices cannot instantiate the AI embedded in memory                                                                                                                                                                                                                                                               |                                                ✅                                               |  ❌  |     ❌    |

### `DocumentDetectorStep`

| Field           | Type                  | Description                                                     | Android | iOS |
| --------------- | --------------------- | --------------------------------------------------------------- | ------- | :-: |
| `document`      | [Document](#document) | Defines the document capture flow.                              | ✅       |  ✅  |
| `stepLabel`     | string                | Defines text to be shown in the lower part of the layout.       | ✅       |  ✅  |
| `showStepLabel` | boolean               | Present the text to be displayed at the top of the layout.      | ✅       |  ✅  |
| `illustration`  | string                | Defines illustration to be shown in the popup prior to capture. | ✅       |  ✅  |

### `DocumentDetectorCaptureStage`

| Field             | Type                        | Description                                                  | Android | iOS |
| ----------------- | --------------------------- | ------------------------------------------------------------ | ------- | :-: |
| `captureMode`     | [CaptureMode](#capturemode) | Defines the capture mode.                                    | ✅       |  ❌  |
| `durationMillis`  | number                      | Duration of the stage, in milliseconds.                      | ✅       |  ❌  |
| `wantSensorCheck` | boolean                     | Enables/Disables the use of sensors for capturing the photo. | ✅       |  ❌  |

### `DocumentDetectorSensorSettings`

| Field               | Type                                                                                            | Description                                                                                                                                                 | Android | iOS |
| ------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | :-: |
| `luminositySensor`  | number                                                                                          | Defines threshold between acceptable/unacceptable ambient brightness.                                                                                       | ✅       |  ✅  |
| `orientationSensor` | number                                                                                          | Defines threshold between correct/incorrect device orientation. Higher the value more flexible it will be.                                                  | ✅       |  ✅  |
| `stabilitySensor`   | [DocumentDetectorSensorSettingsStabilitySensor](#documentdetectorsensorsettingsstabilitysensor) | Changes the default settings of the stability sensor. The threshold of this sensor is in the range of the last two accelerations collected from the device. | ✅       |  ✅  |

#### `DocumentDetectorSensorSettingsStabilitySensor`

| Field           | Type   | Description                                                                                           | Android | iOS |
| --------------- | ------ | ----------------------------------------------------------------------------------------------------- | :-----: | :-: |
| `stabledMillis` | number | Defines stability sensor settings.                                                                    |    ✅    |  ❌  |
| `threshold`     | number | The threshold of this sensor is in the range of the last two accelerations collected from the device. |    ✅    |  ✅  |

### `DocumentDetectorProxySettings`

| Field            | Type                                                                                        | Description                                                  | Android | iOS |
| ---------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | :-----: | :-: |
| `hostname`       | string                                                                                      | Sets the domain or IP address of the proxy service.          |    ✅    |  ✅  |
| `port`           | number                                                                                      | Sets the port to be used.                                    |    ✅    |  ✅  |
| `authentication` | [DocumentDetectorProxySettingsAuthentication](#documentdetectorproxysettingsauthentication) | Enables/Disables the use of sensors for capturing the photo. |    ✅    |  ✅  |

#### `DocumentDetectorProxySettingsAuthentication`

| Field      | Type   | Description                             | Android | iOS |
| ---------- | ------ | --------------------------------------- | :-----: | :-: |
| `user`     | string | Username to be used for authentication. |    ✅    |  ✅  |
| `password` | number | Password to be used for authentication. |    ✅    |  ✅  |

### `DocumentDetectorPreviewSettings`

| Field          | Type    | Description                                                                                                                                 | Android | iOS |
| -------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------- | :-----: | :-: |
| `show`         | boolean | Enables/disables and allows the configuration of the visualization of the capture performed, requesting the user's confirmation to proceed. |    ✅    |  ✅  |
| `title`        | string  | Sets the title shown on the screen.                                                                                                         |    ✅    |  ✅  |
| `subtitle`     | string  | Sets the subtitle displayed on the screen.                                                                                                  |    ✅    |  ✅  |
| `confirmLabel` | string  | Sets the message displayed on the confirmation button.                                                                                      |    ✅    |  ✅  |
| `retryLabel`   | string  | Sets the message displayed on the button to perform a new capture.                                                                          |    ✅    |  ✅  |

### `DocumentDetectorMessageSettings`

| Field                           | Type   | Description                                                                                                                                                                                                                                                                                                     | Android | iOS |
| ------------------------------- | ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :-----: | :-: |
| `waitMessage`                   | string | Message displayed when you start the camera                                                                                                                                                                                                                                                                     |    ✅    |  ✅  |
| `fitTheDocumentMessage`         | string | Message telling you to fit the document to the mask                                                                                                                                                                                                                                                             |    ✅    |  ✅  |
| `holdItMessage`                 | string | Message displayed at the moment the capture is being performed                                                                                                                                                                                                                                                  |    ✅    |  ✅  |
| `verifyingQualityMessage`       | string | Message displayed when the SDK makes a request to the backend, checking for quality                                                                                                                                                                                                                             |    ✅    |  ✅  |
| `lowQualityDocumentMessage`     | string | Message displayed when the capture quality fails                                                                                                                                                                                                                                                                |    ✅    |  ✅  |
| `uploadingImageMessage`         | string | Message displayed when there is no quality check and the capture is being saved on the servers                                                                                                                                                                                                                  |    ✅    |  ✅  |
| `openDocumentWrongMessage`      | string | Message displayed when displaying an open document, the message will be displayed together with the error message on the document being used, example: if the user displays an open CNH(Brazilian drive’s license), the standard error message "Essa é uma CNH Aberta" + the defined message will be displayed. |    ✅    |  ❌  |
| `popupDocumentSubtitleMessage`  | string | Message displayed in the subtitle of the pop-up that brings the illustration of the document that is being requested for capture.                                                                                                                                                                               |    ✅    |  ✅  |
| `wrongDocumentMessage`          | string | Message displayed when the document is displayed in a different stream than expected.                                                                                                                                                                                                                           |    ✅    |  ✅  |
| `unsupportedDocumentMessage`    | string | Message displayed when a unexpected type of document is displayed for capture                                                                                                                                                                                                                                   |    ✅    |  ✅  |
| `documentNotFoundMessage`       | string | Message displayed when a document is unknown                                                                                                                                                                                                                                                                    |    ✅    |  ❌  |
| `sensorLuminosityMessage`       | string | Message displayed when the brightness threshold is lower than expected                                                                                                                                                                                                                                          |    ✅    |  ✅  |
| `sensorOrientationMessage`      | string | Message displayed when the orientation threshold is lower than expected                                                                                                                                                                                                                                         |    ✅    |  ✅  |
| `sensorStabilityMessage`        | string | Message displayed when the orientation threshold is lower than expected                                                                                                                                                                                                                                         |    ✅    |  ✅  |
| `positiveButtonMessage`         | string | Allows for customization of the confirmation button message                                                                                                                                                                                                                                                     |    ✅    |  ❌  |
| `predictorScanDocumentMessage`  | string | Message displayed to request a document to be present on the camera.                                                                                                                                                                                                                                            |    ✅    |  ✅  |
| `predictorGetCloserMessage`     | string | Message displayed to request to get closer to the document.                                                                                                                                                                                                                                                     |    ✅    |  ✅  |
| `predictorCentralizeMessage`    | string | Message displayed to request to center the document.                                                                                                                                                                                                                                                            |    ✅    |  ✅  |
| `predictorMoveAwayMessage`      | string | Message displayed to request to move away from the document.                                                                                                                                                                                                                                                    |    ✅    |  ✅  |
| `predictorAlignDocumentMessage` | string | Message displayed to request to align the document.                                                                                                                                                                                                                                                             |    ✅    |  ✅  |
| `predictorTurnDocumentMessage`  | string | Message displayed to request to turn document 90 degrees.                                                                                                                                                                                                                                                       |    ✅    |  ✅  |
| `predictorCapturedMessage`      | string | Message displayed to alert that the document was captured.                                                                                                                                                                                                                                                      |    ✅    |  ✅  |

### `DocumentDetectorUploadSettings`

| Field         | Type                          | Description                                                  | Android | iOS |
| ------------- | ----------------------------- | ------------------------------------------------------------ | :-----: | :-: |
| `enable`      | boolean                       | Enables/disables this feature.                               |    ✅    |  ✅  |
| `compress`    | boolean                       | Enables/disables file compression before uploading.          |    ✅    |  ✅  |
| `fileFormats` | [FileFormat\[\]](#fileformat) | Defines the file format(s) that will be accepted for upload. |    ✅    |  ✅  |
| `maxFileSize` | number                        | Sets the maximum KB limit of the file to upload.             |    ✅    |  ✅  |

### `DocumentDetectorStyle`

| Field                    | Type                                              | Description                              | Android                                                                                        | iOS                                         |
| ------------------------ | ------------------------------------------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------- |
| `primaryColor`           | string                                            | Define the principal color of the SDK.   | [See example](/caf-sdk/react-native/standalone-modules/document-detector/customizing-style.md) | Use hexadecimal colors. Example: `#34d690`. |
| `feedbackColors`         | [DocumentFeedbackColors](#documentfeedbackcolors) | Colors of the feedback area.             | [See example](/caf-sdk/react-native/standalone-modules/document-detector/customizing-style.md) | Use hexadecimal colors. Example: `#34d690`. |
| `uploadBackgroundColor`  | string                                            | Background color for the upload flow.    | [See example](/caf-sdk/react-native/standalone-modules/document-detector/customizing-style.md) | Use hexadecimal colors. Example: `#34d690`. |
| `previewBackgroundColor` | string                                            | Background color for the preview screen. | [See example](/caf-sdk/react-native/standalone-modules/document-detector/customizing-style.md) | Use hexadecimal colors. Example: `#ffffff`. |

#### `DocumentFeedbackColors`

| Field          | Type   | Description                                                            |                                             Android                                            | iOS |
| -------------- | ------ | ---------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------: | :-: |
| `defaultColor` | string | Defines the default coolor for default feedback.                       | [See example](/caf-sdk/react-native/standalone-modules/document-detector/customizing-style.md) |  ✅  |
| `errorColor`   | string | defines the error color when there is an error capturing the document. | [See example](/caf-sdk/react-native/standalone-modules/document-detector/customizing-style.md) |  ✅  |
| `successColor` | string | Sets the success color when the document is captured.                  | [See example](/caf-sdk/react-native/standalone-modules/document-detector/customizing-style.md) |  ✅  |

### `DocumentDetectorSecuritySettings`

| Field                | Type    | Description                                   | Android | iOS |
| -------------------- | ------- | --------------------------------------------- | :-----: | :-: |
| `useDevelopmentMode` | boolean | Enable developer mode on the physical device. |    ✅    |  ❌  |
| `useAdb`             | boolean | Enable the Android Debug Bridge (ADB).        |    ✅    |  ❌  |
| `useDebug`           | boolean | Enable debug mode for Android.                |    ✅    |  ❌  |

## Enums

### `Document`

| Field        | Description                                                                                                                        | Android | iOS |
| ------------ | ---------------------------------------------------------------------------------------------------------------------------------- | :-----: | :-: |
| `RG_FRONT`   | Front of the RG, part where the photo is.                                                                                          |    ✅    |  ✅  |
| `RG_BACK`    | Back of the RG, where the data is.                                                                                                 |    ✅    |  ✅  |
| `RG_FULL`    | RG open, showing both the front and back.                                                                                          |    ✅    |  ✅  |
| `CNH_FRONT`  | Front of the CNH, part where the photo is.                                                                                         |    ✅    |  ✅  |
| `CNH_BACK`   | Back of the CNH, part where the signature is.                                                                                      |    ✅    |  ✅  |
| `CNH_FULL`   | CNH open, showing both the front and back.                                                                                         |    ✅    |  ✅  |
| `CRLV`       | CRLV.                                                                                                                              |    ✅    |  ✅  |
| `RNE_FRONT`  | Front of RNE and RNM, where are the data.                                                                                          |    ✅    |  ✅  |
| `RNE_BACK`   | Back of RNE and RNM, where is the photo.                                                                                           |    ✅    |  ✅  |
| `PASSPORT`   | Passport, one side only, showing all data.                                                                                         |    ✅    |  ✅  |
| `CTPS_FRONT` | Front of CTPS, where the photo is located.                                                                                         |    ✅    |  ✅  |
| `CTPS_BACK`  | Back of the CTPS, where it contains the data.                                                                                      |    ✅    |  ✅  |
| `OTHERS`     | Other identification documents in general, such as RNE, Military Identity, OAB and CRLV.                                           |    ✅    |  ✅  |
| `ANY`        | Allows the sending of any type of document, all those mentioned above, including any other document, as no typifications are made. |    ✅    |  ✅  |

### `CaptureMode`

| Field       | Description                       | Android | iOS |
| ----------- | --------------------------------- | :-----: | :-: |
| `AUTOMATIC` | Automatically scans the document. |    ✅    |  ❌  |
| `MANUAL`    | Scan the document manually.       |    ✅    |  ❌  |

### `Stage`

| Field  | Description             | Android | iOS |
| ------ | ----------------------- | :-----: | :-: |
| `BETA` | Beta environment.       |    ✅    |  ✅  |
| `PROD` | Production environment. |    ✅    |  ✅  |

### `Resolution`

| Field      | Description | Android | iOS |
| ---------- | ----------- | :-----: | :-: |
| `FULL_HD`  | 1920 x 1080 |    ✅    |  ✅  |
| `QUAD_HD`  | 2560 x 1440 |    ✅    |  ❌  |
| `ULTRA_HD` | 3840 x 2160 |    ✅    |  ✅  |

### `CountryCodes`

See the complete list at: [ISO 3166-1 alpha-3](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3).\
Example: `CountryCodes.BRA`.

### `FileFormat`

| Field  | Description | Android | iOS |
| ------ | ----------- | :-----: | :-: |
| `PNG`  | image/png   |    ✅    |  ✅  |
| `JPG`  | image/jpg   |    ✅    |  ❌  |
| `JPEG` | image/jpeg  |    ✅    |  ✅  |
| `PDF`  | image/pdf   |    ✅    |  ✅  |
| `HEIF` | image/heif  |    ✅    |  ❌  |

### `Error`

| Field                | Description                                                         | Android | iOS |
| -------------------- | ------------------------------------------------------------------- | :-----: | :-: |
| `PermissionReason`   | You are missing some mandatory permission to run the SDK.           |    ✅    |  ✅  |
| `NetworkReason`      | Indicates a network-related exception occurred during verification. |    ✅    |  ✅  |
| `ServerReason`       | Indicates a server-side exception occurred during verification.     |    ✅    |  ✅  |
| `InvalidTokenReason` | Indicates an issue with the token used for verification.            |    ✅    |  ✅  |
| `SecurityReason`     | When the SDK cannot be started due to a security reason.            |    ✅    |  ✅  |
| `StorageReason`      | When an SDK internal library cannot be started.                     |    ✅    |  ✅  |
| `LibraryReason`      | There is no space on the user device's internal storage.            |    ✅    |  ✅  |
| `UnexpectedReason`   | An unxpected error has occurred.                                    |    ✅    |  ✅  |


---

# 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/react-native/standalone-modules/document-detector/typescript-references.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.
