Skip to main content
The chat module powers direct, group, and space conversations — sending and editing messages (with file attachments), managing members, reacting, and tracking read state. All actions are performed as the logged-in user.
Two list endpoints page by cursor, not page/limit: listConversations takes the opaque cursor the previous page returned, and listMessages pages before or after a message id. See each below.

listConversations

Lists the user’s conversations, newest activity first, with cursor pagination.
ConversationType | ConversationType[]
Only conversations of these types: any of "direct", "group", "space". Omitted, every type is listed.
string | null
pagination.nextCursor from the previous response, passed as returned; omit it (or pass null) for the first page. It is opaque: don’t build or parse it. One the server can’t read is rejected with 400 chat/invalid-cursor.
number
Page size. Defaults to 20, max 50.
Returns — Promise<CursorPaginatedResponse<ConversationPreview>>: { data: ConversationPreview[]; pagination: { nextCursor: string | null; hasMore: boolean } }. nextCursor is null when hasMore is false. A ConversationPreview is the conversation’s own fields plus:
  • unreadCount and memberCount (active members).
  • mutedUntil and mutedForever: the user’s mute on the conversation (see muteConversation).
  • otherMembers — up to 5 active members other than the current user (id, name, username, avatar) for direct/group conversations, so a DM/group can render the counterparty without a separate members fetch. Capped at 5 (use memberCount for the group total); empty for space conversations.
  • lastMessage (ConversationPreviewLastMessage | null): a preview of the newest top-level message — id, conversationId, content (cut to 100 characters), gif, userId, moderationStatus, userDeletedAt, createdAt, files, and user ({ id, name, username, avatar, reputation }, on group and space rows only; null on direct rows). It has no mentions, quotes or reactions. A deleted or removed last message is its placeholder.

createDirectConversation

Returns the 1:1 direct conversation with another user, or creates it when there is none. Props type: CreateDirectConversationProps.
string
required
The other participant’s Sublay user ID.
Returns — Promise<CreateDirectConversationResult>: { conversation: Conversation; created: boolean }. created is true when this call created the conversation (HTTP 201) and false when it already existed (HTTP 200).

createGroupConversation

Creates a group conversation.
string
Group name.
string
Group description.
string[]
Sublay user IDs to add to the group. Defaults to an empty list.
object
Arbitrary key-value data attached to the conversation.
{ file: Blob | File; options: ImageOptions }
The group’s avatar image and its processing options (a mode and the fields it needs; see Image Processing Modes). The request is then sent as multipart/form-data. Requires the files-images bundle.
Returns — Promise<Conversation>

getConversation

Fetches a single conversation by ID.
string
required
The conversation ID.
Returns — Promise<Conversation>

updateConversation

Updates a conversation’s settings.
string
required
The conversation ID.
string
New name.
string
New description.
{ file: Blob | File; options: ImageOptions }
New avatar image and its processing options (a mode and the fields it needs; see Image Processing Modes). The request is then sent as multipart/form-data, and the previous avatar, if any, is deleted.
string[]
Files to remove: the conversation’s avatarFileId, nothing else. Removing it clears the avatar. Works alone or with a new avatarFile. Any other id throws a 400 (chat/invalid-remove-file-ids, with invalidIds).
"members" | "team"
Space conversations only: who may post — any active member ("members") or only the space’s active admins and moderators ("team").
Returns — Promise<Conversation>

deleteConversation

Deletes a conversation.
string
required
The conversation ID.
Returns — Promise<void>

getUnreadCount

Returns the user’s total unread message count and unread-conversation count. Takes no arguments.
Returns — Promise<{ totalUnread: number; unreadConversationCount: number }>

listMembers

Lists the members of a conversation (standard page-based pagination).
string
required
The conversation ID.
number
Page number (1-indexed).
number
Results per page: a whole number from 1 to 100. Defaults to 50. A larger value is rejected with 400 chat/invalid-query, never lowered to 100.
"admin" | "member"
Filter members by role.
Returns — Promise<PaginatedResponse<ConversationMember>>

addMember

Adds a user as a member of a conversation.
string
required
The conversation ID.
string
required
The user to add (the target member).
Returns — Promise<ConversationMember>

removeMember

Removes another member from a conversation. Passing the logged-in user’s own id is refused with 400 chat/own-member-id: to leave, use leaveConversation.
string
required
The conversation ID.
string
required
The member to remove (the target).
Returns — Promise<void>

changeMemberRole

Changes another member’s role within a conversation. Passing the logged-in user’s own id is refused with 400 chat/own-member-id.
string
required
The conversation ID.
string
required
The member whose role to change (the target).
"admin" | "member"
required
The new role.
Returns — Promise<ConversationMember>

checkMyConversationMembership

Reads the logged-in user’s own membership in a conversation (GET /chat/conversations/:conversationId/members/me).
string
required
The conversation ID.
Returns — Promise<CheckMyConversationMembershipResponse>, a flat object where a field that doesn’t apply is left out:
  • an active member: { isMember: true, role, lastReadAt, mutedForever, mutedUntil }
  • a user who left or was removed: { isMember: false, leftAt }
  • a user with no membership yet (a space conversation they haven’t opened): { isMember: false }
A user who can’t read the conversation gets the same error as reading it (404 chat/not-found or 403 chat/not-a-member). See Check My Membership.

leaveConversation

The logged-in user leaves a conversation (DELETE /chat/conversations/:conversationId/members/me).
string
required
The conversation ID.
Returns — Promise<void>. It resolves with no value once the user has left.

listMessages

Lists messages in a conversation, a page at a time before or after a message.
string
required
The conversation ID.
string
List this message’s thread replies (thread view), oldest first by default.
string
A message id: return the limit messages just before it. Pass the oldest message you hold to load older ones. It must be a message of this conversation at the same thread level (parentMessageId), or the call is rejected with 400 chat/invalid-cursor. Mutually exclusive with after.
string
A message id: return the limit messages just after it. Pass the newest message you hold to load newer ones. Same rules as before. Mutually exclusive with before.
number
Page size. Defaults to 50, max 100.
"asc" | "desc"
The order of the page by creation time. Defaults to "desc" for the main stream and "asc" for a thread. With before or after, the anchor decides which messages are in the page; sortDir only orders them.
ChatMessageListIncludeParam
Associations to populate, as a single value or an array: "files" (the message’s images and files) and "grants" (each message’s reputation-grant summary). Pass ["files", "grants"] for both.
MessageFilters
Optional filters. filters.hasReplies (boolean): when true, returns only messages that have thread replies (threadReplyCount > 0); when false, only messages with none. Filters by thread replies, not quotings.Threads are one level deep, so hasReplies: true together with parentMessageId always returns an empty list — the response’s notice field explains why.
Returns — Promise<{ data: ChatMessage[]; pagination: { hasMore: boolean }; notice?: string }>. hasMore says whether more messages exist past this page in the direction of travel: older with before, newer with after; with neither, older for "desc" and newer for "asc". See List Messages › Paging.

sendMessage

Sends a message to a conversation, optionally with images and files. When images or files is provided the request is sent as multipart/form-data (pass browser File / Blob objects); otherwise it is a plain JSON body. A message needs content, a GIF, or at least one image or file.
string
required
The conversation ID.
string
Message text.
GifData | null
An attached GIF, or null.
Mention[]
User mentions embedded in the message.
string
The message this is a threaded reply to.
string
A message being quoted.
object
Arbitrary key-value data attached to the message.
string
A client-generated ID echoed back on the created message (for optimistic UI); not stored.
{ files: (Blob | File)[]; options: ImageOptions }
Images, at most 50 MB each, processed into sizes per options (mode is required); each comes back with image and its variants. A request takes at most 20 files in all. Triggers a multipart/form-data upload. Requires the files-images bundle.
{ files: (Blob | File)[]; options?: { pathParts?: string[] } }
Files, at most 50 MB each, stored as uploaded (image is null, an image sent here included). Triggers a multipart/form-data upload. Requires the files-images bundle.
Returns — Promise<SendMessageResponse>: the created message as a SentChatMessage (a ChatMessage without reactionCounts, userReactions and grants), with localId when you passed one.

getMessage

Fetches a single message by ID.
string
required
The conversation ID.
string
required
The message ID.
ChatMessageIncludeParam
A single value or an array. The only value is "grants" — it attaches the message’s reputation-grant summary at message.grants. The message’s files are always returned.
Returns — Promise<ChatMessage>

editMessage

Edits an existing message.
string
required
The conversation ID.
string
required
The message ID.
string
New message text.
GifData | null
A GifData attachment, or null to clear it.
Mention[]
Updated mentions.
object
Replaces the message’s metadata. Send {} to clear it; null isn’t accepted (400 chat/invalid-body).
Returns — Promise<SentChatMessage>: the edited message, without reactionCounts, userReactions and grants.

deleteMessage

Deletes a message in a conversation.
string
required
The conversation ID.
string
required
The message ID.
Returns — Promise<void>. It resolves with no value once the message is deleted.

Reporting a message

Message reports go through the shared reports API, not a chat-specific function — the same call that reports entities and comments.
targetId is the message id; the conversation is resolved server-side, so no conversationId is needed. The reporter must be a member of the conversation and cannot report their own message. See createReport. Returns — Promise<CreateReportResponse> — the user’s own report of the message (see createReport).

toggleReaction

Toggles (adds or removes) an emoji reaction on a message for the logged-in user. A deleted or removed message takes no new reaction: adding one fails with 404 chat/message-not-found, while taking back your own still works.
string
required
The conversation ID.
string
required
The message ID.
string
required
The reaction emoji (1–10 characters).
Returns — Promise<{ reactionCounts: Record<string, number>; userReactions: string[]; delta: 1 | -1 }>

listReactions

Lists the users who reacted to a message with a given emoji.
string
required
The conversation ID.
string
required
The message ID.
string
required
The reaction emoji to list reactors for.
number
Page number. Defaults to 1.
number
Results per page: a whole number from 1 to 100. Defaults to 50. A larger value is rejected with 400 chat/invalid-query, never lowered to 100.
Returns — Promise<{ data: MessageReaction[]; pagination: { page: number; pageSize: number; totalPages: number; totalItems: number; hasMore: boolean } }>, where MessageReaction is { emoji: string; user: UserSummary; createdAt: string } and the user is { id, name, username, avatar, reputation } (plus spaceReputation when requested).

markAsRead

Marks a conversation as read up to a given message.
string
required
The conversation ID.
string
required
The message up to which the conversation is marked read.
Returns — Promise<void>

muteConversation

Sets or clears the signed-in user’s mute on a conversation. Muting suppresses the message push for this conversation only; the message is still delivered and readable. See Notification Preferences & Mute.
string
required
The conversation to mute or unmute.
"8h" | "24h" | "1w" | "forever" | null
required
The mute duration choice, or null to clear the mute. Send the choice, never a raw timestamp — the server resolves the window.
Returns — Promise<{ currentMember: ConversationMember }> — the signed-in user’s own member row.
“Forever” is an explicit signal. A forever mute returns mutedForever: true with mutedUntil: null; a timed mute returns mutedForever: false with a real ISO mutedUntil. Read the boolean — never string-match a far-future date.