Integrations
Node.js SDK
@beacon-status/node is a typed client for the whole REST API, the incident ingest endpoints, heartbeat pings and webhook signature verification. Zero runtime dependencies (global fetch, Node 18+), ESM and CommonJS.
Not yet published to npm — install from GitHub for now.
npm cannot install a package from a subdirectory of a git repository, so install the standalone SDK repository by tag, or build a tarball with npm pack and install that.
Installation
# From GitHub, pinned to a release tag (builds on install)
npm install github:shaferllc/beacon-node#v1.0.0
# Or build a tarball yourself
git clone https://github.com/shaferllc/beacon-node.git
cd beacon-node && npm ci && npm pack # → beacon-status-node-1.0.0.tgz
cd /your/app && npm install /path/to/beacon-status-node-1.0.0.tgz
Once it is on npm this becomes npm install @beacon-status/node.
Initialization
import { Beacon } from '@beacon-status/node';
// const { Beacon } = require('@beacon-status/node');
const beacon = new Beacon({
token: process.env.BEACON_API_TOKEN, // bchk_… (Settings → API tokens)
baseUrl: 'https://usebeacon.pro', // optional
pageSlug: 'your-page-slug', // default page for the ingest helpers
});
Other options: timeoutMs (default 10000), maxRetries (default 2 — rate-limited requests are retried after Retry-After; server and network errors are retried for GET requests only) and fetch (a custom implementation).
Incidents and component status
const incident = await beacon.createIncident({
title: 'Payment processing delays',
impact: 'major',
state: 'investigating',
message: 'Stripe webhook delivery is delayed.',
component_ids: [12],
});
await beacon.addIncidentUpdate(incident.id, 'Fix deployed, monitoring.');
await beacon.resolveIncident(incident.id, 'Webhook delivery restored.');
await beacon.updateComponent(12, { status: 'degraded_performance' });
These call the ingest endpoints and return the same flat JSON (string ids) as the HTTP API.
REST resources
statusPages, components, monitors, incidents, maintenances, subscribers, webhooks and imports each expose list, iterate, get, create, update and delete (where the API allows them). Page-scoped resources take the page slug first; iterate() follows the cursor through every page.
const api = await beacon.components.create('acme', { name: 'API' });
await beacon.monitors.create('acme', {
name: 'API health',
type: 'http',
url: 'https://api.example.com/health',
allow_cold_start: true,
check_window_start: '08:00',
check_window_end: '20:00',
status_component_id: api.id,
});
for await (const incident of beacon.incidents.iterate('acme', { state: 'open' })) {
console.log(incident.title);
}
const hook = await beacon.webhooks.create('acme', { url: 'https://example.com/beacon' });
hook.secret; // returned once — store it
Heartbeats
import { pingHeartbeat } from '@beacon-status/node';
await processInvoices();
await pingHeartbeat('YOUR-HEARTBEAT-TOKEN', { baseUrl: 'https://usebeacon.pro' }); // no API token needed
Errors
import { BeaconError } from '@beacon-status/node';
try {
await beacon.components.create('acme', { name: '' });
} catch (err) {
if (err instanceof BeaconError) {
err.status; // 422
err.code; // 'validation_failed', 'rate_limited', 'plan_limit_reached', …
err.errors; // { name: ['…'] }
err.retryAfter; // seconds, on 429
}
}
Verifying webhooks
import express from 'express';
import { verifyWebhookSignature } from '@beacon-status/node';
app.post('/beacon', express.raw({ type: 'application/json' }), (req, res) => {
if (!verifyWebhookSignature(req.body, req.headers, process.env.BEACON_WEBHOOK_SECRET)) {
return res.sendStatus(403);
}
const event = JSON.parse(req.body.toString());
res.sendStatus(204);
});
Pass the raw body and the request headers. The comparison is constant-time and deliveries more than 300 seconds old are rejected (toleranceSeconds changes that). Webhook format
TypeScript types
Every API object and input is exported as a type (StatusPage, Component, Monitor, Incident, Maintenance, Subscriber, Webhook, Import, MonitorInput, …), written from the OpenAPI document.