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 use cursor (keyset) pagination, not
page/limit:
listConversations and listMessages.
Their return shapes differ from the standard PaginatedResponse — see each
below.listConversations
Lists the user’s conversations, newest activity first, with keyset pagination.Promise<{ conversations: ConversationPreview[]; hasMore: boolean }>.
Each ConversationPreview includes 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.
createDirectConversation
Creates (or returns the existing) 1:1 direct conversation with another user.Promise<Conversation>
createGroupConversation
Creates a group conversation.Promise<Conversation>
getConversation
Fetches a single conversation by ID.Promise<Conversation>
updateConversation
Updates a conversation’s settings.Promise<Conversation>
deleteConversation
Deletes a conversation.Promise<{ message: string }>
getUnreadCount
Returns the user’s total unread message count and unread-conversation count. Takes no arguments.Promise<{ totalUnread: number; unreadConversationCount: number }>
listMembers
Lists the members of a conversation (standard page-based pagination).Promise<PaginatedResponse<ConversationMember>>
addMember
Adds a user as a member of a conversation.Promise<ConversationMember>
removeMember
Removes a member from a conversation.Promise<{ message: string }>
changeMemberRole
Changes a member’s role within a conversation.Promise<ConversationMember>
leaveConversation
The logged-in user leaves a conversation.Promise<{ message: string }>
listMessages
Lists messages in a conversation with keyset (before/after) pagination.Keyset cursor (ISO timestamp) — return messages created before this. Mutually
exclusive with
after.Keyset cursor (ISO timestamp) — return messages created after this. Mutually
exclusive with
before.Comma-separated associations to populate:
"files" (message attachments) and "grants" (each message’s reputation-grant summary). Combine them as "files,grants".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 parentId
always returns an empty list — the response’s notice field explains why.Promise<{ messages: ChatMessage[]; hasMore: boolean; oldestCreatedAt: string | null; newestCreatedAt: string | null }>.
sendMessage
Sends a message to a conversation, optionally with file attachments. Whenfiles
is provided the request is sent as multipart/form-data (pass browser File /
Blob objects); otherwise it is a plain JSON body.
Up to 10 file attachments, as browser
File / Blob objects. Triggers a
multipart/form-data upload.Promise<ChatMessage>
getMessage
Fetches a single message by ID.Comma-separated associations to populate. Only
"grants" is supported here — it attaches the message’s reputation-grant summary at message.grants.Promise<ChatMessage>
editMessage
Edits an existing message.A GifData attachment, or
null to clear it.Promise<ChatMessage>
deleteMessage
Deletes a message in a conversation.Promise<{ message: string; userDeletedAt?: string }> (userDeletedAt
is set when the author soft-deletes their own message).
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<{ message: string; code: string }>
toggleReaction
Toggles (adds or removes) an emoji reaction on a message for the logged-in user.Promise<{ reactionCounts: Record<string, number>; userReactions: string[]; delta: 1 | -1 }>
listReactions
Lists the users who reacted to a message with a given emoji.Promise<{ data: MessageReaction[]; pagination: { page: number; limit: number; total: number; hasMore: boolean } }>,
where MessageReaction is { user: User; emoji: string; createdAt: Date }.
markAsRead
Marks a conversation as read up to a given message.Promise<{ message: string }>
muteConversation
Sets or clears the signed-in user’s mute on a conversation. Muting suppresses themessage push for this conversation only; the message is still delivered and readable. See Notification Preferences & Mute.
The mute duration choice, or
null to clear the mute. Send the choice, never a raw timestamp — the server resolves the window.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.
