> For the complete documentation index, see [llms.txt](https://docs.brain.fi/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.brain.fi/build/audit-every-action.md).

# Audit Every Action

Read a tenant-scoped, tamper-evident audit trail and verify its inclusion proofs.

Goal: retrieve the authenticated tenant's meaningful audit events for compliance review, support work, and proof verification.

The API and off-chain audit service are production available. The public anchor contract runs on Base Sepolia only and is unaudited.

### Read the Trail

```typescript
const page = await brain.audit.list({
  layer: "execution",
  since: "2025-09-01T00:00:00.000Z",
  until: "2025-09-30T23:59:59.999Z",
  limit: 100,
});

for (const event of page.events) {
  console.log(event.id, event.action, event.created_at);
}
console.log(page.nextCursor);
```

The available filters are `layer`, `actor`, `since`, `until`, `limit`, and `cursor`.

| Event action                 | Meaning                          |
| ---------------------------- | -------------------------------- |
| `wiki.question`              | A Wiki question was processed    |
| `policy.evaluate`            | A policy evaluation was recorded |
| `ledger.transaction.created` | A Ledger transaction was created |
| `agent.action.proposed`      | An agent created a proposal      |
| `payment_intent.approved`    | A human approval completed       |
| `payment_intent.executed`    | A payment completed              |

### Verify a Payment Proof

```typescript
const proof = await brain.proof("pi_8231");

console.log(proof.merkle_root);
console.log(proof.merkle_proof);
console.log(proof.chain_anchor?.tx_hash);
console.log(proof.chain_anchor?.block_number);
console.log(proof.rail_receipt);
```

The proof includes the exact `audit_events` objects used for the proof, rather than only event identifiers.

### Trace an Entity

```typescript
const trace = await brain.trace("pi_8231");

for (const entry of trace.entries) {
  console.log(entry.event.action, entry.event.created_at);
  console.log(entry.inclusionProof.merkleRoot);
}
```

`brain.trace` is an SDK aggregation over the entity history and each event's inclusion proof. Its entries are `{ event, inclusionProof }`.

### Export Tenant Data

`brain.audit.export()` is an intentional SDK stub and the underlying audit export endpoint returns 501. Use the tenant export lifecycle instead:

```
POST /v1/tenants/{tenant_id}/export
GET  /v1/tenants/{tenant_id}/export/{job_id}
GET  /v1/tenants/{tenant_id}/export/{job_id}/download
```

### Filter by Actor

```typescript
const page = await brain.audit.list({
  actor: "agent:payments-v1",
  since: new Date(Date.now() - 86_400_000).toISOString(),
  limit: 100,
});

for (const event of page.events) {
  console.log(event.action, event.created_at);
}
```

### What's Next

* [Let an External Agent In](/build/let-an-external-agent-in.md)
* [Audit and Proof](/protocol/audit-and-proof.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.brain.fi/build/audit-every-action.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
