SDK
@workstudio-inc/sdk is a headless client for the embed API. No UI, no framework — wrap it in whatever you already use.
Install
npm install @workstudio-inc/sdk
yarn add @workstudio-inc/sdk
pnpm add @workstudio-inc/sdk
Works in Node 18+ and in browsers. TypeScript types are included.
On your server
Authenticate with your embed key and act on behalf of a customer:
import { IntegrationsClient } from '@workstudio-inc/sdk';
const client = new IntegrationsClient({
apiKey: process.env.WORKSTUDIO_EMBED_KEY,
tenantId: process.env.WORKSTUDIO_TENANT_ID,
scopeKey: 'customer:acme',
});
const { integrations } = await client.listIntegrations();
The main reason to construct a server client is to mint tokens for the browser:
const { token, expiresAt } = await client.mintSessionToken('customer:acme', { ttlSeconds: 900 });
In the browser
Pass the session token your server minted. Never the embed key.
import { IntegrationsClient } from '@workstudio-inc/sdk';
const client = new IntegrationsClient({ token, tenantId });
// The customer scope is inside the signed token — you don't pass scopeKey here.
const { integrations } = await client.listIntegrations();
const activation = await client.activate('slack');
Connect button
The browser entry point handles the OAuth popup for you:
It opens the provider's authorisation page, waits for the callback, and resolves with the refreshed activation.
Methods
Catalog
Activations
Connections and OAuth
Session tokens
Connector operations
const res = await client.execute(githubConnectorId, 'issues/create', {
owner: 'acme',
repo: 'platform',
title: 'Nightly sync failed',
});
if (res.ok) console.log(res.data);
The call uses that customer's own connection. Credentials never leave the platform — you send the input and get the upstream answer back.
ok is the upstream system's verdict, not ours
A 404 from the target system arrives as ok: false, status: 404 with the body in data; it does not throw. Platform-side failures — no connection for this customer, unknown operation, missing permission — throw IntegrationsApiError.
Connections
AI assistant access
Requires 0.2.0
The methods in these three sections landed in @workstudio-inc/sdk 0.2.0. On 0.1.0 they don't exist — check your installed version if one is undefined.
Configuration
Provide either apiKey or token. The constructor throws if you provide neither.
Errors
Failed calls throw IntegrationsApiError with status and the server's message. Configuration problems throw IntegrationsConfigError.
import { IntegrationsApiError } from '@workstudio-inc/sdk';
try {
await client.activate('slack');
} catch (err) {
if (err instanceof IntegrationsApiError && err.status === 401) {
// Session token expired — fetch a new one from your server
}
}
Next steps
- Authentication — tokens, scopes and origins
- Web component — the no-code route
Something not behaving as described? support@work.studio