Skip to main content

SOAT SDK

@soat/sdk is a TypeScript client for the SOAT REST API, generated from the OpenAPI specs; every endpoint, parameter, and response body is typed.

Installation​

npm install @soat/sdk
# or
pnpm add @soat/sdk

Create one SoatClient and reuse it:

import { SoatClient } from '@soat/sdk';

const soat = new SoatClient({
baseUrl: 'https://your-soat-server.com',
token: 'your-bearer-token',
});
OptionTypeRequiredDescription
baseUrlstringNoServer base URL (e.g. https://api.example.com). Defaults to the current origin.
tokenstringNoBearer token — JWT session token or sk_-prefixed API key.
headersRecord<string, string>NoAdditional headers merged into every request.

Calling Methods​

Each resource is a property on SoatClient (soat.actors, soat.users, soat.files):

const { data, error } = await soat.actors.listActors();
FieldWhen to useExample
pathURL path parameterspath: { actor_id: 'actor_...' }
queryQuery string parametersquery: { limit: 10 }
bodyRequest body (POST/PUT/PATCH)body: { name: 'Bot', type: 'ai' }

Body and query fields use the REST field names; path parameters use the URL template's names (actor_id, project_id, file_id, conversation_id):

// Path param
const { data } = await soat.actors.getActor({
path: { actor_id: 'actor_...' },
});

// POST with body (fields use snake_case)
const { data } = await soat.actors.createActor({
body: { name: 'Support Bot', external_id: '+15551234567' },
});

Error Handling​

Every call returns { data, error, response }; when error is set, data is undefined:

const { data, error } = await soat.users.listUsers();

if (error) {
throw new Error(`API error: ${JSON.stringify(error)}`);
}

console.log(data); // fully typed

Authentication​

// JWT token
const soat = new SoatClient({ baseUrl, token: sessionToken });

// API key
const soat = new SoatClient({ baseUrl, token: 'sk_...' });

Low-level API — Static Service Classes​

The generated static classes (Actors, Users, Files, etc.) take a client on every call, for per-request auth overrides or custom fetch implementations:

import { Actors, createClient, createConfig } from '@soat/sdk';

const client = createClient(
createConfig({
baseUrl: 'https://your-soat-server.com',
headers: { Authorization: 'Bearer sk_...' },
})
);

const { data, error } = await Actors.listActors({ client });

Full method list: Services Reference.