Skip to content

Quickstart

This page covers installation, client initialization, and sending your first log. The entire integration takes under 5 minutes.

Terminal window
npm install @volidator/node

Create one client instance per application and reuse it. Initializing per-request is wasteful.

The apiKey authenticates requests to the ingestion worker. The encryptionKey is the AES-256-GCM key you generate to encrypt log payloads client-side before they leave your server (Volidator never holds this key).

You must generate a secure 32-byte (64 hex characters) key. You can generate one using:

Terminal window
node -e "const b=require('crypto').randomBytes(32);console.log('vol-dek-'+b.toString('hex'))"

Initialize the client like so:

import { VolidatorClient } from '@volidator/node';
export const volidator = new VolidatorClient({
apiKey: process.env.VOLIDATOR_API_KEY!,
encryptionKey: process.env.VOLIDATOR_ENCRYPTION_KEY!,
});

Store both values as environment secrets. Never commit them. Changing the encryption key later will make existing encrypted logs unreadable unless you use keyring rotation.

await volidator.log({
actor: 'user_abc123',
action: 'invoice.download',
target: 'invoice_789',
metadata: {
invoiceNumber: 'INV-2024-001',
amount: 4900,
},
});

log() returns true if the log was accepted by the ingestion worker, false otherwise. It does not throw.

Pass the HTTP request object directly. The SDK extracts IP, user-agent, and geolocation headers automatically.

// In a Next.js route handler / Express route:
await volidator.log({
actor: session.userId,
action: 'settings.update',
req: request,
});
  • Read Installation for the full constructor option table.
  • Read Telemetry to control what context data is collected.
  • Read PII Redaction if you need HIPAA or GDPR compliance out of the box.