> ## Documentation Index
> Fetch the complete documentation index at: https://idto.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Android SDK

> Run the idto verification flow in a native Android app, from Kotlin or Java.

The Android SDK opens the idto verification flow in its own screen and reports each result to a typed listener. It is a Kotlin library that Java apps use as is: every listener method has a default, so you override only the callbacks you need.

![Mobile number verification screen with OTP entry](https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/img/sdk-mobile-otp.png)

The mobile number step, with the one-time code field.

## Requirements

| Item | Value |
| - | - |
| `minSdk` | 24 (Android 7.0) |
| `compileSdk` and `targetSdk` | 36 |
| JDK | 17 |
| Host language | Kotlin or Java |
| Device | A real device for document and selfie capture. Most emulators have no usable camera. |

You also need a `client_id` and `client_secret` (kept on your server), a `workflowTemplateId`, and a backend route that mints a client token. See [Authentication](https://idto.mintlify.site/authentication.md).

## Install

Add the JitPack repository in `settings.gradle.kts`:

```kotlin theme={null}
dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        maven { url = uri("https://jitpack.io") }
    }
}
```

Then add the dependency in `app/build.gradle.kts`:

```kotlin theme={null}
dependencies {
    implementation("com.github.idto-ai:idto-android:0.1.0")
}
```

Groovy:

```groovy theme={null}
dependencies {
    implementation 'com.github.idto-ai:idto-android:0.1.0'
}
```

## Permissions

The library declares `CAMERA` and `RECORD_AUDIO` in its own manifest, so they merge into your app, and `IDto.open` requests any missing runtime permission before the flow starts. You add no manifest entries and call no permission API. The camera is used for documents and selfies, the microphone only for a liveness step. If the user has permanently denied the camera, the SDK offers a one-time dialog that opens Settings.

## Quick start

**1. Mint a client token on your server**

Your server calls `POST /auth/sdk/token` with `client_id` and `client_secret` and returns only `access_token` to the app. Never ship the secret in the app. Recipes: [Node](https://idto.mintlify.site/recipes/sdk-token-node-express.md), [Java](https://idto.mintlify.site/recipes/sdk-token-java.md), [Python](https://idto.mintlify.site/recipes/sdk-token-python-fastapi.md).

**2. Open the flow (Kotlin)**

```kotlin theme={null}
import ai.idto.sdk.IDto
import ai.idto.sdk.IDtoConfig
import ai.idto.sdk.IDtoEnv
import ai.idto.sdk.IDtoErrorData
import ai.idto.sdk.IDtoEventListener
import ai.idto.sdk.IDtoStepCompleteData
import ai.idto.sdk.IDtoWorkflowCompleteData

val config = IDtoConfig.Builder(clientToken, "your-workflow-template-uuid")
    .businessName("Sample Traders")
    .env(IDtoEnv.PRODUCTION)
    .build()

IDto.open(this, config, object : IDtoEventListener {
    override fun onStepComplete(data: IDtoStepCompleteData) {
        Log.d("idto", "step ${data.step}")
    }
    override fun onWorkflowComplete(data: IDtoWorkflowCompleteData) {
        confirmOnServer(data.sessionToken)
    }
    override fun onError(data: IDtoErrorData) {
        Log.e("idto", "${data.step}: ${data.error}")
    }
    override fun onClose() {}
})
```

**3. Or open it from Java**

```java theme={null}
IDtoConfig config = new IDtoConfig.Builder(clientToken, "your-workflow-template-uuid")
        .businessName("Sample Traders")
        .build();

IDto.open(this, config, new IDtoEventListener() {
    @Override public void onWorkflowComplete(IDtoWorkflowCompleteData data) {
        confirmOnServer(data.getSessionToken());
    }
    @Override public void onError(IDtoErrorData data) {
        Log.e("idto", data.getError());
    }
});
```

**4. Confirm the result on your server**

Listener callbacks drive your UI only. Confirm the session from your server with the [session result recipe](https://idto.mintlify.site/recipes/confirm-session-result.md) or a signed [webhook](https://idto.mintlify.site/concepts/webhooks.md) before you grant access.

`IDto.open(context, config, listener, tokenProvider)` works from any `Context`. `IDto.close()` closes the flow and `IDto.isOpen()` tells you whether one is open. Only one flow runs at a time: a second `open` while one is active calls the new listener's `onError` with `step = "init"` and `error = "session_active"` and opens nothing.

![Selfie capture screen](https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/img/sdk-face-capture.png)

The selfie step. The flow picks the front camera.

## Token refresh

Pass an `IDtoTokenProvider` as the fourth argument to `IDto.open`. When the client token expires, the SDK calls `getToken(callback)`; answer with `callback.onToken(newToken)` or `callback.onError(throwable)`.

## Configuration

`IDtoConfig.Builder(clientToken, workflowTemplateId)` takes these optional setters.

| Setter | Type | Purpose |
| - | - | - |
| `sessionToken` | `String` | Resume an earlier session. |
| `startFresh` | `Boolean` | Start a new session even if one is in progress. |
| `merchantUserId` | `String` | Your own id for this user. |
| `phone` | `String` | Prefills the mobile number step. |
| `preVerified` | `Map<String, Boolean>` | Module slugs you already verified, which the flow skips. |
| `accumulatedData` | `JSONObject` | Data you already hold, passed into the session. |
| `referenceName` | `String` | Name every document name is matched against. |
| `nameMatchConfig` | `IDtoNameMatchConfig` | Threshold, decision mode (`ALL` or `ANY`), honorifics, aliases, compare pairs. |
| `faceMatchReferenceImage` | `String` | Reference photo for face match. |
| `faceMatchConfig` | `IDtoFaceMatchConfig` | Skip liveness, threshold, liveness failure policy. |
| `aadhaarConfig` | `IDtoAadhaarConfig` | DigiLocker failure limit, OKYC on or off. |
| `panConfig` | `IDtoPanConfig` | Skip the PAN context screen. |
| `businessName` | `String` | Your name in the flow header. |
| `logo` | `String` | URL of your logo. |
| `language` | `IDtoLanguage` | `EN` or `HI`. |
| `theme` | `IDtoTheme` | `LIGHT` or `DARK`. |
| `colors` | `IDtoColors` | Colour overrides. |
| `displayMode` | `IDtoDisplayMode` | `FULL_SCREEN` or `BOTTOM_SHEET`. |
| `bottomSheet` | `IDtoBottomSheet` | Sheet height limits. |
| `env` | `IDtoEnv` | `PRODUCTION` (default, `https://prod.idto.ai`) or `DEVELOPMENT` (staging, `https://dev.idto.ai`). |
| `baseUrl` | `String` | Overrides the API host. |
| `readyTimeoutMs` | `Long` | How long to wait for the flow to load. Default 30000. |
| `allowedHosts` | `List<String>` | Extra hostnames the flow may navigate to, for example when you set a custom `baseUrl`. |
| `debug` | `Boolean` | Sends the flow's console logs and blocked navigations to Logcat. Default `false`. |

## Callbacks

`IDtoEventListener` methods, all optional:

| Method | Payload fields |
| - | - |
| `onStepComplete(IDtoStepCompleteData)` | `step`, `result`, `accumulatedData`, `sessionToken`, `creditsDeducted`, `balanceRemaining` |
| `onWorkflowComplete(IDtoWorkflowCompleteData)` | `allSteps`, `accumulatedData`, `sessionToken` |
| `onError(IDtoErrorData)` | `step`, `error`, `sessionToken` |
| `onAbandon(IDtoAbandonData)` | `atStep`, `reason`, `sessionToken` |
| `onClose()` | none |

`onError` with `step = "init"` comes from the SDK itself: `session_active` (a flow is already open), `network_error` (the flow did not load within `readyTimeoutMs`) or `unknown_error` (the WebView stopped). Other `error` values are readable messages to log, not to match on.

## See it run

<video controls width="100%" src="https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/video/flow-face.mp4" poster="https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/video/flow-face.jpg" />

Was this page helpful? Email us at [tech@idto.ai](mailto:tech@idto.ai?subject=Docs%20feedback%3A%20Android%20SDK) with the page link.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.