SDK Overview

TypeScript SDK for querying, mutating, and subscribing to start.chat data

The @start-chat/sdk package gives you typed access to start.chat data. Three modes depending on what you need:

ModeImportUse case
REST queriesquery.*One-shot reads, server-side scripts
REST mutationsmutate.*One-shot writes, server-side scripts
Realtimerealtime.subscribe / realtime.mutateLive data, optimistic updates

Install

Terminal

npm install @start-chat/sdk

Setup

import { setup, query, mutate } from '@start-chat/sdk'
await setup({ apiKey: 'sk_live_your_api_key' })

Config options

OptionTypeDefaultDescription
apiKeystringAPI key from Server Settings → API Keys. Format: sk_live_*
baseUrlstringhttps://start.chatCustom instance URL
zeroUrlstringhttps://zero.start.chatCustom Zero sync server URL

For local development, use sk_dev with baseUrl: 'http://localhost:7878' to auto-authenticate as admin.

Quick example

import { setup, query, mutate, realtime } from '@start-chat/sdk'
await setup({ apiKey: 'sk_live_your_api_key' })
// read
const channels = await query.channelsByServer({ serverId: 'srv_...' })
const messages = await query.channelMessages({
serverId: 'srv_...',
channelId: 'ch_...',
})
// write
await mutate.message.send({
channelId: 'ch_...',
content: 'Hello from the SDK',
})
// subscribe to live updates
import { channelMessages } from '@start-chat/sdk/queries'
const sub = realtime.subscribe(
channelMessages,
{ serverId: 'srv_...', channelId: 'ch_...' },
(messages) => {
console.info('Messages updated:', messages.length)
},
)
// later: sub.unsubscribe()

API surface

11 queries and 20 mutations across 9 resources, plus realtime subscriptions and optimistic mutations via Zero.

Using cURL

Every query and mutation is also available as a REST endpoint. See the API reference for cURL examples.

Terminal

curl -X POST https://start.chat/api/v1/messages \
-H "Authorization: Bearer sk_live_your_api_key" \
-H "Content-Type: application/json" \
-d '{"channelId": "ch_...", "content": "Hello from cURL!"}'