The JavaScript SDK ships three classes for three runtimes. Pick the one that matches where your code runs, install with your usual package manager, and initialise once with a publishable key.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.
Install
Pick a class
| Class | Runtime | Identity handling |
|---|---|---|
Client | Node, edge runtimes, server jobs | You pass anonymousId and / or externalId on every call |
BrowserClient | Web browsers (modern bundlers) | Mints an anonymous ID on first use, caches externalId after identify |
Spotzee | Browser script tag (window.Spotzee) | Static singleton wrapper around BrowserClient |
Initialise
The SDK needs a publishable API key. Read Manage API keys for how to create one. Usepk_… keys for client builds (browsers, mobile, anywhere the key is visible to end users). Server-side jobs that already have a backend can use either a publishable key for SDK flows or a secret key (sk_…) for the typed client.
track / identify from your own storage.
What every request carries
Every call the SDK makes adds these headers automatically. You don’t need to set them yourself.| Header | Value | Why |
|---|---|---|
Authorization | Bearer <your apiKey> | Authenticates the request |
Spotzee-Version | 2026-04-28 | Pins the API version this SDK release targets |
x-spotzee-client-type | sdk-js | Helps the platform attribute traffic by client type. Read Identify your API client type |
Content-Type | application/json | Set on POST and PUT requests |
identify({ externalId: 'u_42', timezone: 'Australia/Sydney' }) puts external_id and timezone on the wire.
Errors
Failed requests throw anError whose message includes the HTTP status, the API error code (when present), the human-readable message, and the request_id for support. The SDK parses the RFC 7807 envelope on 2026-04-28 and falls back to the legacy { error: string } shape across the cutover.
request_id when contacting support so the team can find the request in the platform logs.
Debugging
The SDK doesn’t ship a debug toggle. Use your runtime’s standard tools.- Node. Set
NODE_DEBUG=http,httpsto see outbound requests, or wrap the SDK call in a logging block. The SDK’s thrown error already contains everything support needs. - Browser. Use the network panel of your browser’s developer tools to inspect the request and response payloads. Filter by
apix.spotzee.comto isolate Spotzee traffic.
Next steps
Identify users
Link anonymous activity to a known user, set traits, and alias on sign-up.
Track events
Send custom events with properties to trigger journeys and segment users.
Devices and notifications
Register browser or web push tokens, fetch in-app notifications.
Typed API client
The full OpenAPI surface for server-side and agentic use.