<!-- source: https://secondlayer.tools/docs/api-reference#verify-archive -->

## Verify this instance against a signed archive

`POST /v1/archive/verify`

Compares identity digests of this instance's blocks, transactions and events against the range digests in a signed archive manifest. Read-only: the instance fetches the manifest, nothing is uploaded. Semantic replay (`--deep`) is CLI only. Without `from_block` or `to_block`, a manifest with more than 40 matching ranges is refused with 400. A missing key, an unreachable manifest, a failed signature or no matching digests answer 200 `unanchored` with a `reason`, never `clean`.

### Body

| Field | Type | Description |
| --- | --- | --- |
| `against` | string · uri, required | https URL of `latest.json` or a snapshot manifest. Local paths and plain http are refused. |
| `target` | string | `raw` (default) or `all` check blocks, transactions and events. `decode:<name>` and `subgraph:<name>` parse, but only raw datasets have digests, so they answer `unanchored` with `no digests`. |
| `from_block` | integer | First height to check. Needed, with or without `to_block`, when the manifest has more than 40 matching ranges. |
| `to_block` | integer | Last height to check. Must be at least `from_block`. |
| `insecure` | boolean | Compare even when the signature does not verify. `signature.verified` stays `false`. |
| `public_key_pem` | string | Archive signing key to verify with. Without it the instance uses `ARCHIVE_SIGNING_PUBLIC_KEY` (or `STREAMS_SIGNING_PUBLIC_KEY`); the hosted API also fetches the published key. |

### Returns

One `ArchiveVerifyResult` object.

### Responses

- `200` The comparison, or `unanchored` with the reason it could not run
- `400` The body is not JSON (`INVALID_JSON`), `against` is missing or not https, a field has the wrong type, `target` is not recognised, `to_block` is below `from_block`, or more than 40 ranges matched without a height window (`VALIDATION_ERROR`)
- `401` This bind requires the instance token, and it was missing or wrong

### Example

```bash
curl -X POST https://api.secondlayer.tools/v1/archive/verify \
  -H "Authorization: Bearer $SECONDLAYER_API_KEY" \
  --json '{
  "against": "https://archive.secondlayer.tools/latest.json",
  "target": "raw",
  "from_block": 0,
  "to_block": 99999
}'
```

```json
{
  "status": "diverged",
  "target": "raw",
  "against": "https://archive.secondlayer.tools/latest.json",
  "signature": {
    "verified": true
  },
  "coverage": {
    "from_block": 0,
    "to_block": 99999
  },
  "ranges": [
    {
      "dataset": "blocks",
      "from_block": 0,
      "to_block": 49999,
      "status": "match",
      "expected_digest": "5d41402abc4b2a76b9719d911017c592",
      "actual_digest": "5d41402abc4b2a76b9719d911017c592"
    },
    {
      "dataset": "blocks",
      "from_block": 50000,
      "to_block": 99999,
      "status": "digest-mismatch",
      "expected_digest": "7d793037a0760186574b0282f2f435e7",
      "actual_digest": "e2fc714c4727ee9395f324cd2e7f331f"
    }
  ]
}
```
