Valta Docs
Audit Export
The audit trail records every run, every attempted action, every policy check, and every blocked injection attempt. You can export the full history at any time.
Export all entries for an agent
ts
const entries = await valta.audit.export({ agentId: agent.id })
console.log(`Exporting ${entries.length} entries`)
Export a date range
ts
const entries = await valta.audit.export({
agentId: agent.id,
from: '2026-01-01',
to: '2026-03-31',
})
Write to CSV
ts
import { writeFileSync } from 'fs'
const entries = await valta.audit.export({ agentId: agent.id })
const csv = [
'id,action,agentId,userId,createdAt',
...entries.map(e => `${e.id},${e.action},${e.agentId},${e.userId},${e.createdAt}`)
].join('\n')
writeFileSync('audit-export.csv', csv)
console.log(`Wrote ${entries.length} entries to audit-export.csv`)
Verify chain integrity before export
The audit trail uses a cryptographic hash chain. Verify it is intact before exporting for compliance purposes.
ts
const check = await valta.audit.verify(agent.id)
if (!check.intact) {
throw new Error(`Audit chain integrity failed at entry ${check.firstFailedId}`)
}
// Safe to export
const entries = await valta.audit.export({ agentId: agent.id })
CLI
bash
valta audit export --agent-id <id>
Prints CSV to stdout. Pipe to a file:
bash
valta audit export --agent-id <id> > audit-export.csv
Note: Export auto-paginates. It fetches all entries regardless of count. For agents with large histories, this may take a few seconds.