Audit Logging Guide

Overview

Audit logging provides an immutable record of all permission changes in your organization, enabling compliance tracking, debugging, and accountability. Logs are append-only, never modified, and automatically cleaned up based on retention policy.

How It Works

Log Lifecycle

  1. Event Occurs — A role, team, or membership change happens
  2. Log Created — The change is recorded with actor, IP, timestamp, and details
  3. Stored Permanently — Log becomes immutable (read-only forever)
  4. Queryable — Admins can search by actor, resource, action, or date
  5. Cleaned Up — Logs older than retention period are deleted by cleanup job

Audit Actions (MVP)


Querying Audit Logs

Basic Query

Get all audit logs for your organization:

Filter by Actor

Find all changes made by a specific user:
This is useful for auditing a specific admin’s activities or seeing if someone made unauthorized changes.

Filter by Resource

Track all changes to a specific role:
Supported resource types:
  • role — Custom role changes
  • team — Team CRUD operations
  • member — Member changes (added, removed, role assignments)

Filter by Date Range

Get logs from the last 30 days:

Combined Filters

Find all role-related changes by an admin in the last week:

Log Format

Example Audit Log Entry

Field Definitions


Retention Policy

Default Retention

Organizations retain audit logs for a default period (e.g., 90 days). After this period, logs are automatically deleted. The response from the audit API includes the retention period:

Cleanup Process

A scheduled job (cron, Lambda, etc.) calls the cleanup endpoint periodically:
Response:

Dry Run

Test cleanup without deleting:
Returns how many logs would be deleted without actually deleting them.

Common Use Cases

Compliance Audit

“Show me all role changes made in Q1 2026”:
Then export to CSV or PDF for compliance teams.

Security Investigation

“Did someone add themselves as an admin without authorization?”:
Review the log history to see all role changes for that member.

Debugging Permission Issues

“Why does Alice not have content:publish permission?”:

Admin Activity Review

“What did the new admin do in their first week?”:

Best Practices

Regular Audits

Schedule weekly or monthly reviews of audit logs to catch suspicious activity early.

Retention Strategy

  • Short retention (30 days): For compliance-sensitive data, delete quickly
  • Standard retention (90 days): Default for most organizations
  • Long retention (1 year): For highly regulated industries

Immutability Guarantee

Audit logs are guaranteed immutable. They cannot be:
  • Modified or edited
  • Deleted except by retention policy
  • Hidden from queries
This makes them trustworthy for compliance purposes.

IP Address Logging

Logs capture the requester’s IP address for security investigations:
Use this to detect unauthorized access patterns or geographic anomalies.

API Pagination

Audit logs support pagination to handle large result sets efficiently:
Response includes:
Use total to calculate how many pages exist: Math.ceil(total / pageSize).

Error Handling

Insufficient Permissions

Only members of the organization can view audit logs.

Invalid Filter

Ensure dates are in ISO 8601 format and logically ordered.

Organization Not Found

Verify the organization ID is correct.