> ## 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.

# Authentication

> How to authenticate server-to-server calls with API key headers, and how to mint short-lived tokens for browser and mobile SDKs.

idto has two ways to authenticate, depending on where the call originates.

## Server-to-server: API key headers

Every call to `/verify/*` (v1) or `/v2/verify/*` (v2) is authenticated with a static header pair:

| Header | Value |
| - | - |
| `X-Client-ID` | The Client ID of your API key, listed on the dashboard's API Credentials page. Not your account or customer ID, which returns 401 |
| `X-API-Key` | Your secret API key |

Send both on every request. There's no separate login step for this method, the headers are the credential.

```bash theme={null}
curl --request POST \
  --url https://dev.idto.ai/v2/verify/pan_validation \
  --header "X-Client-ID: $IDTO_CLIENT_ID" \
  --header "X-API-Key: $IDTO_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"pan_number": "ABCDE1234F", "user_consent": true}'
```

Because these headers work in any request, this method is for calls your own backend makes. Never embed a client ID and API key in a mobile app or a web page, anyone who reads the app bundle or the network tab gets your permanent credential.

### Hosts

| Environment | Base URL | Notes |
| - | - | - |
| Production | `https://prod.idto.ai` | Keys from the dashboard after go-live. Billed. |
| Staging | `https://dev.idto.ai` | Keys on request from your idto account manager. Calls reach live sources, so use identities you are authorised to verify. Staging credits are deducted from your staging account. |

Staging and production keys are separate pairs. A staging `X-Client-ID` and `X-API-Key` won't authenticate against `prod.idto.ai`, and vice versa. See [Environments](https://idto.mintlify.site/environments.md).

## Browser and mobile SDKs: token exchange

The idto SDKs (web, Android, iOS, Flutter, React Native) run in an environment you don't control, a user's browser or device, so they can't hold your permanent `X-Client-ID` / `X-API-Key` pair. Instead, your backend exchanges that pair for a short-lived token and hands the token to the SDK.

**1. Your backend requests a token**

```bash theme={null}
curl --request POST \
  --url https://dev.idto.ai/auth/sdk/token \
  --header "Content-Type: application/json" \
  --data '{
    "client_id": "your_client_id",
    "client_secret": "your_api_key"
  }'
```

`client_id` and `client_secret` are the same values as your `X-Client-ID` and `X-API-Key`.

**2. idto returns a bearer token**

```json theme={null}
{
  "access_token": "eyJhbGciOiJIUzI1NiJ9.example.sdk-token",
  "token_type": "bearer",
  "expires_in": 900
}
```

The token is valid for 900 seconds (15 minutes). It is a short-lived, client-side credential: the SDK sends it as `Authorization: Bearer <token>` and it authenticates verification calls as your account until it expires. Your `client_secret` never leaves your server. Mint a token per user session, just before you start the SDK, and never log or persist it.

Errors: wrong credentials return `401` with `{"detail": "Invalid client credentials"}`, and an inactive client returns `401` with `{"detail": "Client is inactive"}`.

**3. Your backend passes the token to the SDK**

Hand `access_token` to the SDK at init time as its client token. If a user takes longer than 15 minutes, the web SDK calls its `getToken` option on a `401`, so point that at an endpoint on your backend that mints a fresh token the same way. Never move the exchange to the client.

> [!WARNING]
>
> `POST /auth/sdk/token` is meant to be called from your backend, not from the browser or app itself. If the client-side code called it directly, it would need your permanent `X-API-Key` to do so, which defeats the purpose of the exchange.

## Authentication errors

| HTTP | `detail` | Cause |
| - | - | - |
| 401 | `Authentication required. Provide either a valid JWT token, API key + client ID, or SDK token.` | Headers missing, or the key pair does not match |
| 403 | `Client is inactive` | The client has been deactivated |
| 403 | `Customer is inactive` | The account is deactivated |
| 404 | `Customer not found for this client` | The client is not linked to an active account |

These are returned before any verification runs and are never billed.

## Which method to use

| Where the call originates | Method |
| - | - |
| Your backend, calling `/verify/*` or `/v2/verify/*` directly | `X-Client-ID` + `X-API-Key` headers |
| Your backend, provisioning a session for a web or mobile SDK | `POST /auth/sdk/token`, then hand the returned token to the SDK |
| The SDK itself, running in a user's browser or app | The short-lived token from `/auth/sdk/token`, never your permanent key pair |

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


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