Skip to content

API Reference

Client

new OpenSlaq(options)

Create a new SDK client.

import { OpenSlaq } from "openslaq";
const client = new OpenSlaq({
apiKey: "osk_xxxxxxxxxxxxx",
workspaceSlug: "my-workspace", // optional
});
OptionTypeDescription
apiKeystringAPI key — must start with osk_ (required)
baseUrlstringAPI base URL (default: https://api.openslaq.com)
workspaceSlugstringWorkspace to operate on (default: "default")
fetchtypeof globalThis.fetchCustom fetch implementation (optional)

Messages

client.messages.send(channelId, options)

Send a message to a channel.

const message = await client.messages.send("ch_abc123", {
content: "Hello, world!",
attachmentIds: ["att_xyz789"], // optional
});
OptionTypeDescription
contentstringMessage content (required)
attachmentIdsstring[]File attachment IDs (optional)

client.messages.list(channelId, options?)

List messages in a channel.

const { messages, nextCursor } = await client.messages.list("ch_abc123", {
limit: 50,
direction: "older",
});
OptionTypeDescription
cursorstringPagination cursor (optional)
limitnumberNumber of messages to return (optional)
direction"older" | "newer"Pagination direction (optional)

client.messages.get(messageId)

Get a single message by ID.

const message = await client.messages.get("msg_abc123");

client.messages.edit(messageId, options)

Edit an existing message.

const updated = await client.messages.edit("msg_abc123", {
content: "Updated content",
});
OptionTypeDescription
contentstringNew message content (required)

client.messages.delete(messageId)

Delete a message.

await client.messages.delete("msg_abc123");

client.messages.reply(channelId, parentMessageId, options)

Reply to a message in a thread.

const reply = await client.messages.reply("ch_abc123", "msg_parent456", {
content: "Thread reply!",
});
OptionTypeDescription
contentstringReply content (required)
attachmentIdsstring[]File attachment IDs (optional)

client.messages.listReplies(channelId, parentMessageId, options?)

List replies in a thread.

const { messages, nextCursor } = await client.messages.listReplies(
"ch_abc123",
"msg_parent456",
{ limit: 25 },
);
OptionTypeDescription
cursorstringPagination cursor (optional)
limitnumberNumber of replies to return (optional)
direction"older" | "newer"Pagination direction (optional)

client.messages.toggleReaction(messageId, emoji)

Toggle a reaction on a message. Adds the reaction if not present, removes it if already added.

const { reactions } = await client.messages.toggleReaction("msg_abc123", "thumbsup");

client.messages.pin(channelId, messageId)

Pin a message to a channel.

await client.messages.pin("ch_abc123", "msg_abc123");

client.messages.unpin(channelId, messageId)

Unpin a message from a channel.

await client.messages.unpin("ch_abc123", "msg_abc123");

client.messages.listPinned(channelId)

List all pinned messages in a channel.

const { messages } = await client.messages.listPinned("ch_abc123");

client.messages.getPinCount(channelId)

Get the number of pinned messages in a channel.

const { count } = await client.messages.getPinCount("ch_abc123");

client.messages.save(channelId, messageId)

Save a message for later.

await client.messages.save("ch_abc123", "msg_abc123");

client.messages.unsave(channelId, messageId)

Remove a message from saved items.

await client.messages.unsave("ch_abc123", "msg_abc123");

client.messages.listSaved()

List all saved messages across the workspace.

const { messages } = await client.messages.listSaved();
// [{ message, channelName, savedAt }]

client.messages.listSavedIds()

Get just the IDs of saved messages (useful for checking save state).

const { messageIds } = await client.messages.listSavedIds();

client.messages.share(channelId, options)

Share an existing message into a channel.

const message = await client.messages.share("ch_abc123", {
sharedMessageId: "msg_xyz789",
comment: "Check this out!", // optional
});
OptionTypeDescription
sharedMessageIdstringID of the message to share (required)
commentstringComment to include with the share (optional)

client.messages.getAround(channelId, messageId)

Get messages surrounding a specific message (useful for jump-to-message).

const result = await client.messages.getAround("ch_abc123", "msg_abc123");
// { messages, targetFound, olderCursor, newerCursor, hasOlder, hasNewer }

Scheduled Messages

client.scheduledMessages.create(options)

Schedule a message for future delivery.

const scheduled = await client.scheduledMessages.create({
channelId: "ch_abc123",
content: "Good morning team!",
scheduledFor: "2026-03-15T09:00:00Z",
attachmentIds: [], // optional
});
OptionTypeDescription
channelIdstringTarget channel (required)
contentstringMessage content (required)
scheduledForstringISO 8601 delivery time (required)
attachmentIdsstring[]File attachment IDs (optional)

client.scheduledMessages.list()

List all scheduled messages. Returns messages with channel names.

const scheduled = await client.scheduledMessages.list();
// [{ id, channelId, channelName, content, scheduledFor, status, ... }]

client.scheduledMessages.get(id)

Get a single scheduled message by ID.

const scheduled = await client.scheduledMessages.get("sched_abc123");

client.scheduledMessages.update(id, options)

Update a pending scheduled message.

const updated = await client.scheduledMessages.update("sched_abc123", {
content: "Updated content",
scheduledFor: "2026-03-16T09:00:00Z",
});
OptionTypeDescription
contentstringNew message content (optional)
attachmentIdsstring[]New attachment IDs (optional)
scheduledForstringNew delivery time (optional)

client.scheduledMessages.delete(id)

Delete a scheduled message.

await client.scheduledMessages.delete("sched_abc123");

client.scheduledMessages.countByChannel(channelId)

Get the number of scheduled messages for a channel.

const { count } = await client.scheduledMessages.countByChannel("ch_abc123");

Channels

client.channels.list()

List channels the current user has joined.

const channels = await client.channels.list();

client.channels.browse(options?)

Browse all channels in the workspace, including ones you haven’t joined.

const channels = await client.channels.browse({
includeArchived: true,
});
OptionTypeDescription
includeArchivedbooleanInclude archived channels (optional)

Returns channels with an isMember field indicating membership.

client.channels.create(options)

Create a new channel.

const channel = await client.channels.create({
name: "my-channel",
description: "A new channel",
type: "public",
});
OptionTypeDescription
namestringChannel name (required)
descriptionstringChannel description (optional)
type"public" | "private"Channel type (optional)

client.channels.update(id, options)

Update a channel.

const channel = await client.channels.update("ch_abc123", {
description: "Updated description",
});
OptionTypeDescription
descriptionstringNew channel description (optional)

client.channels.archive(id)

Archive a channel.

await client.channels.archive("ch_abc123");

client.channels.unarchive(id)

Unarchive a channel.

await client.channels.unarchive("ch_abc123");

client.channels.join(id)

Join a channel.

await client.channels.join("ch_abc123");

client.channels.leave(id)

Leave a channel.

await client.channels.leave("ch_abc123");

client.channels.listMembers(id)

List members of a channel.

const members = await client.channels.listMembers("ch_abc123");
// [{ id, displayName, email, avatarUrl, joinedAt }]

client.channels.addMember(id, userId)

Add a member to a channel.

await client.channels.addMember("ch_abc123", "usr_xyz789");

client.channels.removeMember(id, userId)

Remove a member from a channel.

await client.channels.removeMember("ch_abc123", "usr_xyz789");

client.channels.listStarred()

List channels the current user has starred.

const starred = await client.channels.listStarred();

client.channels.star(id)

Star a channel.

await client.channels.star("ch_abc123");

client.channels.unstar(id)

Unstar a channel.

await client.channels.unstar("ch_abc123");

client.channels.markRead(id)

Mark a channel as read.

await client.channels.markRead("ch_abc123");

client.channels.markUnread(id, options)

Mark a channel as unread starting from a specific message.

const { ok, unreadCount } = await client.channels.markUnread("ch_abc123", {
messageId: "msg_xyz789",
});
OptionTypeDescription
messageIdstringMessage to mark as the first unread (required)

client.channels.listNotificationPrefs()

List notification preferences for all channels.

const prefs = await client.channels.listNotificationPrefs();
// { "ch_abc123": "all", "ch_def456": "mentions" }

client.channels.getNotificationPref(id)

Get the notification preference for a specific channel.

const { level } = await client.channels.getNotificationPref("ch_abc123");

client.channels.setNotificationPref(id, options)

Set the notification preference for a channel.

await client.channels.setNotificationPref("ch_abc123", {
level: "mentions",
});
OptionTypeDescription
levelChannelNotifyLevelNotification level (required)

Users

client.users.me()

Get the current authenticated user.

const user = await client.users.me();

client.users.updateMe(options)

Update the current user’s profile.

const user = await client.users.updateMe({
displayName: "New Name",
avatarUrl: "https://example.com/avatar.png",
});
OptionTypeDescription
displayNamestringDisplay name (optional)
avatarUrlstringAvatar URL (optional)

client.users.setStatus(options)

Set the current user’s status.

await client.users.setStatus({
emoji: "🏖️",
text: "On vacation",
expiresAt: "2026-03-15T00:00:00Z",
});
OptionTypeDescription
emojistringStatus emoji (optional)
textstringStatus text (optional)
expiresAtstringISO 8601 expiration date (optional)

client.users.clearStatus()

Clear the current user’s status.

await client.users.clearStatus();

Direct Messages

client.dms.open(userId)

Open a DM channel with a user. Creates the channel if it doesn’t exist.

const { channel, otherUser } = await client.dms.open("usr_abc123");

client.dms.list()

List all DM channels for the current user.

const dms = await client.dms.list();
// [{ channel, otherUser: { id, displayName, email, avatarUrl } }]

Files

client.files.upload(options)

Upload one or more files.

const { attachments } = await client.files.upload({
files: myFile, // File or File[]
});
OptionTypeDescription
filesFile | File[]File(s) to upload (required)

client.files.getDownloadUrl(attachmentId)

Get a download URL for an attachment.

const url = await client.files.getDownloadUrl("att_abc123");

client.files.browse(options?)

Browse uploaded files.

const { files, nextCursor } = await client.files.browse({
channelId: "ch_abc123",
category: "images",
limit: 20,
});
OptionTypeDescription
channelIdstringFilter by channel (optional)
categoryFileCategoryFilter by file category (optional)
cursorstringPagination cursor (optional)
limitnumberNumber of files to return (optional)

client.search.query(options)

Search messages across the workspace.

const results = await client.search.query({
q: "deployment issue",
channelId: "ch_abc123",
fromDate: "2026-03-01",
limit: 10,
});
OptionTypeDescription
qstringSearch query (required)
channelIdstringFilter by channel (optional)
userIdstringFilter by author (optional)
fromDatestringStart date filter (optional)
toDatestringEnd date filter (optional)
offsetnumberPagination offset (optional)
limitnumberNumber of results (optional)

Error Handling

The SDK throws typed errors for API failures.

import { OpenSlaqApiError } from "openslaq";
try {
await client.messages.get("msg_nonexistent");
} catch (err) {
if (err instanceof OpenSlaqApiError) {
console.error(err.status); // 404
console.error(err.errorMessage); // "Not found"
}
}
ClassPropertiesDescription
OpenSlaqErrormessageBase error class
OpenSlaqApiErrorstatus, errorMessageAPI error with HTTP status code