API: Audit
Audit history, hash chain verify, and PII erasure endpoints.
Overview
Audit endpoints provide access to execution history, hash chain verification, and GDPR PII erasure. All executions validated through the gateway are persisted in an append-only audit ledger.
Why It Matters
Compliance teams need queryable audit records and tamper-evident chain verification for ISO 42001 and SOC2 evidence.
Prerequisites
- Team tier and above for central audit and hash-chain verification
- Gateway with PostgreSQL (not embedded SQLite for production audit)
Step-by-Step Guide
List executions
GET /v1/audit/executions?agent_id=payment-agent&limit=50&offset=0
X-AgentTrust-Token: at_team_your_keyGet execution detail
GET /v1/audit/executions/{envelope_id}Verify hash chain
GET /v1/audit/chain/verifyReturns chain integrity status. Team tier and above — the entitlement guard answers
402 Payment Required (not 403) with an upgrade message on lower tiers. The list and
detail endpoints above carry no entitlement guard at all.
PII erasure (GDPR Art. 17)
DELETE /v1/audit/executions/{envelope_id}/piiMasks PII fields in payload without deleting hash chain metadata.
Full route list
| Method | Path | Purpose |
|---|---|---|
| GET | /v1/audit/executions | List records |
| GET | /v1/audit/executions/{envelope_id} | Record detail |
| GET | /v1/audit/executions/stats | Aggregate counts |
| GET | /v1/audit/chain/verify | Hash-chain integrity (Team+) |
| DELETE | /v1/audit/executions/{envelope_id}/pii | Mask PII on one record (GDPR Art. 17) |
| DELETE | /v1/audit/executions | Mask PII across all records — tenant exit |
| DELETE | /v1/audit/tenant | Hard delete tenant data — irreversible |
| GET | /v1/audit/soc2-export | SOC2 Type II export (Enterprise) |
| POST | /v1/audit/executions/{envelope_id}/replay | Re-run an envelope through the pipeline |
| GET | /v1/audit/executions/{envelope_id}/replay/history | Replay history for an envelope |
DELETE /v1/audit/executions and DELETE /v1/audit/tenant are the destructive pair
behind agentrust uninstall --delete-from-gateway. The first masks payloads; the second
hard-deletes executions, certifications, and agents and cannot be undone. Both
require an explicit confirm=true query parameter.
CLI equivalents
agentrust audit tail
agentrust export ./audit.jsonlExamples
curl -H "X-AgentTrust-Token: $AGENTRUST_KEY" \
"http://localhost:8000/v1/audit/executions?agent_id=faq-agent&limit=10"Best Practices
- Retention: 90-day hot store, 7-year metadata (see Data Governance)
- Run periodic chain verification in Enterprise deployments
- Use
agent_idfilter for per-agent compliance reports - Export via
/v1/reports/*for regulator evidence packs
Common Mistakes
- Expecting full payloads after 90-day retention period
- Deleting audit records manually in PostgreSQL (breaks hash chain)
- Using embedded SQLite as production audit store
Troubleshooting
| Issue | Fix |
|---|---|
| Empty audit list | Confirm validations hit this gateway instance |
| Chain verify fails | Do not manually edit audit table |
| 402 on chain verify | Team tier or above required — the entitlement guard returns 402, not 403 |
Related Resources
- Data Governance
- Operator dashboard —
agentrust-edge/dashboard/(served on:3000in the Compose stack) - Compliance