Optimistic Mutations

Instant local writes via realtime.mutate

realtime.mutate writes through Zero for instant local updates. The mutation is applied optimistically — your UI updates immediately, then the server confirms or rebases.

import { setup, realtime } from '@start-chat/sdk'
await setup({ apiKey: 'sk_live_your_api_key' })
await realtime.mutate.message.send({
channelId: 'ch_...',
content: 'This updates instantly',
})

The API matches mutate.* exactly — same resources, same actions, same parameters. The difference: mutate.* is a REST call that waits for server confirmation; realtime.mutate.* applies locally first, then syncs.

Mutations are grouped by resource: realtime.mutate.{resource}.{action}(params).

message

Send, edit, and delete messages

message.send

Send a message to a channel. Optionally target a thread or reply to another message.

ParameterTypeRequiredDescription
serverIdstringYes
threadIdstringNo
channelIdstringYes
contentstringYes
replyingToIdstringNo
await realtime.mutate.message.send({
serverId: 'srv_...',
channelId: 'ch_...',
content: 'Hello from the SDK',
})

message.delete

Permanently delete a message by ID.

ParameterTypeRequiredDescription
idstringYes
await realtime.mutate.message.delete({ id: '...' })

thread

Message threads

thread.insert

Create a new thread attached to a channel.

ParameterTypeRequiredDescription
idstringYes
channelIdstringYes
serverIdstringYes
titlestringNo
await realtime.mutate.thread.insert({
id: '...',
channelId: 'ch_...',
serverId: 'srv_...',
})

thread.updateTitle

Update the title of an existing thread.

ParameterTypeRequiredDescription
threadIdstringYes
contentstringYes
await realtime.mutate.thread.updateTitle({
threadId: 'thr_...',
content: 'Updated thread title',
})

reaction

Emoji reactions

reaction.insert

Add an emoji reaction to a message.

ParameterTypeRequiredDescription
idstringYes
messageIdstringYes
contentstringYes
await realtime.mutate.reaction.insert({
id: '...',
messageId: 'msg_...',
content: 'thumbsup',
})

reaction.delete

Remove a reaction by ID.

ParameterTypeRequiredDescription
idstringYes
await realtime.mutate.reaction.delete({ id: '...' })

indicator

Typing indicators

indicator.insert

Create a typing indicator for real-time presence.

ParameterTypeRequiredDescription
serverIdstringNo
channelIdstringNo
threadIdstringNo
typestringYes
lastActiveAtnumberNo
await realtime.mutate.indicator.insert({ type: '...' })

indicator.update

Update the last active time of an indicator.

ParameterTypeRequiredDescription
idstringYes
lastActiveAtnumberNo
await realtime.mutate.indicator.update({ id: '...' })

indicator.delete

Remove a typing indicator.

ParameterTypeRequiredDescription
idstringYes
await realtime.mutate.indicator.delete({ id: '...' })

secret

App secrets and API keys

secret.set

Store a secret value (API key, token) for an installed app.

ParameterTypeRequiredDescription
appInstallIdstringYes
serverIdstringYes
keystringYes
valuestringYes
await realtime.mutate.secret.set({
appInstallId: 'ai_...',
serverId: 'srv_...',
key: 'API_TOKEN',
value: 'secret_value',
})

secret.delete

Delete a stored secret by key.

ParameterTypeRequiredDescription
appInstallIdstringYes
serverIdstringYes
keystringYes
await realtime.mutate.secret.delete({
appInstallId: 'ai_...',
serverId: 'srv_...',
key: 'API_TOKEN',
})

channel

Create and manage channels

channel.insert

Create a new channel in a server.

ParameterTypeRequiredDescription
serverIdstringYes
namestringYes
descriptionstringYes
await realtime.mutate.channel.insert({
serverId: 'srv_...',
name: 'my-channel',
description: 'Channel description',
})

channel.update

Update channel properties (name, description, etc.).

ParameterTypeRequiredDescription
idstringYes
namestringNo
descriptionstringNo
await realtime.mutate.channel.update({ id: '...' })

channel.delete

Delete a channel and all its contents.

ParameterTypeRequiredDescription
idstringYes
await realtime.mutate.channel.delete({ id: '...' })

pin

Pinned messages

pin.insert

Pin a message in a channel.

ParameterTypeRequiredDescription
serverIdstringNo
channelIdstringYes
messageIdstringYes
await realtime.mutate.pin.insert({ channelId: 'ch_...', messageId: 'msg_...' })

pin.delete

Unpin a message.

ParameterTypeRequiredDescription
idstringYes
await realtime.mutate.pin.delete({ id: '...' })

role

Roles and permissions

role.insert

Create a new role with permissions.

ParameterTypeRequiredDescription
namestringYes
colorstringYes
serverIdstringNo
await realtime.mutate.role.insert({ name: 'Moderator', color: '#3B82F6' })

role.update

Update role name, color, or permissions.

ParameterTypeRequiredDescription
idstringYes
namestringNo
colorstringNo
await realtime.mutate.role.update({ id: '...' })

role.delete

Delete a role.

ParameterTypeRequiredDescription
idstringYes
await realtime.mutate.role.delete({ id: '...' })

serverMember

Server membership

serverMember.delete

Remove (kick) a member from the server.

ParameterTypeRequiredDescription
idstringYes
await realtime.mutate.serverMember.delete({ id: '...' })