Documentation Index
Fetch the complete documentation index at: https://docs.nusomi.com/llms.txt
Use this file to discover all available pages before exploring further.
Targets Node 18+ and modern bundlers. ESM + CJS exports. Zero runtime dependencies beyond undici.
Client
import { Nusomi } from "@nusomi/sdk";
const nusomi = new Nusomi({
apiKey: process.env.NUSOMI_API_KEY,
baseUrl: "https://api.nusomi.com", // override for self-hosted
timeout: 30_000,
fetch: customFetch, // optional; defaults to global fetch
});
| Option | Default | Notes |
|---|
apiKey | process.env.NUSOMI_API_KEY | Required at construction or via env. |
baseUrl | https://api.nusomi.com | Override for self-hosted. |
timeout | 30_000 | Per-request, milliseconds. |
maxRetries | 3 | Auto-retry on 408, 429, 5xx. |
fetch | global fetch | Inject for custom transport / interception. |
userAgent | nusomi-ts/<ver> | Customize for your service. |
Resources
The client exposes one resource per primitive:
nusomi.sessions.*
nusomi.events.*
nusomi.frames.*
nusomi.replay.*
nusomi.recovery.*
nusomi.memory.*
nusomi.exports.*
nusomi.workflows.*
nusomi.webhooks.*
sessions
nusomi.sessions.create(input): Promise<Session>
nusomi.sessions.get(id): Promise<Session>
nusomi.sessions.list(filter?): AsyncIterable<Session>
nusomi.sessions.start(id): Promise<Session>
nusomi.sessions.stop(id): Promise<Session>
nusomi.sessions.tag(id, name, data?): Promise<void>
nusomi.sessions.delete(id): Promise<void>
Session is also a fluent object — await session.start(), await session.stop() work too.
events
nusomi.events.query(sessionId, filter?): Promise<Event[]>
nusomi.events.stream(sessionId, opts?): AsyncIterable<Event>
nusomi.events.emit(sessionId, type, payload): Promise<void>
frames
nusomi.frames.get(frameId): Promise<Frame>
nusomi.frames.image(frameId): Promise<Blob>
nusomi.frames.list(sessionId, filter?): AsyncIterable<Frame>
replay
nusomi.replay.exact(sessionId, opts?): Promise<Replay>
nusomi.replay.guided(sessionId, opts?): Promise<Replay>
nusomi.replay.partial(sessionId, opts): Promise<Replay>
recovery
nusomi.recovery.from(sessionId, opts?): Promise<Replay>
memory
nusomi.memory.paths(filter): Promise<Path[]>
nusomi.memory.outliers(filter): Promise<Session[]>
nusomi.memory.similar(sessionId, opts?): Promise<Session[]>
nusomi.memory.recoveryPoints(filter): Promise<Frame[]>
nusomi.memory.onDrift(workflow, handler): Subscription
exports
nusomi.exports.create(input): Promise<Export>
nusomi.exports.get(id): Promise<Export>
nusomi.exports.list(filter?): AsyncIterable<Export>
webhooks
nusomi.webhooks.list(): Promise<Webhook[]>
nusomi.webhooks.create(input): Promise<Webhook>
nusomi.webhooks.delete(id): Promise<void>
list(...) returns an AsyncIterable. Use for await:
for await (const s of nusomi.sessions.list({ workflow: "process_invoice" })) {
console.log(s.id, s.duration_ms);
}
The SDK pages under the hood with a default page size of 100. Pass pageSize to override.
Errors
All API errors throw NusomiError:
import { NusomiError } from "@nusomi/sdk";
try {
await nusomi.sessions.create({ workflow: "..." });
} catch (e) {
if (e instanceof NusomiError) {
console.error(e.code, e.message, e.requestId);
if (e.code === "rate_limited") await sleep(e.retryAfterMs);
}
}
See the errors reference for the full code table.
Streaming
Events stream as Server-Sent Events. The SDK exposes them as an async iterator:
const stream = nusomi.events.stream(sessionId, {
types: ["click", "validation_error"],
});
for await (const ev of stream) {
console.log(ev.t_ms, ev.type, ev.payload);
}
The stream auto-reconnects with Last-Event-ID on transient failure. To stop:
TypeScript types
Every resource is fully typed. Import directly:
import type {
Session,
Frame,
Event,
ClickEvent,
Replay,
Export,
} from "@nusomi/sdk";
Discriminated unions are used for event payloads:
function handle(ev: Event) {
switch (ev.type) {
case "click":
console.log(ev.payload.x, ev.payload.y); // typed
break;
case "validation_error":
console.log(ev.payload.field, ev.payload.message);
break;
}
}
Logging
Pass a logger:
new Nusomi({
apiKey: ...,
logger: {
debug: (...a) => myLogger.debug(...a),
info: (...a) => myLogger.info(...a),
warn: (...a) => myLogger.warn(...a),
error: (...a) => myLogger.error(...a),
},
});