TRAILBASE|DOCUMENTATION

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:

  1. Go to Settings in the left sidebar
  2. Click API Keys tab
  3. Click Generate New API Key
  4. Copy the key (it won't be shown again!)
  5. 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:

  1. Navigate to Audit Logs in your dashboard
  2. You should see the user.login event
  3. 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 tenantId matches 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.email field is required
  • Invalid outcome: Must be one of: success, failure, or denied
  • 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.ai is accessible from your environment
  • Consider increasing the maxRetries configuration option

Need Help?

Join our Discord community or email trailbase@frozo.ai for assistance.

Edit this page on GitHub