Send feedback

JavaScript SDK (server)

The server half of the SDK, @optiqstudio/track/server, for Node 20 or later, Deno, Bun and edge runtimes.

new Optiq#

TypeScript
new Optiq(options: { secretKey: string; baseUrl?: string; retries?: number })
NameTypeDescription
secretKeyrequiredstringThe source's secret key (sk_…). Throws if it is not one.
baseUrlstringDefault https://enterprise.optiq.studio
retriesnumberTries for a busy answer (429, 5xx or none). Default 3, with growing pauses.

optiq.track#

TypeScript
optiq.track(events: ServerEvent | ServerEvent[]): Promise<{ accepted: number; duplicates: number; rejected: { index: number; reason: string }[] }>

Sends one event or many; any number go 500 at a time. Each email and phone is hashed before it leaves, and an event_id is made for any event without one. A ServerEvent takes the fields on every event, plus:

NameTypeDescription
last_refstringThe tracked link that brought them, when you know it better than the browser did.
last_ref_atstring | DateWhen that link was pressed.
click_idsobjectgclid, fbclid, ttclid, wbraid or gbraid.

optiq.suggest and optiq.profile#

TypeScript
optiq.suggest(o: { email?; phone?; person_hash?; visitor_id?; product?; exclude?: string[]; limit? }): Promise<{ suggestions; recentlyViewed }>
optiq.profile(who: { email?; phone?; person_hash?; visitor_id? }): Promise<Profile>

Suggestions for one customer across every device they used, and everything your company knows about them. The email or phone is hashed by Enterprise on arrival and not kept. See Personalise.

optiq.forget#

TypeScript
optiq.forget(who: { email?: string; phone?: string | number; person_hash?: string; visitor_id?: string }): Promise<{ deleted: number }>

Removes every event and visit of that person in your company, and of every browser they were seen on. Only the hash is sent.

Errors#

A refusal throws an OptiqError with the answer’s status and a sentence saying why. A bad key is 401, too many events in one call is 413, and an event that cannot be kept is listed in rejected instead. Busy answers are tried again first.

TypeScript
import { Optiq, OptiqError } from "@optiqstudio/track/server";

try {
  await optiq.track(events);
} catch (e) {
  if (e instanceof OptiqError && e.status === 401) alertTheTeam("The Optiq secret key was revoked.");
  else throw e;
}
Note: Each event_id counts once, so after any failure it is always safe to send the same events again.

Last updated 2026-11-04 UTC. The SDK is open source under the MIT licence. Tell us what is missing.