Skip to main content

Integrate a site

Integrate a site​

  1. Your backend, after its own sign-in, calls POST /v1/subscriber-tokens with the secret key and your user id, and gives the token to the browser.
  2. Serve a one-line sw.js from your origin: importScripts('/sw-core.js').
  3. In the browser:
import { createClient } from '@notification-service/sdk';
const ns = createClient({ apiBase, publishableKey, getToken });
await ns.subscribe(); // call straight from a click handler
await ns.completeProfile({ timezone });
await ns.createEnrolment({ topicId, slots: [{ day: 1, time: '07:00' }], timezone, endDate: '2026-12-31' });
  1. Load messages with POST /v1/topics/:id/items:import using the secret key.