Getting Started with Trailbase
Add enterprise-grade audit logging to your application in under 5 minutes. This guide will walk you through installation, authentication, and sending your first audit event.
Prerequisites
- Node.js 18+ or compatible JavaScript runtime
- A Trailbase account (sign up at trailbase.frozo.ai)
- Basic familiarity with TypeScript/JavaScript
1Install the SDK
Install the Trailbase SDK using your preferred package manager:
npm install @trailbase/sdk
Also available with yarn add @trailbase/sdk or pnpm add @trailbase/sdk
2Get Your API Key
After signing up, navigate to your dashboard:
- Go to Settings in the left sidebar
- Click API Keys tab
- Click Generate New API Key
- Copy the key (it won't be shown again!)
- Store it securely in your environment variables
Security Best Practice
Never commit API keys to version control. Use environment variables or a secrets manager.
3Send Your First Event
Initialize the client and log your first audit event:
import { TrailbaseClient } from '@trailbase/sdk';
// Initialize the client
const trailbase = new TrailbaseClient({
apiKey: process.env.TRAILBASE_API_KEY!,
tenantId: 'your-tenant-id',
});
// Log an audit event
await trailbase.log({
action: 'user.login',
actor: {
id: 'user_123',
email: 'alice@acme.com',
ip: '192.168.1.1',
},
resource: {
type: 'session',
id: 'session_xyz',
},
outcome: 'success',
metadata: {
login_method: 'password',
mfa_enabled: true,
},
});
console.log('✓ Audit event logged successfully!');Expected Output
✓ Audit event logged successfully!
Event Queued for Batching
By default, events are batched automatically every 1 second or when 50 events are queued. This ensures high throughput with minimal latency.
4View in Dashboard
Your event will appear in the Trailbase dashboard within seconds:
- Navigate to Audit Logs in your dashboard
- You should see the
user.loginevent - Click on the event to view full details, including metadata and hash chain verification
The event includes a cryptographic hash linking it to the previous event, ensuring immutability.
5Next Steps
Now that you've logged your first event, explore these topics:
Core Concepts
Learn about audit events, RBAC, compliance frameworks, and security guarantees.
Read Concepts →Practical Guides
Step-by-step tutorials for common use cases like RBAC implementation and compliance automation.
Browse Guides →SDK Reference
Complete API reference for all SDK methods, configuration options, and type definitions.
View SDK Docs →Troubleshooting
Common Issues
Authentication Failed
If you receive a 401 Unauthorized error, verify that:
- Your API key is correct and hasn't been revoked
- The
tenantIdmatches your account - You're passing the API key in the correct format
Event Validation Errors
Events must include required fields. Common validation errors:
- Missing actor.email: The
actor.emailfield is required - Invalid outcome: Must be one of:
success,failure, ordenied - Metadata too large: Metadata must be under 64KB
Network Timeouts
The SDK automatically retries failed requests up to 3 times with exponential backoff. If you're experiencing persistent timeouts:
- Check your network connectivity
- Verify that
https://api.trailbase.frozo.aiis accessible from your environment - Consider increasing the
maxRetriesconfiguration option
Need Help?
Join our Discord community or email trailbase@frozo.ai for assistance.