Getting Started
Install the alrt SDK and start sending notifications in under 5 minutes. One API key, 6+ channels, zero external account setup.
Installation
npm install @alrt/nodeInitialize the Client
Create an alrt client instance with your server API key. Get your key from the Settings page in the dashboard.
Constructor Options
Authentication
The SDK authenticates via your API key passed to the constructor. alrt supports two key types:
Keys are SHA-256 hashed before storage. The raw key is only shown once at creation time. Manage keys in the dashboard under Settings → API Keys.
Events
Events are the primary way to trigger notification workflows. Each event maps to a workflow you've built in the visual editor.
client.events.trigger(params)Trigger a notification workflow for a single subscriber. The workflow determines which channels to send on, applies templates, and executes any delay/condition nodes.
Promise<TriggerEventResponse>Parameters
Errors
client.events.triggerBulk(params)Trigger a workflow for up to 1,000 subscribers in a single request. Each subscriber is processed independently — partial failures don't block the batch.
Promise<TriggerBulkResponse>Parameters
Subscribers
Subscribers represent the people who receive your notifications. Each subscriber has channel-specific contact info and delivery preferences.
client.subscribers.create(params)Create a new subscriber with channel-specific contact information.
Promise<SubscriberResponse>Parameters
Errors
client.subscribers.get(subscriberId)Retrieve a subscriber by their external ID.
Promise<SubscriberResponse>Parameters
Errors
client.subscribers.list(params?)List subscribers with optional pagination.
Promise<SubscriberResponse[]>Parameters
client.subscribers.update(subscriberId, params)Update a subscriber's contact info or custom properties. Only provided fields are changed.
Promise<SubscriberResponse>Parameters
Errors
client.subscribers.delete(subscriberId)Permanently delete a subscriber and all their notification history.
Promise<void>Parameters
Errors
Preferences
Manage subscriber notification preferences — global channel opt-in/out, per-category settings, do-not-disturb windows, and frequency caps.
client.subscribers.getPreferences(subscriberId)Get the notification preferences for a subscriber.
Promise<PreferencesResponse>Parameters
client.subscribers.updatePreferences(subscriberId, prefs)Update notification preferences. Supports granular per-category and per-channel settings.
Promise<PreferencesResponse>Parameters
Push Tokens
Register and manage device push tokens for mobile and web push notifications via FCM/APNs.
client.subscribers.registerPushToken(subscriberId, params)Register a push notification token for a subscriber's device.
Promise<PushTokenResponse[]>Parameters
client.subscribers.listPushTokens(subscriberId)List all registered push tokens for a subscriber.
Promise<PushTokenResponse[]>Parameters
client.subscribers.removePushToken(subscriberId, token)Remove a specific push token from a subscriber (e.g., on logout or token rotation).
Promise<PushTokenResponse[]>Parameters
Error Handling
The SDK throws typed exceptions for all API errors. All errors extend AlrtError and include status, code, and message properties.
Exception Hierarchy
Automatic Retries
The SDK automatically retries requests that fail with 429 (rate limit) or 5xx (server error) status codes, using exponential backoff with jitter. Non-retryable errors (400, 401, 404, 409) are thrown immediately.
WebSocket (In-App Notifications)
For real-time in-app notifications, connect to the WebSocket endpoint using a subscriber-scoped JWT. This is a direct WebSocket connection — no SDK wrapper needed.
How it works
- Server-side: call
POST /subscribers/:id/tokento get a short-lived JWT - Client-side: connect to
ws://api.alrt.dev/ws?token=JWT - Receive real-time notification payloads as JSON messages