Skip to main content
DOCS

SDK reference

The full surface: client, data, agents, realtime, auth, notifications, jobs, keys, and utilities.

Client

const client = new CodataClient({ apiKey | token | tokenFn, timeout?, retry?, cache? });

await client.listWorkspaces();
await client.getWorkspace(id);
await client.createWorkspace(name, description?);
await client.getMe();
await client.getOpenApiSpec(workspaceId);
const ws = client.workspace(workspaceId, { branch?, auth? });

Data

await ws.get(path, query?);      await ws.post(path, body?);
await ws.put(path, body?);       await ws.patch(path, body?);
await ws.delete(path);
await ws.operations();           // typed proxy keyed by operationId
await ws.listOperations();

Agents

const agent = ws.agent(name);

await agent.run(input, options?);      // submit + wait (poll) → AgentRun
await agent.submit(input, options?);   // 202 → { runId, status }
await agent.getRun(runId);
await agent.approve(runId);            // write-capable agents
await agent.reject(runId, reason?);
agent.eventsUrl(runId);                // SSE stream URL

AgentRunOptions: sessionId, startSession, endUserId, callbackUrl + callbackSecret (HMAC-signed webhook), idempotencyKey, pollIntervalMs, timeoutMs, signal.

AgentRun
{
  runId: string;
  status: "queued" | "running" | "succeeded" | "failed" | "cancelled" | "awaiting_approval";
  output: string | null;
  error: { code?, message? } | null;
  sessionId: string | null;
  usage?: { inputTokens?, outputTokens?, costUsd? };
}

Realtime

const rt = ws.realtime();

const conn = await rt.connect({ endUserId? });
const sub  = await conn.subscribe(channel);
sub.on(event | "*", handler);
await sub.publish(event, payload);
sub.unsubscribe();

await rt.publish(channel, event, payload);   // server-side push
await rt.presence(channel);                  // who's connected
await rt.getConnection({ endUserId? });      // token for non-JS clients

Auth (end users)

await ws.auth.signUp({ email, password });
await ws.auth.signIn({ email, password });
await ws.auth.signInAnonymously();
await ws.auth.startGoogleSignIn();
await ws.auth.getSession();
await ws.auth.logout();

Notifications & jobs

await ws.notifications.send({ eventId, to, variables? });
await ws.notifications.batch({ eventId, recipients: [{ to, variables? }] });

await ws.jobs.run(jobId);
await ws.jobs.runs(jobId);
await ws.jobs.metrics();

API keys

const { plainTextKey } = await client.keys.create(workspaceId, "ci-key", "read-only");
await client.keys.list(workspaceId);
await client.keys.rotate(workspaceId, keyId);   // revoke old, mint new
await client.keys.revoke(workspaceId, keyId);

plainTextKey is shown exactly once — store it securely immediately.

Utilities

paginate / paginateAll
Async-iterate or collect every page of a collection.
batch
Run many requests with a concurrency limit.
healthCheck
Ping the platform, returns { healthy, latencyMs }.
validate
JSON-Schema validation helper.
createProxyMiddleware
Express middleware that proxies /api/* to a workspace.
retryWithBackoff / LRUCache
The retry & cache primitives the client uses, exported for reuse.