# API Reference

The CLI calls these routes for you. Use them directly only to build your own client. The base URL is `https://api.octetproof.com/v1/vaults`. Send a vault token as `Authorization: Bearer <token>`. The vault a token reads is its licence and environment.

Errors are `application/problem+json` with a stable `code`. See [Errors](/docs/vaults/reference/errors/). List routes page with `cursor` and `limit`.

## Read (`vaults:read`)

| Method and path | Returns |
|---|---|
| `GET /keys` | The vault's recipient keys and owner key, as a key list signed by Octet |
| `GET /owner-key` | The owner-key history, oldest first |
| `GET /policy` | The vault's settings, and every earlier version with its log position |
| `GET /objects` | Objects. Filters: `since`, `until` (on the received time), `decision_ref`, `subject_ref`, `source` |
| `GET /objects/{object_id}` | The index row, the receipt, the inclusion proof, and `bound`, the earliest timestamped checkpoint that contains the object's event |
| `GET /objects/{object_id}/blob` | The sealed object, `application/octet-stream`. Logged as `object_read`. |
| `POST /objects/{object_id}/retention-challenge` | A retention challenge. Body `{"nonce": "<64 hex>", "mode": "sampled", "samples": 16}`, or `"mode": "full"` without `samples`. A sampled answer returns the chunks with their Merkle paths, and is logged as `object_read`. At most 60 per licence per clock hour. See [Proof of retention](/docs/vaults/concepts/integrity/#proof-of-retention). |
| `GET /log/checkpoint` | The latest checkpoint, or an earlier one with `?tree_size=`, with its timestamps and witness cosignatures |
| `GET /log/consistency?from=&to=` | A consistency proof between two log sizes |
| `GET /log/events?since_index=` | Your vault's events, with what each one contains |

## Change (`vaults:admin`)

| Method and path | Does |
|---|---|
| `PUT /owner-key` | Set or replace the owner key |
| `POST /keys` | Register a recipient key. Returns its `kid` and an encrypted challenge. |
| `POST /keys/{kid}/activate` | Return the opened challenge, which activates the key |
| `POST /keys/{kid}/retire`, `POST /keys/{kid}/revoke` | Retire or revoke a key |
| `POST /keys/{kid}/owner-signature` | Sign a key again with the current owner key |
| `PUT`, `DELETE /objects/{object_id}/hold` | Set or clear a hold on one object |
| `PUT`, `DELETE /hold` | Set or clear a hold on the whole vault |
| `DELETE /objects/{object_id}` | Delete an object. Optional body `{"reason": "..."}`. |
| `POST /subjects/erase` | Delete up to 500 objects of one `subject_ref` per call. Body `{"subject_ref": "...", "reason": "..."}`. |
| `PUT /delegation-root` | Set the delegation root, certified by the owner key |
| `POST /delegations` | Register a delegation. Body `{"delegation": "octet_bsc_..."}`. |
| `GET /delegations` | List delegations |
| `POST /delegations/{delegation_id}/revoke` | Revoke a delegation |
| `POST /delegations/revoke` | Revoke by revocation ID. Body `{"revocation_id": "..."}`, with `"delegation_id"` for a copy the vault has not seen. |
| `POST /objects/{object_id}/grants` | Store a grant for an auditor |

## Auditor (a delegation)

An auditor sends `Authorization: Bearer octet_bsc_...` and signs every request with three headers: `Octet-Delegate-Time` (Unix milliseconds), `Octet-Delegate-Nonce` (16 random bytes, base64url) and `Octet-Delegate-Signature`. The vault accepts a time within 60 seconds of its own clock, and each nonce once. The CLI does this for you.

A delegation reaches `GET /objects` (only the delegated objects), `GET /objects/{object_id}`, `GET /objects/{object_id}/blob`, `GET /objects/{object_id}/grants/{grant_id}`, `GET /log/events` (only the delegated objects' events), `GET /log/checkpoint` and `GET /log/consistency`, as far as its operations allow. Every other route answers `403 delegation_scope`.

## Public (no credential)

| Method and path | Returns |
|---|---|
| `GET /signing-keys` | Octet's signing keys with their root certificates, and the root keys with their YubiKey attestations |
| `GET /status-lists/{sha256}` | An archived Android attestation revocation list |
| `GET /log/platform-events?tree_size=` | Octet's own log events, such as signing-key certificates, with their inclusion proofs |
| `GET /tlog/checkpoint` | The latest checkpoint as a C2SP signed note, with witness cosignatures |
| `GET /tlog/tile/...` | The log's C2SP `tlog-tiles` |

Public routes are rate-limited at the edge, except the tiles.
