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

# Confirm a session result from your server

> Check a verification session's step statuses from your server after the SDK reports completion.

The SDK `onWorkflowComplete` callback runs in the user's browser, so confirm the outcome from your server before you act on it. The session token is the `session_token` your app passes to the SDK, which the callbacks also return.

Session state is read with an SDK token, not with the API key headers, so the server mints one first.

**1. Set your credentials**

Use `https://dev.idto.ai` (staging) while you build and `https://prod.idto.ai` (production) when you go live. Keep the client ID and API key on your server only. Never ship them to a browser or a mobile app.

```bash .env theme={null}
IDTO_BASE_URL=https://dev.idto.ai
IDTO_CLIENT_ID=your-client-id
IDTO_API_KEY=your-api-key
```

```bash theme={null}
set -a; source .env; set +a
```

**2. Mint an SDK token and read the state**

```python session_state.py theme={null}
import os
import sys

import requests

BASE_URL = os.environ.get("IDTO_BASE_URL", "https://dev.idto.ai")


def sdk_token():
    response = requests.post(
        f"{BASE_URL}/auth/sdk/token",
        json={"client_id": os.environ["IDTO_CLIENT_ID"], "client_secret": os.environ["IDTO_API_KEY"]},
        timeout=(5, 15),
    )
    response.raise_for_status()
    return response.json()["access_token"]


def session_state(session_token):
    response = requests.get(
        f"{BASE_URL}/sdk/v2/session/{session_token}/state",
        headers={"Authorization": f"Bearer {sdk_token()}"},
        timeout=(5, 15),
    )
    if response.status_code == 404:
        return None
    response.raise_for_status()
    return response.json()


if __name__ == "__main__":
    print(session_state(sys.argv[1]))
```

**3. Read the steps**

A known session returns `200` with a `steps` list. Each step has `step_index`, `module_slug`, `status`, `version` and `retry_count`. State carries step statuses only. Fetch the verification details through your normal result flow.

A session token that has no session returns `404`, and the function returns `None`:

```json 404 theme={null}
{"detail": "Session not found"}
```

## Good to know

* `401` means the SDK token is missing or expired. Mint a new one, it lasts 900 seconds.
* `403` means this SDK token may not read that session.

Was this page helpful? Email us at [tech@idto.ai](mailto:tech@idto.ai?subject=Docs%20feedback%3A%20Confirm%20a%20session%20result%20from%20your%20server) with the page link.


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