Skip to main content
BunShip records every significant action in an append-only audit log. Each entry captures who did what, when, and what changed — providing a full trail for debugging, compliance, and security reviews.

What Gets Logged

Every audit log entry contains these fields:

Example entry

Creating Audit Log Entries

The audit service provides typed helper methods for different actor types.

User actions

API key actions

System actions

Querying Audit Logs

List audit logs with filters, pagination, and date ranges:

Available filters

Response format

The total field returns the full count of matching entries, so your frontend can calculate page numbers.

Filtering by date range

Log Retention

Audit logs are cleaned up automatically by the background jobs system. Retention periods depend on your plan: The cleanup worker runs weekly and removes entries older than the configured threshold:
Adjust the daysToKeep value in apps/api/src/jobs/index.ts to change the retention period.

Integration with Other Features

Audit logs are created automatically throughout BunShip. Here are the key integration points:

Authentication

Login attempts, password changes, 2FA setup, and session revocations are logged with the user’s IP address and user agent.

Team Management

Member invitations, role changes, and removals record both the actor and the affected member.

Billing

Subscription changes, checkout completions, and cancellations are logged as system actions triggered by Stripe webhooks.

API Keys

Key creation and revocation are logged. Requests authenticated with API keys use actorType: "api_key" for attribution.

Adding audit logs to custom routes

When building new features, add audit logging at the service layer:
The audit service catches and logs its own errors internally, so a failure to write an audit entry will not break the primary operation. Errors are printed to stderr and an InternalError is thrown, which the global error handler catches.