Skip to main content

How audit logging works

Every call to kavach.authorize() or kavach.authorizeByToken() writes an entry to the audit log, regardless of outcome. Allowed, denied, and rate-limited calls are all recorded. The log is append-only: entries are never updated or deleted. authorize() returns an auditId linking the decision to its log entry:

Querying logs

AuditEntry type

string
Unique entry identifier, prefixed aud_.
string
The agent that triggered the authorization check.
string
The user who owns the agent.
string
The action the agent attempted (e.g. read, write, delete).
string
The resource the action was attempted on.
Arguments passed to the tool at the time of the call.
'allowed' | 'denied' | 'rate_limited'
The outcome of the authorization check.
number
Time taken to evaluate the decision, in milliseconds.
number
Optional token usage from the agent’s LLM call, if provided.
Date
When the authorization check occurred.

Filtering

All filter fields are optional and combinable. Without filters, the query returns all entries up to the limit.
string
Filter to a specific agent.
string
Filter to all agents owned by a user.
Date
Include entries on or after this timestamp.
Date
Include entries before this timestamp.
string[]
Filter to specific action names.
'allowed' | 'denied' | 'rate_limited'
Filter by outcome.
number
Maximum entries to return. Default is 1000.
number
Pagination offset.

Exporting logs

The CSV export includes a header row with field names matching the AuditEntry interface. Each row is one authorization decision.
Both since and until are optional on exports. Omitting both exports the entire log.

Compliance references

Article 12 requires high-risk AI systems to log events automatically throughout the system lifecycle, including the period of activity and data used. KavachOS records every authorization decision with agent identity, resource, action, parameters, outcome, and timestamp.
The NIST AI Risk Management Framework calls for documented accountability mechanisms and the ability to trace AI actions to specific identities. The append-only audit trail links every decision to a named agent and user.
SOC 2 trust services criteria for logical access controls and system monitoring require evidence that access is granted only to authorized identities and that access events are logged. The allowed/denied/rate_limited result field satisfies CC6.1–CC6.3. The tamper-evident, append-only structure satisfies CC7.2.
ISO 42001 recommends documenting the behavior of AI systems in production. Exporting the audit log as JSON or CSV gives auditors a machine-readable record of every decision the system made.

Usage patterns

Monthly access report for a user
Agents with repeated denials today
High-frequency agent detection
A sudden spike in call volume from a single agent often indicates a runaway loop. Use kavach.agent.revoke() to suspend the agent while you investigate.

Next steps

Compliance

Map audit data to EU AI Act, NIST, SOC 2, and ISO 42001.

REST API

Query audit logs via HTTP endpoints.

Admin dashboard

Visual audit log viewer with filters and export.
Last modified on April 18, 2026