The JavaScript SDK covers two related surfaces: device registration (so you can target the user with push) and in-app notifications (so you can render messages inside the page).Documentation Index
Fetch the complete documentation index at: https://docs.spotzee.com/llms.txt
Use this file to discover all available pages before exploring further.
Register a device
registerDevice records a device against the current user. The os field tells Spotzee what kind of surface this is. For browser tracking you can register without a push token; for web push you pass the subscription token.
| Field | Notes |
|---|---|
deviceId | Stable identifier you generate and store yourself. UUID v4 is fine. |
os | web, ios, android. The mobile SDKs set this for you; in JS you set it. |
model | Free-form string. Browser name (Chrome, Safari) is a useful default. |
appBuild | Free-form. Often a calendar version or commit SHA. |
appVersion | Free-form. Often a semver string. |
token is optional. Without it, the call still records the device against the user (useful for cross-device tracking and per-device journey logic) but won’t deliver push to it.
You must have called identify, or pass anonymousId / externalId explicitly, before registerDevice succeeds.
Web push
The SDK does not implement the Web Push API itself. You wire up the standard browser primitives, ask the user for permission, subscribe to a service worker, and pass the resulting subscription endpoint intoregisterDevice as token. The full flow:
- Register a service worker that handles
pushevents. - Call
Notification.requestPermission()from a user gesture. - Subscribe via
serviceWorkerRegistration.pushManager.subscribe({ userVisibleOnly: true, applicationServerKey: '<your VAPID public key>' }). - Send the subscription’s endpoint, keys, and
authto your backend. - Pass that subscription identifier as
tokenintoSpotzee.registerDevice({ os: 'web', token, … }).
Fetch in-app notifications
Notifications targeted at the user via campaigns or journeys land in a queue you read withgetNotifications. The SDK does not render them; you decide when and how.
title, body, and an optional custom map. The alert and html types also carry an html field with the rendered markup; alert adds an optional image URL.
Mark a notification read
CallmarkNotificationRead once the user dismisses or acknowledges the notification. The platform stops returning it from getNotifications after that.
BrowserClient, the cached externalId and anonymousId are passed automatically. For the bare Client, pass them as the second argument:
Worked example: fetch on app load, mark read on dismiss
Next steps
Set up push providers
Configure APN and FCM credentials before mobile or web push can deliver.
Typed API client
Server-side surface for higher-volume notification listing.