Dashboard

Node.js SDK

@sentriq/node is a server-only SDK — it holds a secret key and must never run in browser code. For browser-side tracking, see the Browser SDK.

Install

npm install @sentriq/node

Initialize

import { Sentriq } from '@sentriq/node';

const sentriq = new Sentriq({
  secretKey: process.env.SENTRIQ_SECRET_KEY!,
  // Optional. Defaults to the hosted Sentriq API.
  apiUrl: process.env.SENTRIQ_API_URL,
  // Optional. Defaults to 10000ms.
  timeoutMs: 10_000,
  // Optional. Automatic retries for idempotent GET requests only. Default 2.
  maxRetries: 2,
});

Resources

sentriq.events.retrieve(eventId)
sentriq.events.list(environmentId, params?)
sentriq.events.submitOutcome(eventId, { label: 'legitimate' })
sentriq.events.listOutcomes(eventId)

sentriq.devices.retrieve(deviceId)
sentriq.devices.list(environmentId)
sentriq.devices.listEvents(deviceId)
sentriq.devices.listAccounts(deviceId)
sentriq.devices.listSignals(deviceId)
sentriq.devices.listResolutions(deviceId)
sentriq.devices.trust(deviceId)
sentriq.devices.revokeTrust(deviceId)

sentriq.accounts.listDevices(environmentId, externalAccountId)

sentriq.risk.list(environmentId, params?)

sentriq.network.list(environmentId)

sentriq.webhooks.verifySignature(rawBody, timestamp, signature, secret)
No policies or webhook management here
There is no sentriq.policies and no sentriq.webhooks.create()/list()/update()/delete() — those API routes require an authenticated dashboard session, not a secret key, by design. webhooks.verifySignature() remains because it needs no API call at all — see Webhooks.

Errors

SentriqError                  (base — every error below extends this)
SentriqConfigurationError      bad SDK usage, caught before any request
SentriqNetworkError            the HTTP request itself failed
SentriqTimeoutError            exceeded the configured timeout
SentriqApiError                non-2xx not covered below
SentriqAuthenticationError     401
SentriqPermissionError         403
SentriqNotFoundError           404
SentriqValidationError         422 — .fields
SentriqRateLimitError          429 — .retryAfterSeconds
import { SentriqNotFoundError, SentriqError } from '@sentriq/node';

try {
  await sentriq.events.retrieve(eventId);
} catch (e) {
  if (e instanceof SentriqNotFoundError) {
    // e.requestId — include this when contacting support
  } else if (e instanceof SentriqError) {
    // catches everything else this SDK throws
  }
}

Retries

A GET request retries automatically (bounded, backoff) on a network error, timeout, 429, or 5xx. Mutations (POST/DELETE) are never automatically retried — this API has no generic idempotency-key mechanism today, so blindly retrying a mutation could double-apply it.