# Audit log

> What Neurouter records for every MCP tool call, how the hash chain and signed checkpoints make tampering detectable, how to verify the chain, and how to export, stream and archive events.

Source: https://neurouter.com/docs/audit-log · Last updated: 2026-11-25

Neurouter writes every MCP call, tool search, admin change and sign-in to an append-only audit log. Rows are hash-chained and sealed by signed checkpoints, so changes to past records are detectable. For the overview, see [Tamper-evident audit log](https://neurouter.com/features/audit-log).

![Audit chain verification dialog reporting every entry verified](https://neurouter.com/screens/audit-verify.png "Verify integrity recomputes the hash chain over the retained log and checks the signed checkpoints.")

## What a record contains

For a tool call: timestamp, user, agent, client, server, tool, the decision (allowed; blocked with a reason; approval pending, approved or denied), input parameters after redaction, output size and hash, status, latency, error, trace ID and session ID.

- **Redaction** rules are applied before anything is stored, so secrets in arguments are never written.
- **Outputs** are stored as size and SHA-256 hash by default. An admin can turn on storing full outputs (up to 64 KiB per call by default).
- Admin and configuration changes are audited too.

## How the chain works

```text
genesis_prev = sha256("neurouter-audit-genesis:" + install_id)
entry_body   = JCS(row)          # RFC 8785 canonical JSON, nulls explicit
hash(n)      = sha256(prev_hash ‖ 0x1E ‖ entry_body)
```

One global chain covers the whole deployment, including all replicas. A **checkpoint** signed with an HMAC key derived from your key-encryption keys is written every 10,000 rows or 5 minutes, on key rotation, and before every retention cut.

## Verifying the chain

In the console: *Audit & observability → Audit log → Verify*. Through the API (Auditor or Admin role):

```http
POST /api/audit/verify
Content-Type: application/json

{ "from": "2026-11-01T00:00:00Z", "to": "2026-11-25T00:00:00Z" }
```

`from` and `to` are optional timestamps; without them the whole retained log is verified. The response is `202 {"jobId": "…"}`; poll `GET /api/jobs/:id`. The result is:

```json
{ "ok": true, "checked": 50000, "firstSeq": 1, "lastSeq": 50000,
  "checkpointsVerified": 5, "brokenAt": null, "durationMs": 1830 }
```

If anything doesn't match, `ok` is `false` and `brokenAt` names the first row whose hash, link or checkpoint failed, with a `reason` (`hash_mismatch`, `broken_link`, `gap`, `bad_checkpoint_mac` or `checkpoint_mismatch`). Verification runs are themselves audited. To check an export independently of Neurouter's code, see [Verifying the audit log offline](https://neurouter.com/blog/tamper-evident-audit-log-for-ai-agents#offline-with-your-own-code).

## Threat model

- Someone with database write access can rewrite rows **and** recompute the chain, but they can't forge checkpoint MACs without your key-encryption keys. Rewriting history is therefore detectable at the next checkpoint.
- Deleting the newest rows is only detectable up to the last checkpoint that left the database. **Export audit events** to a system your database administrators don't control.
- Audit writes are batched (every 200 ms or 200 events), so a call doesn't wait for its own row. Neurouter fails closed by default: if 10,000 events are waiting to be written, new tool calls are refused until the queue drains. Watch `neurouter_audit_queue_depth`.

## Search and export

- Filter by user, agent, server, tool, decision, status and time range; full-text search over parameters.
- Export as CSV or JSON Lines from the console.

## Streaming to a SIEM

Configure in *Settings → Gateway settings → Export*:

- **Webhook:** batches of events as `application/x-ndjson`. With a secret set, each request carries `X-Neurouter-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "t.body">` so the receiver can verify origin and freshness.
- **OpenTelemetry logs:** audit events exported as OTLP logs.

## Retention and archive

Audit retention defaults to **90 days** and is configurable. If `AUDIT_ARCHIVE_URL` is set (`file:`, `s3://`, `gs://` or `azblob://`), rows are archived there before they're deleted. A checkpoint is written before every retention cut, so the remaining chain still verifies.

## Separate audit database

Set `AUDIT_DATABASE_URL` to keep the audit log, sessions and metric rollups in their own database, with its own connection pool and migrations.
