# Run an ID session

Ask a new customer for a photo of their driver's license, ID card or passport and a selfie with a head-turn check, taken live on their phone, with checks on what each image is and whether it's usable, then hand the images to your identity provider. Or sign each photo in your own camera screen and read its hardware tier.

An ID session asks a person for the document kinds you accept (a driver's license, ID card or residence permit front and back, or a passport photo page), then a selfie with a short head turn. They take each photo live: in your app with the native SDK, or on our branded capture page from a link.

As they frame each shot the phone says what to fix ("Hold still", "Too much glare"). After each shot our server checks the photo again and offers a retake. When they send it, you get a webhook, a redirect back into your flow, and a signed result that says what each image is and whether it passed.

Checking that the document is genuine, reading it and matching the face to it stay with your identity provider. An ID session gets them clean, live images with proof of how they were taken.

**Before you begin:** set `PROVENANCE_API` as on [Sandbox and keys](https://provenanceauth.com/docs/get-started/sandbox.md). You need an `attest` key on an account with its own Attest key; in the sandbox, `prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x` is set up for you. Read [Request photos by link](https://provenanceauth.com/docs/attest/guides/capture-requests.md) for how links are sent.

## 1. Create the session

Send [`POST /v1/attest/capture_requests`](https://provenanceauth.com/docs/api/capture-requests.md#post-v1-attest-capture-requests) with `session_type: "id"` instead of an item list:

| Field | What it sets |
| --- | --- |
| `accepted_documents` | The kinds you accept: `passport`, `passport_card`, `driving_license`, `national_id_card`, `residence_permit`. Default: `passport`, `driving_license`, `national_id_card` and `residence_permit`. With one kind (a car rental's `["driving_license"]`) the person isn't asked which document they have; with several, they pick one of them |
| `redirect_url` | The page in your flow the person returns to when they finish |

**curl**

```bash
export PROVENANCE_KEY=prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x
curl -X POST $PROVENANCE_API/v1/attest/capture_requests \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "case_id": "ONB-48213",
    "session_type": "id",
    "accepted_documents": ["passport", "driving_license"],
    "redirect_url": "https://app.pellowmarsh.example/onboarding/done",
    "delivery": "self"
  }'
```

**Node**

```ts
import { Provenance } from "@provenanceauth/sdk";

const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: process.env.PROVENANCE_API });
const session = await prov.attest.captureRequests.create({
  caseId: "ONB-48213",
  sessionType: "id",
  acceptedDocuments: ["passport", "driving_license"],
  redirectUrl: "https://app.pellowmarsh.example/onboarding/done",
  delivery: "self",
});
console.log(session.id, session.captureUrl);
```

**Python**

```python
import os
from provenanceauth import Provenance

prov = Provenance(os.environ["PROVENANCE_KEY"], base_url=os.environ["PROVENANCE_API"])
session = prov.attest.capture_requests.create(
    case_id="ONB-48213",
    session_type="id",
    accepted_documents=["passport", "driving_license"],
    redirect_url="https://app.pellowmarsh.example/onboarding/done",
    delivery="self",
)
print(session["id"], session["capture_url"])
```

```json
{
  "id": "capr_01M6VQBD873JECJ1PKTECEGXNH",
  "object": "capture_request",
  "status": "pending",
  "case_id": "ONB-48213",
  "session_type": "id",
  "accepted_documents": ["passport", "driving_license"],
  "redirect_url": "https://app.pellowmarsh.example/onboarding/done",
  "items": [
    { "object": "capture_item", "index": 0, "type": "id_document", "label": "Your passport or driver’s license", "document_kind": null, "status": "waiting", "checks": [] },
    { "object": "capture_item", "index": 1, "type": "selfie", "label": "A selfie", "status": "waiting", "checks": [] }
  ],
  "result": null,
  "capture_url": "https://console.provenanceauth.com/capture/4WxUVWSppSynhTy7LDwew3hLatIIz3tzBLmG5jNq7aI"
}
```

The example is shortened. With `delivery: "self"` you show the link yourself (or open it in your app); send `contact` instead to have us text or email it with your branding.

## 2. Run it in your app or on the capture page

With the [capture release](https://provenanceauth.com/docs/attest/guides/capture-release.md) on, the person first sees "Before you continue" and chooses **I agree** before the camera opens. If your app draws its own screens, send `terms_accepted: true` on the call that starts each item, or the face and ID photos are refused.

**In your app** (the strongest proof: each photo is signed by the device, StrongBox or the TEE on Android, the Secure Enclave on iPhone once App Attest is on), take the token from `capture_url` and render the SDK's default screens:

```tsx
import { ProvenanceCaptureFlow } from "@provenanceauth/react-native";
import * as FileSystem from "expo-file-system";

<ProvenanceCaptureFlow
  token={captureToken}
  baseUrl={process.env.PROVENANCE_API!}
  readFileBase64={(uri) => FileSystem.readAsStringAsync(uri, { encoding: "base64" })}
  onComplete={({ requestId, redirectUrl }) => navigation.navigate("Onboarding", { requestId })}
/>
```

The screens use your branding (name, logo and colours, from Settings → Branding). To build your own screens, the same steps are separate SDK calls, listed in [the native SDK guide](https://provenanceauth.com/docs/attest/guides/native-sdk.md#5-run-a-guided-session).

**On the capture page**, the person opens the link on their phone. Every capture there is the `software` tier: a browser can't prove the camera hardware. The page takes live camera frames only.

Either way, the person:

1. picks their document from the kinds you accept, one row each (skipped when you accept one);
2. takes the card's front and back, or the passport's photo page, with a card guide on the viewfinder;
3. follows a two-step head turn ("Turn your head to your left", then right), then takes the selfie;
4. reviews every photo with what the checks found, retakes any, and taps **Send**.

## 3. Read the checks

The phone checks each photo first, for guidance while framing and a verdict before it's sent. Our server runs the decisive checks again on the uploaded image, and its answer is the one you receive:

| Check | What it looks at | Its limits |
| --- | --- | --- |
| Attestation | The tier the server assigned and how the photo is bound: a device signature from your app, or a single-use shutter nonce on the capture page | A browser capture is always `software` |
| What it is | The step it was taken in, moved by evidence: a selfie-sized face, a small ID portrait, no face where one was expected; on iPhone also a passport's machine-readable zone, an ID barcode and the card's shape. Says how sure it is (`high`, `medium`, `low`) and why | It doesn't read or authenticate the document |
| Usable or retake | Sharpness, exposure, contrast, resolution, and on documents glare and how much of the frame the content fills | Fixed thresholds on image statistics, not a model; framing is a rough measure |
| Face present | One clear face, big enough, eyes visible | Needs the face detector on the server; without it the check reports `not_run` |
| Head turn (basic) | The frames the person took while turning: timing on our clock, that the frames change, and with the face detector that one face turns the asked way | It catches a still photo or a frozen replay. A mask or a replayed video of a head turn needs a stronger check, such as your identity provider's |
| Screening | Synthetic-media screening, when it is set up and within budget | Advisory; it never changes the risk score |
| Document type | On each ID shot, what kind of document it is (`passport`, `driving_license`, `national_id_card`, ...), the country when read, a confidence, and whether it's one of your `accepted_documents`. See [document type](https://provenanceauth.com/docs/attest/guides/capture-requests.md#document-type) | Not an authenticity check. Pro and up, and only where the classifier is set up |

A check that couldn't run says `not_run` with the reason, never a pass. The session's `result.checks` is `checks_passed` only when every decisive check passed; otherwise `needs_review`, with the reasons. On a server without the face detector, an ID session always reads `needs_review` (`face_check_not_run`, `liveness_limited`).

No face template is ever made or stored. The head-turn frames are checked and dropped; the request keeps the outcome only.

## 4. Get the result back

When the person sends the session, you get `attest.capture_request.completed` with the result summary, and the capture page returns them to your `redirect_url` with `capture_request_id` and `status` appended. Fetch the signed result with [`GET /v1/attest/capture_requests/{id}/result`](https://provenanceauth.com/docs/api/capture-requests.md#get-v1-attest-capture-requests-id-result):

**curl**

```bash norun
curl $PROVENANCE_API/v1/attest/capture_requests/capr_01M6VQBD873JECJ1PKTECEGXNH/result \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const result = await prov.attest.captureRequests.result("capr_01M6VQBD873JECJ1PKTECEGXNH");
console.log(result.checks, result.images.map((i) => [i.checks?.kind, i.sha256]));
```

**Python**

```python
result = prov.attest.capture_requests.result("capr_01M6VQBD873JECJ1PKTECEGXNH")
print(result["checks"], [(i["checks"]["kind"], i["sha256"]) for i in result["images"]])
```

```json
{
  "object": "capture_result",
  "capture_request_id": "capr_01M6VQBD873JECJ1PKTECEGXNH",
  "session_type": "id",
  "status": "completed",
  "checks": "checks_passed",
  "reasons": [],
  "images": [
    {
      "attestation_id": "att_3F3MNRWF2A9XF9PZ9A3G79Z3BV",
      "item_type": "id_document",
      "side": "front",
      "document_kind": "driving_license",
      "sha256": "3b1f8c0e5a6d47e29f0c1b2a3d4e5f60718293a4b5c6d7e8f9a0b1c2d3e4f506",
      "tier": "strongbox",
      "checks": {
        "kind": { "status": "done", "value": "id_card_front", "matches_request": true, "confidence": "medium", "basis": ["requested_step", "face_size"] },
        "quality": { "status": "usable", "reasons": [] }
      }
    }
  ],
  "token": "eyJhbGciOiJFUzI1NiIsInR5cCI6InByb3ZlbmFuY2UtY2FwdHVyZS1yZXN1bHQrand0Iiwia2lkIjoiOWYyYjFjNGQ2ZThhMGIyYyJ9…",
  "jwks_url": "https://api.provenanceauth.com/.well-known/jwks.json"
}
```

The example is shortened. `token` is an ES256 JWS (`typ: provenance-capture-result+jwt`) over the same claims; verify it against the JWKS before you pass the images on. Then fetch the images with [`GET /v1/attest/capture_requests/{id}/files`](https://provenanceauth.com/docs/api/capture-requests.md#get-v1-attest-capture-requests-id-files): each link works without a key for 15 minutes (`expires_in` up to an hour). Send the images and the token to your identity provider together.

## 5. Keep images only as long as you need them

Images are encrypted at rest and kept for your retention window: 30 days unless you change it in the console (Attest → Capture requests) or with [`PUT /v1/attest/settings/capture_retention`](https://provenanceauth.com/docs/api/account.md#put-v1-attest-settings-capture-retention) (1 to 365 days; a change applies to the images you already hold). Delete a session's images sooner with [`DELETE /v1/attest/capture_requests/{id}/media`](https://provenanceauth.com/docs/api/capture-requests.md#delete-v1-attest-capture-requests-id-media). The attestations, their hashes and the checks stay on the case after the images go, and the result records when they went.

## Sign the photos in your own camera screen

When your app draws its own onboarding screens, skip the session and sign each photo with `<ProvenanceCamera>` from the [native capture SDK](https://provenanceauth.com/docs/attest/guides/native-sdk.md). Provenance proves the capture: which enrolled device took the photo, when, and that the bytes are untouched. Your identity provider still runs the document and face checks, on the same image.

### Enroll the phone

Enrollment sends the device's attestation evidence to the server, which assigns the [hardware tier](https://provenanceauth.com/docs/attest/concepts/device-registry.md#key-fields). Do it once per install, before the first capture.

```ts
import { enrollDevice } from "@provenanceauth/react-native";

const { deviceId, tier } = await enrollDevice({
  baseUrl: process.env.PROVENANCE_API!,
  apiKey: process.env.PROVENANCE_KEY!,
});
```

The app never reports its own tier. A device that can't prove hardware backing enrolls as `software`.

### Capture the selfie and the ID front

Render `<ProvenanceCamera>` twice: once with `facing="front"` for the selfie, then with the default back lens for the ID. Use your onboarding case id as `claimId` so both photos land on one case.

```tsx
import { ProvenanceCamera } from "@provenanceauth/react-native";

// Step 1: the selfie, front lens.
<ProvenanceCamera
  claimId="ONB-48213"
  facing="front"
  biometricPrompt
  onAttest={(r) => upload("selfie", r.bundleJson, r.fileUri)}
  onError={(e) => showRetry(e.code)}
/>

// Step 2: the ID front, back lens (the default).
<ProvenanceCamera
  claimId="ONB-48213"
  onAttest={(r) => upload("id_front", r.bundleJson, r.fileUri)}
/>
```

The lens is the only difference. Both photos are hashed, signed in the phone's secure hardware, and returned as the same signed bundle. The tier the server assigns depends on the platform; see the table under [Read the hardware tier](#read-the-hardware-tier). Your JavaScript receives a file URI and the bundle, never the pixels. An unknown `facing` value fails with `invalid_facing` before the camera opens.

> **Note: Keep the original bytes**
>
> Upload the file at `fileUri` unchanged. Cropping, compressing or re-encoding it changes the hash, and the asset then scores `sensor_hash_mismatch`.

### Attest both photos

Your backend sends each signed bundle with its image to [`POST /v1/attest/attestations`](https://provenanceauth.com/docs/api/claims.md#post-v1-attest-attestations). Set `case_type` to `presence` so explanations use the word "verification" instead of "claim". Save the request body your app uploaded as `selfie.json`, then send it.

**curl**

```bash norun
curl $PROVENANCE_API/v1/attest/attestations \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d @selfie.json
```

**Node**

```ts
import { Provenance } from "@provenanceauth/sdk";

const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: process.env.PROVENANCE_API });
const selfie = await prov.attest.attestations.create({ bundle: JSON.parse(bundleJson), imageBase64, caseType: "presence" });
console.log(selfie.status, selfie.riskScore);
```

**Python**

```python
import json, os
from provenanceauth import Provenance

prov = Provenance(os.environ["PROVENANCE_KEY"], base_url=os.environ["PROVENANCE_API"])
selfie = prov.attest.attestations.create(bundle=json.loads(bundle_json), image_base64=image_base64, case_type="presence")
print(selfie["status"], selfie["risk_score"])
```

```json
{
  "id": "8c4e17a2-5b1d-4f0e-9a63-2d7c1e0b4f19",
  "object": "attestation",
  "risk_score": 0,
  "status": "verified"
}
```

Repeat for the ID front. The response `id` is the attestation id you keep with the onboarding record.

### Verify the case

Read both assets at once with [`GET /v1/attest/claims/{id}/provenance`](https://provenanceauth.com/docs/api/claims.md#get-v1-attest-claims-id-provenance). Each asset carries its device, certificate check, capture chain and risk factors.

**curl**

```bash norun
curl $PROVENANCE_API/v1/attest/claims/ONB-48213/provenance \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const record = await prov.attest.claims.getProvenance("ONB-48213");
console.log(record.overallStatus, record.assets.map((a) => a.status));
```

**Python**

```python
record = prov.attest.claims.get_provenance("ONB-48213")
print(record["overall_status"], [a["status"] for a in record["assets"]])
```

```json
{
  "id": "ONB-48213",
  "object": "claim",
  "assets": [
    {
      "id": "8c4e17a2-5b1d-4f0e-9a63-2d7c1e0b4f19",
      "object": "verification_result",
      "claim_id": "ONB-48213",
      "status": "verified",
      "risk_score": 0,
      "risk_factors": [],
      "device_info": {
        "device_id": "5f0d2c1a-7e44-4b8b-a1f2-9c3e6d7a8b01",
        "enrolled": true,
        "cert_valid": true,
        "cert_expires": "2028-10-23T16:49:34.000Z"
      },
      "capture_type": "image",
      "sensor_hash": "96354a9303b1e5737ea85acbba0022b2dedd17da20e1991b00176c1a6a6c8875"
    },
    {
      "id": "1b9d03f6-2a7e-4c55-8f10-6e2b9d4c7a33",
      "object": "verification_result",
      "claim_id": "ONB-48213",
      "status": "partial",
      "risk_score": 50,
      "risk_factors": [
        { "factor": "sensor_hash_mismatch", "points": 50, "description": "Image bytes hash does not match bundle sensor_hash" }
      ],
      "capture_type": "image"
    }
  ],
  "overall_status": "partial",
  "overall_risk_score": 50
}
```

The example is shortened. Here the selfie is untouched, and the ID front was edited after capture: its hash stops matching the signed bundle, so it scores `sensor_hash_mismatch` and the case lands in `partial` for review. The case score is the highest asset score.

| Status | Score | What to do |
| --- | --- | --- |
| `verified` | 0–30 | Pass the images to your identity provider. |
| `partial` | 31–80 | Send the case to manual review, or ask for a new capture. |
| `failed` | 81–100 | Reject the capture and ask the customer to take it again. |

See [risk scoring](https://provenanceauth.com/docs/attest/concepts/risk-scoring.md) for every factor.

### Read the hardware tier

The tier lives on the device record. List your enrolled devices with [`GET /v1/attest/devices`](https://provenanceauth.com/docs/api/devices.md#get-v1-attest-devices) (your Attest key) and find the `device_id` from the asset.

**curl**

```bash norun
curl "$PROVENANCE_API/v1/attest/devices?limit=20" \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const devices = await prov.attest.devices.list({ limit: 20 });
console.log(devices.data.map((d) => [d.id, d.hardwareTier]));
```

**Python**

```python
devices = prov.attest.devices.list(limit=20)
print([(d["id"], d["hardware_tier"]) for d in devices["data"]])
```

```json
{
  "object": "list",
  "data": [
    {
      "id": "5f0d2c1a-7e44-4b8b-a1f2-9c3e6d7a8b01",
      "object": "device",
      "hardware_tier": "strongbox",
      "enrolled_at": "2026-10-24T16:49:34.956Z",
      "revoked_at": null
    }
  ],
  "has_more": false,
  "next_cursor": null
}
```

| Tier | Where the key lives |
| --- | --- |
| `sep` | An iPhone proven by App Attest, when the server verifies it. Otherwise an iPhone reports `software` |
| `strongbox` | A dedicated secure chip on Android |
| `tee` | The Android trusted execution environment |
| `software` | No hardware backing; captures score `hardware_backing_absent` |

Sandbox devices report `simulated`. If a phone is lost or compromised, revoke it with [`POST /v1/attest/devices/{id}/revoke`](https://provenanceauth.com/docs/api/devices.md#post-v1-attest-devices-id-revoke); its later captures score `device_revoked`.

### Export the evidence

**Availability:** Enterprise plan.

For an audit or a dispute, export the case with [`POST /v1/attest/claims/{id}/export`](https://provenanceauth.com/docs/api/exports.md#post-v1-attest-claims-id-export). The bundle holds each signed attestation, its verification and a manifest hash, plus a verifier script that runs offline. When the deployment has a timestamp authority, the manifest hash also gets an RFC 3161 timestamp.

**curl**

```bash norun
curl -X POST $PROVENANCE_API/v1/attest/claims/ONB-48213/export \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const exp = await prov.attest.claims.export("ONB-48213");
console.log(exp.manifestHash, exp.downloadUrl);
```

**Python**

```python
exp = prov.attest.claims.export("ONB-48213")
print(exp["manifest_hash"], exp["download_url"])
```

```json
{
  "id": "exp_01M5QD2NNCYXTSE0ZNG4GP4B5P",
  "object": "export",
  "claim_id": "ONB-48213",
  "status": "ready",
  "manifest_hash": "f1faf70cbf7fb440a3ec2188b9ccc96713a391157bc6e6f2a64acc8b68452630",
  "timestamp": { "status": "not_configured" },
  "file_count": 9,
  "download_url": "/v1/exports/exp_01M5QD2NNCYXTSE0ZNG4GP4B5P/download",
  "expires_at": "2026-10-25T16:49:35.404Z"
}
```

The export holds content hashes, never the photos themselves, so the images stay in your systems. See [chain of custody](https://provenanceauth.com/docs/attest/concepts/chain-of-custody.md) for the bundle's layout.

## Limitations

- A completed session counts as one verified capture, whatever it holds; abandoned and expired sessions and retakes are free.
- The head turn is a basic check. It catches a still photo or a frozen replay; stronger presentation-attack detection stays with your identity provider.
- On Android the SDK's face detector finds faces but not their turn, so the head-turn direction is checked on the server.

## Errors you might see

| Symptom | Cause | Fix |
| --- | --- | --- |
| `409` [`capture_document_required`](https://provenanceauth.com/docs/platform/errors.md#capture_document_required) | A photo of the ID before the person picked a document, in a session that accepts several kinds | Call the document step first (the SDK and the page do). |
| `409` [`capture_liveness_invalid`](https://provenanceauth.com/docs/platform/errors.md#capture_liveness_invalid) | The head-turn challenge expired (2 minutes), was used, or belongs to another item | Start a new challenge and send the selfie with its frames. |
| `409` [`capture_session_incomplete`](https://provenanceauth.com/docs/platform/errors.md#capture_session_incomplete) | Sent before every step had its photo | Take the steps in `details.items`, then send again. |
| `409` [`capture_result_not_ready`](https://provenanceauth.com/docs/platform/errors.md#capture_result_not_ready) | The result was fetched before the person sent the session | Wait for `attest.capture_request.completed`. |
| `409` [`capture_session_needs_link`](https://provenanceauth.com/docs/platform/errors.md#capture_session_needs_link) | A guided session opened in `<provenance-capture>` | Use the capture link or your app. |
| `invalid_facing` | `facing` is a value other than `back` or `front` in your own camera screen | Pass `"front"` for the selfie, or omit it for the back lens. |
| [`sensor_hash_mismatch`](https://provenanceauth.com/docs/attest/concepts/risk-scoring.md) | The uploaded image differs from the signed bytes | Upload the file at `fileUri` unchanged. |
| [`hardware_backing_absent`](https://provenanceauth.com/docs/attest/concepts/risk-scoring.md) | The device enrolled as `software`, such as an emulator | Capture on a physical phone with a secure element. |
| [`device_revoked`](https://provenanceauth.com/docs/attest/concepts/risk-scoring.md) | The capturing device was revoked | Enroll the customer's new device and capture again. |
| [`plan_required`](https://provenanceauth.com/docs/platform/errors.md#plan_required) | Evidence export needs the Enterprise plan | Upgrade the account, or keep the attestation ids and verify on demand. |

## See also

- [Claim capture sessions](https://provenanceauth.com/docs/attest/guides/claim-capture-sessions.md)
- [Request photos by link](https://provenanceauth.com/docs/attest/guides/capture-requests.md)
- [Capture on a phone](https://provenanceauth.com/docs/attest/guides/native-sdk.md)
- [Device registry](https://provenanceauth.com/docs/attest/concepts/device-registry.md)
- [Chain of custody](https://provenanceauth.com/docs/attest/concepts/chain-of-custody.md)
- [Webhooks](https://provenanceauth.com/docs/integrate/webhooks.md)
