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
- Event Occurs — A role, team, or membership change happens
- Log Created — The change is recorded with actor, IP, timestamp, and details
- Stored Permanently — Log becomes immutable (read-only forever)
- Queryable — Admins can search by actor, resource, action, or date
- Cleaned Up — Logs older than retention period are deleted by cleanup job
Audit Actions (MVP)
| Action | Triggered By | Details |
|---|---|---|
member_role_assigned | Assign custom role to member | Before: [], After: [role_id] |
member_role_removed | Remove custom role from member | Before: [role_id], After: [] |
member_custom_roles_updated | Update multiple roles at once | Before: [old_ids], After: [new_ids] |
custom_role_created | Create a new custom role | Role name, permissions |
custom_role_updated | Modify custom role permissions | Before: [perms], After: [perms] |
custom_role_deleted | Delete a custom role | Role name, reason |
team_created | Create new team | Team name, description |
team_updated | Modify team metadata | Before: , After: |
team_deleted | Delete team | Team name |
team_role_assigned | Assign role to team | Role ID, Team ID |
team_role_removed | Remove role from team | Role ID, Team ID |
member_added_to_team | Add member to team | Member ID, Team ID |
member_removed_from_team | Remove member from team | Member ID, Team ID |
Querying Audit Logs
Basic Query
Get all audit logs for your organization:Filter by Actor
Find all changes made by a specific user:Filter by Resource
Track all changes to a specific role:role— Custom role changesteam— Team CRUD operationsmember— 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
| Field | Type | Description |
|---|---|---|
id | UUID | Immutable log ID (can be referenced externally) |
orgId | UUID | Organization ID |
actorId | UUID | User who made the change |
action | String | What happened (member_role_assigned, etc.) |
resourceType | String | Type of resource changed (role, team, member) |
resourceId | UUID | ID of resource that changed |
changes | Object | Before/after state comparison |
ipAddress | String | IP address of requester (for security audit) |
sessionContext | Object | Session details for compliance |
approvalStatus | String | Approval workflow status (future) |
approvalMetadata | Object | Approval details (future) |
orgRetentionDays | Integer | Retention policy in effect at log creation |
createdAt | Timestamp | When the change occurred |
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:Dry Run
Test cleanup without deleting:Common Use Cases
Compliance Audit
“Show me all role changes made in Q1 2026”:Security Investigation
“Did someone add themselves as an admin without authorization?”: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
IP Address Logging
Logs capture the requester’s IP address for security investigations:API Pagination
Audit logs support pagination to handle large result sets efficiently:total to calculate how many pages exist: Math.ceil(total / pageSize).