Skip to main content
Source controller: apps/erp-backend/src/audit/audit.controller.ts
The audit trail is a forensic, append-only log of every mutating request against an entity’s data. Each row stores the actor, credential type, declared actor, request id, route, method, and a diff of what changed. GET requests do not produce audit records.

List audit trail

GET /api/entities/:entityId/audit-trail Returns a paginated page of audit envelopes for the entity, plus the named resources needed to render them without extra lookups. Query params (from listAuditTrailQuerySchema) Response: auditTrailPageSchema (paginated: { envelopes, namedResources, nextCursor })

What the trail captures

Per ADR 0028, the audit trail is row-level and automatic via Postgres triggers. Every mutating request produces one Audit Envelope grouping its Audit Changes:
  • Actor: actorUserId plus name and role of the authenticated user
  • Credential type: session for browser sessions, api_key for API key requests
  • Declared actor: the value of the x-audit-actor header on API-key mutations (stored as a claim, not a verified identity)
  • Request id: a server-generated unique id grouping all changes in one request
  • Route and HTTP method: the endpoint that triggered the mutation
  • Entity id: the entity scope the change occurred within
  • Diff: for inserts and deletes, the full row image; for updates, only the columns that moved with before and after values
GET requests are not audited. Unbook (soft delete) is now traceless no longer: the removed entry’s full image survives as Audit Changes.

Status codes

Unverified: the exact set of tableName values accepted by the filter and the complete list of columns redacted from audit images (for example, secret hashes) are defined in the backend trigger configuration and migration files. Refer to @sintropix/api-contract and the backend audit module for the precise schema.