@notibase/node

npm install @notibase/node
import { Notibase } from "@notibase/node";
const nb = new Notibase(process.env.NOTIBASE_KEY);   // sk_live_...
Server keys only. The constructor throws if you hand it a ck_ key — those belong in browsers/apps with @notibase/web.

Messages

// Idempotent by default — a UUID key is attached unless you pass your own.
const { id, report } = await nb.messages.send({
  audience: { filter: { attr: "country", op: "in", value: ["NP", "IN"] } },
  content:  { title: "नमस्ते {{first_name | default: 'there'}} 👋" },
});

// Retry-safe by construction:
await nb.messages.send({ ..., idempotencyKey: `order-${order.id}-shipped` });

// Schedule:
await nb.messages.send({ ..., sendAt: new Date(Date.now() + 3600_000) });

// Debug any send — per-device timeline with raw provider responses:
const { deliveries } = await nb.messages.deliveries(id);

Users & targeting

await nb.users.upsert({
  external_id: "user-42",
  country: "NP",
  properties: { plan: "pro", signup_date: "2026-08-01" },
});

const { count } = await nb.segments.preview({
  and: [
    { attr: "properties.plan", op: "eq", value: "pro" },
    { attr: "last_seen_at", op: "within_last", value: "7d" },
  ],
});

const seg = await nb.segments.create({ name: "Active pros", filter: {…} });
await nb.messages.send({ audience: { segment_id: seg.id }, content: {…} });

Identity verification

import { signIdentify } from "@notibase/node";
// in the endpoint that serves your logged-in frontend:
const signature = signIdentify(process.env.NOTIBASE_IDENTIFY_SECRET, user.id);
// → frontend: nb.identify(user.id, { signature })

Errors

import { NotibaseError } from "@notibase/node";
try {
  await nb.messages.send({ … });
} catch (e) {
  if (e instanceof NotibaseError) {
    e.status;   // 429 → rate limit or quota; 403 → suspended/scope; 400 → validation
    e.body;     // response text
    e.path;     // which endpoint
  }
}

Devices (server-side registration)

Usually devices register from the client SDKs, but backfills/imports go server-side:

await nb.devices.register({ platform: "android", token: fcmToken });
const { devices } = await nb.devices.list();