# 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-24

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).

## 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

{ "fromSeq": 1, "toSeq": 50000 }
```

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 }
```

If anything doesn't match, `ok` is `false` and `brokenAt` names the first row whose hash, link or checkpoint failed. Verification runs are themselves audited.

## 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.
- Neurouter fails closed by default: if the audit log can't be written, the call isn't made.

## 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.
