API Reference

API: Audit

Audit history, hash chain verify, and PII erasure endpoints.

API: Audit

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_key

Get execution detail

GET /v1/audit/executions/{envelope_id}

Verify hash chain

GET /v1/audit/chain/verify

Returns 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}/pii

Masks PII fields in payload without deleting hash chain metadata.

Full route list

MethodPathPurpose
GET/v1/audit/executionsList records
GET/v1/audit/executions/{envelope_id}Record detail
GET/v1/audit/executions/statsAggregate counts
GET/v1/audit/chain/verifyHash-chain integrity (Team+)
DELETE/v1/audit/executions/{envelope_id}/piiMask PII on one record (GDPR Art. 17)
DELETE/v1/audit/executionsMask PII across all records — tenant exit
DELETE/v1/audit/tenantHard delete tenant data — irreversible
GET/v1/audit/soc2-exportSOC2 Type II export (Enterprise)
POST/v1/audit/executions/{envelope_id}/replayRe-run an envelope through the pipeline
GET/v1/audit/executions/{envelope_id}/replay/historyReplay 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.jsonl

Examples

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_id filter 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

IssueFix
Empty audit listConfirm validations hit this gateway instance
Chain verify failsDo not manually edit audit table
402 on chain verifyTeam tier or above required — the entitlement guard returns 402, not 403