Conversation type and related operations for managing conversation state.
Conversation Type
TheConversation type encapsulates the state of a chat from the current user’s perspective:
Fields
Reference identifying this conversation. For direct messages, this references a user ID. For group chats, this references a chat ID
Snowflake Message ID of the most recent message in this conversation. If no messages exist yet, this defaults to the chat ID. Used for sorting conversations chronologically
Snowflake Message ID of the last message the current user has marked as read. Messages after this ID are considered unread
Number of unread messages in this conversation. Calculated as messages after
last_read_message_idUnsent message text saved as a draft for this conversation. Allows users to preserve work-in-progress messages
Custom permission overrides for this specific conversation
Whether the user has muted notifications for this conversation
Permission Overrides
Bitfield of permissions to explicitly grant for this conversation
Bitfield of permissions to explicitly deny for this conversation
Read States
MarkChatRead
Mark messages as read in a conversation, updating the read position and clearing unread count.Parameters
Reference to the conversation to update
Snowflake Message ID to mark as the last read message. All messages up to and including this ID will be marked as read
Number of messages being marked as read (for analytics/tracking purposes)
Response
Returns empty on success. The server updates theConversation object:
- Sets
last_read_message_idto the providedmessage_id - Recalculates
unread_countto 0 (or remaining unread messages if newer messages exist)
Behavior
- Marking a message as read implicitly marks all earlier messages as read
- If new messages arrive after marking as read,
unread_countincrements accordingly - Read states are per-user and don’t affect other participants
Typing Indicators
SetTyping
Indicate whether the current user is typing in a conversation.Parameters
Reference to the conversation where typing is occurring
true to indicate the user is typing, false to indicate they stoppedResponse
Returns empty on success.Behavior
- Typing indicators are ephemeral and typically expire after a few seconds of inactivity
- Other participants in the conversation receive real-time updates about typing status
- Sending a message automatically clears the typing indicator
- Clients should send
typing = falsewhen the user clears the input field or leaves the conversation
Best Practices
- Send
typing = truewhen the user starts typing (debounced to avoid excessive updates) - Send
typing = falsewhen the user stops typing for ~2-3 seconds - Clear typing state when sending a message
- Don’t spam typing updates on every keystroke
Chat Invites
Invites allow users to join group chats via a shareable code.CreateChatInvite
Generate an invite code for a group chat.Parameters
Reference to the group chat to create an invite for
Unix timestamp (in milliseconds) when the invite expires. If not provided, the invite never expires
Maximum number of times the invite can be used. If not provided, unlimited uses are allowed
Response
Returns anauth.CreatedInvite object containing the invite code and metadata.
Permissions
- Only group chat owners can create invites
- Direct messages don’t support invites
ListChatInvites
Retrieve all active invites for a group chat.Parameters
Reference to the group chat
Response
Returns anauth.InviteList object containing all active invites for the chat.
DeleteChatInvite
Revoke an invite code, preventing further uses.Parameters
The invite code to delete/revoke
Response
Returns empty on success.Behavior
- Deleted invites can no longer be used to join the chat
- Users who already joined via the invite remain in the group
- Only the invite creator or group owner can delete invites
Conversation State Management
Sorting Conversations
Uselast_message_id to sort conversations by most recent activity:
last_message_id defaults to the chat ID when no messages exist, new conversations without messages still sort correctly.
Unread Tracking
Theunread_count field provides an immediate count of unread messages:
- Display badge with count on conversation list items
- Bold or highlight conversations with
unread_count > 0 - Clear count by calling
MarkChatReadwith the latest message ID
Draft Management
Thedraft field persists unsent message text:
- Save draft text to the
Conversationwhen the user types - Restore draft when opening the conversation
- Clear draft when sending a message
Muting Conversations
Themuted field controls notifications:
- When
muted = true, suppress notifications for new messages - Still increment
unread_countand show visual indicators - Allow users to toggle mute status per conversation
Related
- Direct Messages - GetChats and GetChat operations
- Group Chats - Creating and managing group conversations
- Messages - Sending and receiving messages