# Capture sessions

Live video capture with a hash chain seeded by the server.

Related guide: [Video attestation](https://provenanceauth.com/docs/attest/concepts/video-attestation.md)

## Endpoints

- `POST /v1/attest/capture_sessions`: [Open a capture session](#post-v1-attest-capture-sessions)
- `POST /v1/attest/capture_sessions/{id}/chunks`: [Add a chunk hash](#post-v1-attest-capture-sessions-id-chunks)
- `POST /v1/attest/capture_sessions/{id}/finalize`: [Finalize a capture session](#post-v1-attest-capture-sessions-id-finalize)

## The capture session object

### Attributes

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | yes | Unique identifier for the object. |
| `object` | enum | yes | The type of object. One of `capture_session`. |
| `status` | string | yes | The object's current status. |
| `session_nonce` | string | yes | The server's nonce that seeds the chunk hash chain. |
| `expires_at` | string | yes | When it expires. |

### Example

```json
{
  "id": "cses_5F7EZSMK638H49GYJHXEPPRHPX",
  "object": "capture_session",
  "status": "open",
  "session_nonce": "ba1f8c8ba8c45d6ef7c20d57fbad00b6cf27d6c31f33c680aa0915698385ba79",
  "expires_at": "2026-11-07T19:31:47.030Z"
}
```

## Open a capture session

`POST /v1/attest/capture_sessions`

Opens a live video capture session. The server's session_nonce seeds the chunk hash chain, so a recording made earlier can't pass as live.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Retry a create safely: the same key + request returns the stored response (24 h, per caller). |
| `device_id` | body | string | yes | The capture or approving device's ID. |
| `claim_id` | body | string | yes | The claim, or case in another vertical, the asset belongs to. |
| `chunk_duration_ms` | body | integer | yes | Each chunk's length, in milliseconds. |

### Returns

The session, with its ID and nonce. See [the capture session object](#object).

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`parameter_missing`](https://provenanceauth.com/docs/platform/errors.md#parameter_missing)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_full_K7mN3xQp9RbT2vWm8sYd4cFjLhXn6gAe
curl -X POST "$PROVENANCE_API/v1/attest/capture_sessions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "device_id": "dev_00000000000000000000000000000001",
    "claim_id": "CLM-DOCS-VIDEO",
    "chunk_duration_ms": 2000
  }'
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/capture_sessions`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "device_id": "dev_00000000000000000000000000000001",
    "claim_id": "CLM-DOCS-VIDEO",
    "chunk_duration_ms": 2000
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/attest/capture_sessions", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}, json={
    "device_id": "dev_00000000000000000000000000000001",
    "claim_id": "CLM-DOCS-VIDEO",
    "chunk_duration_ms": 2000
}).json()
```

### Response 200

```json
{
  "id": "cses_5F7EZSMK638H49GYJHXEPPRHPX",
  "object": "capture_session",
  "status": "open",
  "session_nonce": "ba1f8c8ba8c45d6ef7c20d57fbad00b6cf27d6c31f33c680aa0915698385ba79",
  "expires_at": "2026-11-07T19:31:47.030Z"
}
```

## Add a chunk hash

`POST /v1/attest/capture_sessions/{id}/chunks`

Adds one chunk's hash to a live session, in order. The server records when each chunk arrived, for the timing checks at finalize.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Retry a create safely: the same key + request returns the stored response (24 h, per caller). |
| `id` | path | string | yes | The session's ID. |
| `index` | body | integer | yes | The position, from 0. |
| `chunk_hash` | body | string | yes | The chunk's chained hash. |
| `captured_at` | body | string | yes | When the device captured the chunk. |

### Returns

The session with the chunk added.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`chunk_index_conflict`](https://provenanceauth.com/docs/platform/errors.md#chunk_index_conflict)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`parameter_missing`](https://provenanceauth.com/docs/platform/errors.md#parameter_missing)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)
- [`session_already_finalized`](https://provenanceauth.com/docs/platform/errors.md#session_already_finalized)
- [`session_expired`](https://provenanceauth.com/docs/platform/errors.md#session_expired)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_full_K7mN3xQp9RbT2vWm8sYd4cFjLhXn6gAe
curl -s -X POST "$PROVENANCE_API/v1/attest/capture_sessions" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "device_id": "dev_00000000000000000000000000000001",
    "claim_id": "CLM-DOCS-VIDEO",
    "chunk_duration_ms": 2000
  }' > step.json
export SESSION_ID=$(jq -r '.id' step.json)
curl -X POST "$PROVENANCE_API/v1/attest/capture_sessions/$SESSION_ID/chunks" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "index": 0,
    "chunk_hash": "2110a233677a28c9cd6d66ac954ce831e70587e1940cf53e1a66f36683efad68",
    "captured_at": "2026-10-24T13:30:00.000Z"
  }'
```

**Node**

```ts
const step1 = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/capture_sessions`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "device_id": "dev_00000000000000000000000000000001",
    "claim_id": "CLM-DOCS-VIDEO",
    "chunk_duration_ms": 2000
  }),
})).json();
const sessionId = step1.id;
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/capture_sessions/${sessionId}/chunks`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "index": 0,
    "chunk_hash": "2110a233677a28c9cd6d66ac954ce831e70587e1940cf53e1a66f36683efad68",
    "captured_at": "2026-10-24T13:30:00.000Z"
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
step1 = httpx.post(f"{api}/v1/attest/capture_sessions", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}, json={
    "device_id": "dev_00000000000000000000000000000001",
    "claim_id": "CLM-DOCS-VIDEO",
    "chunk_duration_ms": 2000
}).json()
session_id = step1["id"]
data = httpx.post(f"{api}/v1/attest/capture_sessions/{session_id}/chunks", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}, json={
    "index": 0,
    "chunk_hash": "2110a233677a28c9cd6d66ac954ce831e70587e1940cf53e1a66f36683efad68",
    "captured_at": "2026-10-24T13:30:00.000Z"
}).json()
```

### Response 200

```json
{
  "object": "capture_chunk",
  "session_id": "cses_2ACVSEKTKG8YM9N2BHPZY4PQS0",
  "index": 0,
  "chunk_count": 1
}
```

## Finalize a capture session

`POST /v1/attest/capture_sessions/{id}/finalize`

Closes a live session with the signed video bundle and verifies it: the nonce, the chunk chain and the arrival timing.

Auth: an API key, as `Authorization: Bearer <key>`.

### Parameters

| Name | In | Type | Required | Description |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string | no | Retry a create safely: the same key + request returns the stored response (24 h, per caller). |
| `id` | path | string | yes | The session's ID. |
| `bundle` | body | object | yes | The signed attestation bundle. |
| `bundle.schema` | body | string | yes | The bundle schema's URL. |
| `bundle.capture_type` | body | string | yes | `image` or `video`. |
| `bundle.session_nonce` | body | string | yes | The server's nonce that seeds the chunk hash chain. |
| `bundle.signature` | body | string | yes | The base64url signature from the passkey assertion. |

### Returns

The verification result for the finished video.

### Errors

- [`authentication_required`](https://provenanceauth.com/docs/platform/errors.md#authentication_required)
- [`insufficient_scope`](https://provenanceauth.com/docs/platform/errors.md#insufficient_scope)
- [`invalid_json`](https://provenanceauth.com/docs/platform/errors.md#invalid_json)
- [`media_too_large`](https://provenanceauth.com/docs/platform/errors.md#media_too_large)
- [`parameter_invalid`](https://provenanceauth.com/docs/platform/errors.md#parameter_invalid)
- [`parameter_missing`](https://provenanceauth.com/docs/platform/errors.md#parameter_missing)
- [`rate_limit_exceeded`](https://provenanceauth.com/docs/platform/errors.md#rate_limit_exceeded)
- [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing)
- [`session_already_finalized`](https://provenanceauth.com/docs/platform/errors.md#session_already_finalized)
- [`session_expired`](https://provenanceauth.com/docs/platform/errors.md#session_expired)

### Request

**curl**

```bash
export PROVENANCE_KEY=prv_test_full_K7mN3xQp9RbT2vWm8sYd4cFjLhXn6gAe
curl -X POST "$PROVENANCE_API/v1/attest/capture_sessions/cs_01M5Q1VJHMGX8E4RVWQ6Y2B9TN/finalize" \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "bundle": {
      "schema": "https://provenanceauth.com/claims/v2",
      "capture_type": "video",
      "session_nonce": "9f2b1c4d6e8a0b2c4d6e8f0a1b3c5d7e9f1a3b5c7d9e1f3a5b7c9d1e3f5a7b9c",
      "signature": "MEUCIQDx5n0q4sSPVd3a2Wbl0L8kQ0YwGg"
    }
  }'
```

**Node**

```ts
const data = await (await fetch(`${process.env.PROVENANCE_API}/v1/attest/capture_sessions/cs_01M5Q1VJHMGX8E4RVWQ6Y2B9TN/finalize`, {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.PROVENANCE_KEY}`, "Content-Type": "application/json" },
  body: JSON.stringify({
    "bundle": {
      "schema": "https://provenanceauth.com/claims/v2",
      "capture_type": "video",
      "session_nonce": "9f2b1c4d6e8a0b2c4d6e8f0a1b3c5d7e9f1a3b5c7d9e1f3a5b7c9d1e3f5a7b9c",
      "signature": "MEUCIQDx5n0q4sSPVd3a2Wbl0L8kQ0YwGg"
    }
  }),
})).json();
```

**Python**

```python
import os
import httpx

api = os.environ["PROVENANCE_API"]
data = httpx.post(f"{api}/v1/attest/capture_sessions/cs_01M5Q1VJHMGX8E4RVWQ6Y2B9TN/finalize", headers={"Authorization": f"Bearer {os.environ['PROVENANCE_KEY']}"}, json={
    "bundle": {
        "schema": "https://provenanceauth.com/claims/v2",
        "capture_type": "video",
        "session_nonce": "9f2b1c4d6e8a0b2c4d6e8f0a1b3c5d7e9f1a3b5c7d9e1f3a5b7c9d1e3f5a7b9c",
        "signature": "MEUCIQDx5n0q4sSPVd3a2Wbl0L8kQ0YwGg"
    }
}).json()
```

### Response 200

```json
{
  "id": "cses_3X7EF22Q2A9Y7BDMGTKJ73YPVG",
  "object": "verification_result",
  "claim_id": "CLM-2026-10421",
  "status": "verified",
  "risk_score": 0,
  "risk_factors": [],
  "chain": [
    {
      "event_type": "capture",
      "timestamp": "2026-10-24T22:31:40.112Z",
      "actor": "device:dev_00000000000000000000000000000001",
      "summary": "Captured video attestation (12 chunks)"
    }
  ],
  "device_info": {
    "device_id": "dev_00000000000000000000000000000001",
    "enrolled": true,
    "cert_valid": true,
    "cert_expires": "2028-10-23T22:26:42.000Z"
  },
  "capture_type": "video",
  "liveness_checked": true,
  "synthetic_media_score": null,
  "synthetic_media_factors": null,
  "verified_at": "2026-10-24T22:31:52.904Z",
  "sensor_hash": "0b7e4c2a9f1d6e38b5a2c7f4d1e9b3a06c8f2d5e7b1a4c9f3e6d0b8a2c5f7e1d"
}
```
