---
title: "Audit log and evidence"
description: "The hash-chained audit record of every change, its filters and export, chain verification and rebase, retention, and evidence files for an auditor."
url: "https://opod.io/docs/control-plane-security/audit/"
markdown_url: "https://opod.io/docs/control-plane-security/audit.md"
section: "Security"
last_updated: "2026-11-12"
---

# Audit log and evidence

> The hash-chained audit record of every change, its filters and export, chain verification and rebase, retention, and evidence files for an auditor.

The audit log is one record of what changed and who did it. It joins two sources:

- **Leader rows**: every state-changing `/admin/v1` call a leader received (with the key name and status), and its lifecycle events: plan, auth and policy updates, node, model and shard events.
- **Control-plane rows**: endpoint changes, applied plans, keys, policies, runs, alerts, sign-ins, users, tokens, settings — with the actor.

Reads and heartbeats are never audit rows. Every row is also a link in a **hash chain** written in the same transaction, so a removed or edited row breaks the chain.

## In short

Every change to the control plane and its leaders is written to the audit log with who did it. Each row is also a link in a hash chain, so a row that is removed or edited breaks the chain, and a check finds it. You read and export the log by filter, check the chain, keep a copy of it outside the control plane, and set how long rows are kept.

## When you need it

- To answer "who changed this endpoint, and when?".
- An auditor asks for the change record, for proof that it is complete, or for a list of the models you run.
- Your policy requires a retention period, for example six months or a year.

## Do it

1. **Find who changed an endpoint**

   ```bash
   curl -s -H "$H" "https://cp.example.com/api/v1/audit?since=7d&source=cp&q=chat&limit=50" \
     | jq -r '.[] | [.ts, .actor, .type, .subject] | @tsv'
   ```

2. **Export a period as CSV**

   ```bash
   curl -s -H "$H" "https://cp.example.com/api/v1/audit/export?since=30d" -o audit.csv
   ```

   One call returns up to 2,000 rows. For more, call again with `until=<the oldest ts you hold>`.

3. **Check the chain**

   ```bash
   curl -s -H "$H" https://cp.example.com/api/v1/audit/verify | jq '{ok, entries, headSeq, firstBadSeq}'
   ```

4. **Keep a copy outside the control plane**

   ```bash
   curl -s -H "$H" https://cp.example.com/api/v1/audit/chain -o "chain-$(date +%F).jsonl"
   ```

   Store the file where the control plane cannot write, for example a bucket with object lock.

5. **Set the retention**

   ```bash
   curl -s -H "$H" -H 'Content-Type: application/json' -X PUT https://cp.example.com/api/v1/audit/retention -d '{"days": 365}'
   ```

   In the release after 0.3.6 the CLI does the same: `opodcp audit retention set 365`. A lower number asks first, or takes `--yes`. `opodcp audit retention` prints the current value. See the [CLI reference](https://opod.io/docs/control-plane-reference/cli/#audit-retention).

## Check it worked

A good `verify` answer has `"ok": true`, and `entries` grows as people work. `GET /api/v1/audit/retention` answers `{"days": 365, "keepAll": false}`. In the console, the **Audit log** page shows the same rows, and an admin can run the chain check there.

## If it fails

| Symptom                                    | Cause                                                                                    | Fix                                                                        |
| ------------------------------------------ | ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
| `400 invalid` on a read                    | `source` is not `leader` or `cp`, or `limit` is not a positive integer                   | fix the parameter                                                          |
| A search misses old rows                   | the rows are older than the retention window                                             | a longer `days`, or `keep-all`                                             |
| `verify` answers `"ok": false`             | a link does not follow from the one before; `firstBadSeq` and `detail` say where and how | compare with your outside copy; if no row was touched, an admin may rebase |
| `400` on rebase                            | the reason is shorter than 10 or longer than 500 characters                              | write a real reason                                                        |
| `403`                                      | reading the chain, verifying and rebasing need admin                                     | an admin's token                                                           |
| A browser download fails with `401`        | a download by navigation cannot send the header                                          | the console uses a stream ticket; a script sends the header                |
| The evidence retention report reads `fail` | the defaults keep 90 days of audit and 30 of usage                                       | set the values it names                                                    |

## Who did it

The actor (`by`) is the caller the API resolved: a local user, an SSO user by name (the first of the claims `email`, `preferred_username`, `name`, `sub`), `token:<name>` for a machine token, or `static-admin` for the bootstrap token. When no person acted, it is the control loop that did, by name: `autoscaler`, `reconciler`. Those names, `static-admin` and `dev` cannot be used as local user names.

## Read and export

```bash
curl -s -H "$H" "https://cp.example.com/api/v1/audit?since=7d&source=cp&type=endpoint.&q=chat&limit=500"
curl -s -H "$H" "https://cp.example.com/api/v1/audit/export?since=30d" -o audit.csv
```

| Parameter | Meaning                                                                   |
| --------- | ------------------------------------------------------------------------- |
| `since`   | RFC 3339, or `24h`, `7d`                                                  |
| `until`   | the cursor to page back: the `ts` of the oldest row you hold (inclusive)  |
| `limit`   | a positive integer; default 200, at most 2,000                            |
| `source`  | `leader` or `cp`; anything else is `400 invalid`                          |
| `type`    | a prefix, for example `key.`                                              |
| `q`       | a case-insensitive substring over type, subject, endpoint, actor and data |

Every filter runs in the database, so `limit` counts matching rows and a search reaches rows far older than the newest page. A row is `{ts, source, endpoint, type, subject, actor, data}`. A team-scoped caller sees only rows of its own endpoints and subjects.

The CSV export (operator) takes the same filters and has columns `ts, source, endpoint, type, subject, actor, data` (`ts` in RFC 3339 with nanoseconds, `data` as JSON), up to 2,000 rows per call; page back with `until`. A browser starts it with a single-use stream ticket (`?ticket=`), because a download by navigation cannot send a header. The console's **Audit log** page loads 500 rows and **Load older** from there.

From 0.3.0, the **Activity** page and `GET /api/v1/activity` show the same record classified for a person: each row a change or an event, a category, a level and a plain title, with repeats folded.

## Verify the chain

Each chain entry carries `seq`, `ts`, `source` (`leader`, `cp` or `anchor`), `type`, `subject`, `actor`, `tenant`, `team`, `cell`, `data`, `prevHash` and `hash`. The hash covers the entry and the hash before it, so a removed, edited or reordered row breaks every link after it.

```bash
curl -s -H "$H" https://cp.example.com/api/v1/audit/verify     # admin
```

```json
{
  "ok": true,
  "entries": 18342,
  "head": "9c1e…",
  "headSeq": 18342,
  "anchors": 3,
  "from": "2026-08-01T00:00:00Z"
}
```

On a broken chain `ok` is `false`, `firstBadSeq` names the first link that does not follow from the one before, and `detail` says how. `from` is the oldest entry still kept. `rebase`, when present, is the newest rebase: `seq`, `at`, `by`, `reason` and `unverifiedBefore`, the count of earlier links this answer does not vouch for.

```bash
curl -s -H "$H" https://cp.example.com/api/v1/audit/chain -o chain.jsonl   # admin, one entry per line
```

`verify` walks the chain inside the control plane. Keep a copy of the chain **outside** it (`/api/v1/audit/chain`, newline-delimited JSON with the hashes) and repeat the walk there: a copy the control plane cannot reach is the only check against a database that was rewritten whole.

**Retention and anchors.** When retention trims old rows, the control plane first writes an `anchor` entry that records the hash of the last trimmed link. The walk restarts from it, so a trimmed chain still verifies. `anchors` counts them.

**Rebase** declares the chain verified from its current head on, for a chain that became unverifiable without being touched. It appends a link carrying who decided it and why; nothing is deleted or rewritten, and `verify` then names the links it no longer vouches for.

```bash
curl -s -H "$H" -H 'Content-Type: application/json' -X POST https://cp.example.com/api/v1/audit/rebase \
  -d '{"reason":"links written before the hash format change"}'
```

The reason is 10 to 500 characters; anything else is refused. The answer is `201` with the rebase entry. The console offers **Rebase** to an admin only after a walk that failed.

## Retention

| Route                                          | Meaning                     |
| ---------------------------------------------- | --------------------------- |
| `GET /api/v1/audit/retention`                  | `{ days, keepAll }`         |
| `PUT /api/v1/audit/retention {"days": 365}`    | 1 to 3,650 days; default 90 |
| `PUT /api/v1/audit/keep-all {"keepAll": true}` | keep every row              |

The `audit-retention` loop trims every 10 minutes. Plan history and run logs follow the same window, except the current revision of a live endpoint. In the release after 0.3.6, resolved alerts do too: an alert resolved before the window is deleted, with its delivery record, while its `alert.fired` and `alert.resolved` events stay as long as the audit does. An open alert is never trimmed, sticky or not. Up to and including 0.3.6, resolved alerts are never deleted, and a flapping alert adds a row on each cycle.

## Evidence for an auditor

The evidence routes are new in 0.3.0. The control plane pushes nothing; your compliance tool pulls these.

| Route                                 | What it is                                                                                                                                                                                                                                             |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `GET /api/v1/evidence/ml-bom` (admin) | the deployed models as a **CycloneDX 1.6 ML-BOM**: one `machine-learning-model` component per distinct set of bytes an endpoint runs, with its licence, hash, approval and signature result; one service per endpoint; and the dependency between them |
| `GET /api/v1/evidence/retention`      | each log store's retention against six months (184 days): `pass`, `fail` (with what to set) or `unknown`                                                                                                                                               |
| `GET /api/v1/audit/export`            | the record, CSV                                                                                                                                                                                                                                        |
| `GET /api/v1/audit/verify`            | proof that the record is intact                                                                                                                                                                                                                        |

The retention report fails on the defaults (90 days of audit, 30 days of usage) and says what to set. With a usage sink connected, the usage store reads `unknown`: the rows live in your store, whose retention the control plane cannot read.
