# Capture, claim, verify

Ask a person for a photo signed at capture, read the claim it lands on, verify the attestation, and explain a claim that failed, against the sandbox.

In this quickstart you send a person a capture link, read the claim their photo lands on, verify its attestation and explain a claim that failed. The phone signs each photo at the moment of capture, so a photo changed afterwards fails verification. You use a published sandbox key, so you don't need an account.

### 1. Set your sandbox key

The full-access sandbox key reads the seeded claims and verifies attestations. Every key is listed on [Sandbox and keys](https://provenanceauth.com/docs/get-started/sandbox.md).

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_full_K7mN3xQp9RbT2vWm8sYd4cFjLhXn6gAe
```

### 2. Ask for a photo

[`POST /v1/attest/capture_requests`](https://provenanceauth.com/docs/api/capture-requests.md#post-v1-attest-capture-requests) creates a capture link for a claim. With `delivery: "self"` nothing is sent: the response carries `capture_url` for you to share. Capture requests need an account with its own Attest key; the published capture key is set up for it.

**curl**

```bash
curl -s -X POST $PROVENANCE_API/v1/attest/capture_requests \
  -H "Authorization: Bearer prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x" \
  -H "Content-Type: application/json" \
  -d '{
    "case_id": "CLM-2077",
    "items": [{ "type": "photo", "label": "The damage", "instructions": "Step back so the whole dent is in frame." }],
    "delivery": "self"
  }'
```

**Node**

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

const capture = new Provenance({ apiKey: "prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x", baseUrl: process.env.PROVENANCE_API });
const request = await capture.attest.captureRequests.create({
  caseId: "CLM-2077",
  items: [{ type: "photo", label: "The damage", instructions: "Step back so the whole dent is in frame." }],
  delivery: "self",
});
console.log(request.captureUrl);
```

**Python**

```python
import os
from provenanceauth import Provenance

capture = Provenance("prv_test_capture_C4pT9vQ2bW7mK3sYd8cFjLh6gAe1nR5x", base_url=os.environ["PROVENANCE_API"])
request = capture.attest.capture_requests.create(
    case_id="CLM-2077",
    items=[{"type": "photo", "label": "The damage", "instructions": "Step back so the whole dent is in frame."}],
    delivery="self",
)
print(request["capture_url"])
```

```json
{
  "object": "capture_request",
  "status": "pending",
  "case_id": "CLM-2077",
  "delivery": { "channel": "self", "delivered": false, "reason": "self_delivery" }
}
```

Open `capture_url` on a phone. The capture page signs each photo with a key on that device as it's taken, and the photo lands on claim `CLM-2077`.

### 3. Read the claim

[`GET /v1/attest/claims/{id}/provenance`](https://provenanceauth.com/docs/api/claims.md#get-v1-attest-claims-id-provenance) returns every asset on a claim with its verdict and risk score. Without a phone, continue on the seeded clean claim, which has two attested photos; with your own photo, read `CLM-2077` with the capture key instead.

**curl**

```bash
export CLAIM_ID=${CLAIM_ID:-CLM-SANDBOX-CLEAN}
curl -s $PROVENANCE_API/v1/attest/claims/$CLAIM_ID/provenance \
  -H "Authorization: Bearer $PROVENANCE_KEY" | tee claim.json
```

**Node**

```ts
const prov = new Provenance({ apiKey: process.env.PROVENANCE_KEY!, baseUrl: process.env.PROVENANCE_API });
const claim = await prov.attest.claims.getProvenance(process.env.CLAIM_ID ?? "CLM-SANDBOX-CLEAN");
```

**Python**

```python
prov = Provenance(os.environ["PROVENANCE_KEY"], base_url=os.environ["PROVENANCE_API"])
claim = prov.attest.claims.get_provenance(os.environ.get("CLAIM_ID", "CLM-SANDBOX-CLEAN"))
```

The response, trimmed to the first asset:

```json
{
  "id": "CLM-SANDBOX-CLEAN",
  "object": "claim",
  "assets": [
    { "id": "att_00000000000000000000000000000001", "status": "verified", "risk_score": 0, "capture_type": "image" }
  ],
  "overall_status": "verified",
  "overall_risk_score": 0
}
```

```bash
export ATTESTATION_ID=$(jq -r .assets[0].id claim.json)
```

### 4. Verify the attestation

[`POST /v1/attest/verifications`](https://provenanceauth.com/docs/api/claims.md#post-v1-attest-verifications) checks one attestation from scratch: the device's certificate, the signature over the capture record and the image bytes against the hash signed at capture.

**curl**

```bash
curl -s -X POST $PROVENANCE_API/v1/attest/verifications \
  -H "Authorization: Bearer $PROVENANCE_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "attestation_id": "'"$ATTESTATION_ID"'" }'
```

**Node**

```ts
const result = await prov.attest.verifications.create({ attestationId: claim.assets[0].id });
```

**Python**

```python
result = prov.attest.verifications.create(attestation_id=claim["assets"][0]["id"])
```

```json
{
  "object": "verification_result",
  "status": "verified",
  "risk_score": 0,
  "risk_factors": [],
  "device_info": { "enrolled": true, "cert_valid": true }
}
```

`verified` with a risk score of 0: an enrolled device signed this photo and nothing changed it since.

### 5. Explain a claim that failed

The seeded fraud claim holds two photos changed after capture. [`GET /v1/attest/claims/{id}/explanation`](https://provenanceauth.com/docs/api/claims.md#get-v1-attest-claims-id-explanation) turns its factors into fixed, plain-language text you can show the policyholder, with what would resolve each one.

**curl**

```bash
curl -s $PROVENANCE_API/v1/attest/claims/CLM-SANDBOX-FRAUD/explanation \
  -H "Authorization: Bearer $PROVENANCE_KEY"
```

**Node**

```ts
const explanation = await prov.attest.claims.explanation("CLM-SANDBOX-FRAUD");
console.log(explanation.summary);
```

**Python**

```python
explanation = prov.attest.claims.explanation("CLM-SANDBOX-FRAUD")
print(explanation["summary"])
```

The response, trimmed to the first two factors:

```json
{
  "object": "claim_explanation",
  "claim_id": "CLM-SANDBOX-FRAUD",
  "overall_status": "failed",
  "factors": [
    {
      "code": "signature_invalid",
      "title": "Signature did not verify",
      "resolution_hint": "Submit the original, unedited file exactly as captured."
    },
    {
      "code": "sensor_hash_mismatch",
      "title": "Image doesn't match its record",
      "resolution_hint": "Submit the original photo without cropping, filtering, or re-saving it."
    }
  ]
}
```

## Try it

The [Attest explorer](https://provenanceauth.com/attest#endpoints) verifies an attestation in your browser. The sandbox seeds these fixtures:

| Scenario | Input | Expected |
| --- | --- | --- |
| Clean photo | `attestation_id` `att_00000000000000000000000000000001` | `status: "verified"`, `risk_score: 0` |
| Edited photo | `attestation_id` `att_00000000000000000000000000000003` | `status: "failed"`, `signature_invalid` and `sensor_hash_mismatch` |
| Clean claim | `GET /v1/attest/claims/CLM-SANDBOX-CLEAN/provenance` | `overall_status: "verified"` |
| Edited video | `GET /v1/attest/claims/CLM-SANDBOX-VIDEO/provenance` | Asset `…0005` is `partial` with `frame_hash_mismatch` at chunk 1 |
| Unknown attestation | Any other `attestation_id` | `404` [`resource_missing`](https://provenanceauth.com/docs/platform/errors.md#resource_missing) |

## Next steps

- [Capture requests](https://provenanceauth.com/docs/attest/guides/capture-requests.md): Several items in order, SMS or email delivery, reminders and webhooks.
- [Review claim media](https://provenanceauth.com/docs/attest/guides/review-claims.md): Score, review and escalate claim media.
- [Capture on a phone](https://provenanceauth.com/docs/attest/guides/native-sdk.md): Sign captures in your own app with the hardware key.

See [Example apps](https://provenanceauth.com/docs/get-started/example-apps.md) for small working apps that use Attest end to end.
