Skip to main content
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.

Install

The package ships dual CJS + ESM builds. Static types ship with the package.

Pick a class

Initialise

The SDK needs a publishable API key. Read Manage API keys for how to create one. Use pk_… 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.
The browser variants persist the anonymous ID for the duration of the page session. To carry an anonymous ID across page loads, pass it explicitly into 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. The SDK also converts JavaScript camelCase property names to snake_case before sending, so calling identify({ externalId: 'u_42', timezone: 'Australia/Sydney' }) puts external_id and timezone on the wire.

Errors

Failed requests throw an Error 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.
Quote the 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,https to 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.com to 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.