> For the complete documentation index, see [llms.txt](https://legacy-docs.usesmileid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://legacy-docs.usesmileid.com/integration-options/mobile/products/document-verification.md).

# Document Verification

Document Verification is exposed as a flow which performs the following high level steps:

1. Displays instructions to the user
2. Requests camera permissions (if not already granted)
3. Performs Document Capture
4. Performs Selfie Capture
   1. useStrictMode defaults to false and will use Smile Smartselfie™ capture screens for selfie
   2. If useStrictMode is set to true, the selfie capture uses Enhanced SmartSelfie™ capture
5. Submits the job to the Smile ID API
6. Delivers the result back to the caller

{% tabs %}
{% tab title="Jetpack Compose (Android)" %}

```kotlin
import android.util.Log
import androidx.compose.runtime.Composable
import com.smileidentity.SmileID
import com.smileidentity.compose.SmartSelfieRegistration
import com.smileidentity.results.SmartSelfieResult

@Composable
fun DocumentVerificationExample() {
    // It will need to be provided as input depending on your use case
    SmileID.DocumentVerification(
        countryCode = "GH",
        useStrictMode = true, // true if you want to capture using enhanced SmartSelfie™ capture
    ) { result ->
        when (result) {
            is SmileIDResult.Success -> {
                val resultData = result.data
                Log.d("DocumentVerification", "Success: $resultData")
                // DocumentVerificationResult contains: captured documents, captured selfie,
                // and job status response from the API
                val (selfieFile, documentFrontFile, documentBackFile, jobStatusResponse) = resultData
            }

            is SmileIDResult.Error -> {
                // There was an error (could be denied camera permissions, network errors, etc)
                val throwable = result.throwable
                Log.w("DocumentVerification", "Failure: $it", throwable)
            }
        }
    }
}
```

{% endtab %}

{% tab title="Fragment (Android)" %}

```kotlin
DocumentVerificationFragment documentVerificationFragment = DocumentVerificationFragment
    .newInstance("GH");
getSupportFragmentManager().setFragmentResultListener(
    DocumentVerificationFragment.KEY_REQUEST,
    this,
    (requestKey, result) -> {
        SmileIDResult<DocumentVerificationResult> documentVerificationResult =
            DocumentVerificationFragment.resultFromBundle(result);
        Timber.v("DocumentVerification Result: %s", documentVerificationResult);
        getSupportFragmentManager()
            .beginTransaction()
            .remove(documentVerificationFragment)
            .commit();
        hideProductFragment();
    }
);
```

When using the Fragment approach, a convenience `resultFromBundle` static method is provided to help extract a typed object from the result Bundle.
{% endtab %}

{% tab title="Swift UI (iOS)" %}

```swift
import SwiftUI
import SmileID

struct HomeView: View, DocumentVerificationResultDelegate {
    @State private var presentDocumentVerification = false
    
    var body: some View {
        HStack(spacing: 15) {
            Button(action: {
                self.presentDocumentVerification.toggle()
            }) {
                Text("Document Verification")
            }
            .sheet(isPresented: $presentDocumentVerification, content: {
                SmileID.documentVerificationScreen(
                    countryCode: "GH",
                    useStrictMode: true, // true if you want to capture using enhanced SmartSelfie™ capture
                    delegate: self
                )
            })
        }
    }

    func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitDocumentVerificationJob: Bool) {
        print("Successfully submitted Document Verification job")
    }

    func didError(error: Error) {
        print("An error occurred - \(error.localizedDescription)")
    }
}
```

{% endtab %}

{% tab title="UIKit (iOS)" %}

```swift
let documentVerificationScreen = SmileID.documentVerificationScreen(...)
let controller = UIHostingController(rootView: documentVerificationScreen)
controller.modalPresentationStyle = .fullScreen
navigationController?.present(controller, animated: true)
```

{% endtab %}

{% tab title="Flutter" %}

```dart
Navigator.of(context).push( //Requires Navigator.of(context).push in order to load
    MaterialPageRoute<void>(
        builder: (BuildContext context) => Scaffold(
            appBar: AppBar(title: const Text("SmileID Document Verification")),
            body: SmileIDDocumentVerification(
                countryCode: "GH",
                useStrictMode: true, // true if you want to capture using enhanced SmartSelfie™ capture
                // There are more parameters -- they correspond 1:1 with the native SDK parameters
                onSuccess: (String? result) {
                    // Your success handling logic
                    final snackBar = SnackBar(content: Text("Success: $result"));
                    ScaffoldMessenger.of(context).showSnackBar(snackBar);
                    Navigator.of(context).pop(); //Return flow to your app
                },
                onError: (String errorMessage) {
                    // Your error handling logic
                    final snackBar = SnackBar(content: Text("Error: $errorMessage"));
                    ScaffoldMessenger.of(context).showSnackBar(snackBar);
                    Navigator.of(context).pop(); //Return flow to your app
                }
            ),
        ),
    ),
);
```

On success, you will receive a JSON string following the structure:

```json
{
  "selfieFile": "<path to selfie file>",
  "livenessFiles": [
    "<path to liveness file>",
        ...
    "<path to liveness file>",
  ],
  "documentFrontFile": "<path to document front file>",
  "documentBackFile": null | "<path to document back file>",
  "didSubmitDocumentVerificationJob": true | false
}
```

{% endtab %}

{% tab title="React Native" %}
{% hint style="info" %}
:warning: **Note:** Recommend wrapping this in a component that can be navigated to and out of view due to a known issue with views displaying dialogs particularly on failure and the dialog keeps showing,
{% endhint %}

```typescript
<SmileIDDocumentVerificationView
  allowAgentMode={false}
  forceAgentMode={false}
  showInstructions={true}
  countryCode="NG"
  documentType="PASSPORT"
  captureBothSides={true}
  allowGalleryUpload={false}
  style={{ width: '100%', height: '100%' }}
  onResult={(event) => {
    setResult(event.nativeEvent.result);
  }}
/>
```

On onResult, you will receive a JSON string following the structure:

```json
{
  "selfieFile": "<path to selfie file>",
  "livenessFiles": [
    "<path to liveness file>",
        ...
    "<path to liveness file>",
  ],
  "documentFrontFile": "<path to document front file>",
  "documentBackFile": null | "<path to document back file>",
  "didSubmitDocumentVerificationJob": true | false
}
}
```

{% endtab %}

{% tab title="React Native Expo" %}
{% hint style="info" %}
:warning: **Note:** Recommend wrapping this in a component that can be navigated to and out of view due to a known issue with views displaying dialogs particularly on failure and the dialog keeps showing,
{% endhint %}

Begin by defining a document verification parameters object:

```typescript
import { DocumentVerificationParams } from 'react-native-expo';


const documentVerificationParams: DocumentVerificationParams = {
  // userId: 'user123', // Optional user ID
  // jobId: 'job456', // Optional job ID
  countryCode: 'NG',
  allowNewEnroll: false,
  documentType: 'PASSPORT',
  // idAspectRatio: 1.0, // Optional aspect ratio for document capture
  // bypassSelfieCaptureWithFile: '', // Optional file path to bypass selfie capture
  autoCaptureTimeout: 10, // this is in seconds,
  autoCapture: AutoCapture.AutoCapture,
  captureBothSides: false,
  allowAgentMode: true,
  showInstructions: true,
  showAttribution: true,
  allowGalleryUpload: true,
  skipApiSubmission: false,
  useStrictMode: false,
  extraPartnerParams: {
    'custom_param_1': 'value1',
    'custom_param_2': 'value2'
    }
};
```

Integrate the document verification component into your view by rendering the `SmileIDDocumentVerificationView` and passing in the configured parameters:

```tsx
<SmileIDDocumentVerificationView
    style={styles.nativeView}
    params={documentVerificationParams}
    onResult={handleSuccessResult}
    onError={handleError}
/>
```

On onResult, you will receive a JSON string following the structure:

```json
{
  "selfieFile": "<path to selfie file>",
  "livenessFiles": [
    "<path to liveness file>",
        ...
    "<path to liveness file>",
  ],
  "documentFrontFile": "<path to document front file>",
  "documentBackFile": null | "<path to document back file>",
  "didSubmitDocumentVerificationJob": true | false
}
```

{% endtab %}
{% endtabs %}

### Arguments

#### `countryCode`

A 2-letter country code (ISO 3166-1 alpha-2 compliant)

#### `documentType`

The type of document/ID that is to be captured. If omitted, the document type will be automatically determined

#### `captureBothSides`

Boolean indicating whether both sides of the ID card should be captured. When set to true, the user will still be presented with the option to skip capturing the back of the ID card. This value can be fetched by calling `SmileID.api.getValidDocuments()` and checking the `hasBack` property of a document

#### `bypassSelfieCaptureWithFile`

If this value is provided, then the user will not be asked to capture a selfie as part of this flow

#### `userId`

The user ID to associate with the job. Most often, this will correspond to a unique User ID within your own system. (If not provided at time of Registration, a random user ID will be generated. This field is required for Authentication)

#### `jobId`

The job ID to associate with the job. Most often, this will correspond to a unique Job ID within your own system. If not provided, a random job ID will be generated.

#### `idAspectRatio`

The aspect ratio of the ID to be captured. If not specified, the aspect ratio will attempt to be inferred from the device's camera.

#### `showAttribution`

Whether to show the Smile ID attribution or not on the Instructions screen

#### `forceAgentMode`

Whether to force Agent Mode. If forced, the back camera will always be used without showing a toggle switch to the user. Takes precedence over `allowAgentMode`.

#### `autoCaptureTimeout`

The timeout before showing the manual capture button when auto-capture has not yet succeeded. Defaults to 10 seconds.

#### `autoCapture`

This is an `enum` that determines how autocapture is used. It takes the values: `autoCapture`, `autoCaptureOnly`, `manualCaptureOnly`. The default is `autoCapture`

{% hint style="warning" %}
:warning: Do not change the default as this might affect your passrates. Learn more on the reason for using this flag here: [document autocapture details](https://github.com/smileidentity/docs/blob/main/further-reading/faqs/document-autocapture/README.md).
{% endhint %}

#### Enum Options

1. `autoCapture` (default)

Uses automatic document capture, with a fallback to a manual capture button after 10 seconds if auto-capture is unsuccessful.

Recommended: Best for maintaining high pass rates and optimal user experience.

2. `autoCaptureOnly` ⚠️

Only automatic document capture is allowed. There is no manual fallback.

Warning: Enabling this may reduce your pass rates if auto-capture fails, since users will not be able to capture documents manually.

3. `manualCaptureOnly` ⚠️

Only manual capture is permitted. No automatic capture is used.

Warning: Disabling auto-capture may negatively impact your pass rates and user experience, as manual capture relies entirely on user input.

#### `allowGalleryUpload`

Whether the user should be allowed to upload their document photos from the Gallery instead of performing a live capture

#### `showInstructions`

Whether to deactivate capture screen's instructions

#### `extraPartnerParams`

Custom values specific to partners passed as an immutable map

#### `colorScheme`

See [Customization](/integration-options/mobile/theming.md#theming)

#### `typography`

See [Customization](/integration-options/mobile/theming.md#theming)

#### `onResult` (Android)

Callback to be invoked when the job is complete. The result itself is a `SmileIDResult` which can either be a `SmileIDResult.Success` or `SmileIDResult.Error`

#### `delegate` (iOS)

This is the delegate object notified when there is a result from the DocumentVerification flow. This class has to conform to `DocumentVerificationResultDelegate` and implement the delegate methods\
`func didSucceed(selfie: URL, documentFrontImage: URL, documentBackImage: URL?, didSubmitDocumentVerificationJob: Bool)` and `func didError(error: Error)`.


---

# 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://legacy-docs.usesmileid.com/integration-options/mobile/products/document-verification.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.
