Skip to content

SDK Overview

The @warmhub/sdk-ts package is the typed TypeScript client for WarmHub. It provides promise-based methods for managing organizations, repositories, and data (shapes, things, assertions). It also covers commits, workspaces, changesets, subscriptions, actions, and diagnostics.

See the SDK Quickstart for full install instructions. In short:

Terminal window
npm install @warmhub/sdk-ts

react is an optional peer dependency — only needed if you use @warmhub/sdk-ts/react.

Install the WarmHub CLI, then create a personal access token and export it as WARMHUB_TOKEN:

Terminal window
wh auth login
wh token create --name my-app
export WARMHUB_TOKEN=eyJhbGciOi...

Then create a client:

import { WarmHubClient } from '@warmhub/sdk-ts'
const client = new WarmHubClient({
auth: { getToken: async () => process.env.WARMHUB_TOKEN },
})
OptionTypeDescription
auth.getToken() => Promise<string | undefined>Token acquisition hook — required for authenticated endpoints
accessTokenstring | () => string | undefined | Promise<string | undefined>Static token or sync/async provider (alternative to auth.getToken)
apiUrlstringOverride the API URL (defaults to https://api.warmhub.ai)
fetchtypeof fetchCustom fetch implementation
functionLogs'raw' | 'off'Server function log forwarding (defaults to 'off')
Import pathDescription
@warmhub/sdk-tsCore client, types, errors, CommitBuilder
@warmhub/sdk-ts/reactReact provider and hooks for WarmHubClient and backend-ready auth state
@warmhub/sdk-ts/advancedLow-level AdvancedClient with WebSocket subscriptions
@warmhub/sdk-ts/testTest utilities (canonicalDataHash, validateAgainstShape)

For a comparison of when to use the SDK vs the CLI or MCP, see How to Get Started.

A surface is a property on the client that groups related methods for a domain (e.g., client.thing for reading things and assertions).

SurfaceDescriptionKey Methods
client.orgOrganization managementlist(), get(), create(), getOrCreate(), addMember(), removeMember(), listMembers(), changeMemberRole(), archive(), unarchive()
client.repoRepository managementlist(), get(), create(), resolve(), archive(), unarchive()
client.shapeSchema definitionslist(), get(), create(), revise(), remove()
client.thingRead things and assertionshead(), get(), query(), about(), refs(), resolve(), search(), history(), count()
client.commitAtomic writesapply(), log()
client.workspaceWorkspace isolationcreate(), list(), get(), remove(), status(), validate(), rebase(), revert(), discard()
client.changesetChangeset reviewpublish(), list(), get(), accept(), reject(), withdraw(), validate()
client.subscriptionWebhook/sprite subscriptionscreate(), update(), list(), get(), pause(), resume(), remove()
client.actionsAction lease coordinationacquireLease(), claimDelivery(), completeDelivery(), liveFeed()
client.diagnosticsHealth and capabilitiesping(), capabilities()

Two lightweight access methods are available for frontend UI gating. They return boolean on success. Like all SDK methods, they throw WarmHubError on network, backend, or auth failures.

MethodArgsDescription
client.access.checkRepoPermissionorgName, repoName, permissionCheck whether the caller has a repo-scoped permission (e.g., "things:write")
client.access.checkOrgPermissionorgName, permissionCheck whether the caller has an org-scoped permission
const canWrite = await client.access.checkRepoPermission(
'acme',
'world',
'things:write',
)

The React app wraps these with TanStack Query hooks. Under the hood they use the same auth and permission resolution as the rest of the WarmHub API.

All SDK methods throw WarmHubError on failure. Use isWarmHubError() and isRetryable() for error handling:

import { isRetryable, isWarmHubError } from '@warmhub/sdk-ts'
try {
await client.repo.get('acme', 'world')
} catch (err) {
if (isWarmHubError(err) && err.kind === 'NOT_FOUND') {
// handle missing repo
}
if (isRetryable(err)) {
// safe to retry (NETWORK, CANCELLED, BACKEND, RATE_LIMITED)
}
throw err
}

Error kinds: NOT_FOUND, VALIDATION, CONFLICT (includes ALREADY_EXISTS and ARCHIVED), UNAUTHENTICATED, FORBIDDEN, RATE_LIMITED, CANCELLED, NETWORK, BACKEND.