Skip to main content

Audit API

Query the immutable audit trail of all agent actions, policy decisions, and human interventions.

Query audit logs

GET /v1/audit

Auth: JWT Bearer Token

Query parameters

ParameterTypeDescription
entityTypestringFilter by entity type (run, tool_call, policy, approval)
entityIdstringFilter by specific entity ID
runIdstringFilter by run ID
actorTypestringFilter by actor type (agent, system, user)
actionstringFilter by action (e.g., blocked, approved, matched)
fromISO dateStart of date range
toISO dateEnd of date range
searchstringFull-text search across audit entries
limitnumberMax results (default: 50)
offsetnumberPagination offset

Examples

# All audit logs
curl http://localhost:3000/v1/audit \
-H "Authorization: Bearer $TOKEN"

# Logs for a specific run
curl "http://localhost:3000/v1/audit?runId=run_abc123" \
-H "Authorization: Bearer $TOKEN"

# All policy match events
curl "http://localhost:3000/v1/audit?entityType=policy&action=matched" \
-H "Authorization: Bearer $TOKEN"

# All human actions
curl "http://localhost:3000/v1/audit?actorType=user" \
-H "Authorization: Bearer $TOKEN"

# Search
curl "http://localhost:3000/v1/audit?search=deploy+production" \
-H "Authorization: Bearer $TOKEN"

# Date range
curl "http://localhost:3000/v1/audit?from=2026-03-01&to=2026-03-19&limit=100" \
-H "Authorization: Bearer $TOKEN"

Response

[
{
"auditId": "aud_abc123",
"runId": "run_xyz789",
"entityType": "tool_call",
"entityId": "tc_def456",
"action": "blocked",
"actorType": "system",
"actorId": "system:policy:block-destructive-ops",
"timestamp": "2026-03-19T10:32:15.000Z",
"metadata": {
"toolName": "shell_execute",
"policyName": "Destructive Script Block",
"reason": "Matched pattern: rm -rf"
}
},
{
"auditId": "aud_abc124",
"runId": "run_xyz789",
"entityType": "approval",
"entityId": "appr_ghi012",
"action": "approved",
"actorType": "user",
"actorId": "user:reviewer@company.com",
"timestamp": "2026-03-19T10:34:00.000Z",
"metadata": {
"decisionReason": "Reviewed and approved"
}
}
]

Export audit logs as CSV

GET /v1/audit/export

Auth: JWT Bearer Token

Downloads audit logs as a CSV file. Supports the same filters as the query endpoint (excluding limit and offset — exports up to 10,000 records).

Query parameters

ParameterTypeDescription
entityTypestringFilter by entity type (run, tool_call, policy, approval)
entityIdstringFilter by specific entity ID
runIdstringFilter by run ID
actorTypestringFilter by actor type (agent, system, user)
actionstringFilter by action (comma-separated for multiple)
fromISO dateStart of date range
toISO dateEnd of date range
searchstringFull-text search across audit entries

Examples

# Export all audit logs as CSV
curl -O -J "http://localhost:3000/v1/audit/export" \
-H "Authorization: Bearer $TOKEN"

# Export logs for a specific run
curl -O -J "http://localhost:3000/v1/audit/export?runId=run_abc123" \
-H "Authorization: Bearer $TOKEN"

# Export logs for a date range
curl -O -J "http://localhost:3000/v1/audit/export?from=2026-03-01&to=2026-03-19" \
-H "Authorization: Bearer $TOKEN"

Response

Returns a CSV file with headers: timestamp, auditId, entityType, entityId, runId, action, actorType, actorId, metadata.

The Content-Disposition header sets the filename to audit-export-YYYY-MM-DD.csv.