segment. Messages support threading via a self-referential parentId.
Who is this for? This reference describes the core chat server data model. It’s essential for data import, analytics integration, and understanding API response structures. For social entities (User, Community, Post, Comment, etc.), see the Social Data Model Reference.
Entity Reference
6 core entities with full field definitions, types, and relationship mappings
Patterns & Relationships
Message threading, channel–community linking, and feed structure
Enums & Import Tips
Enum values and 8 practical data import guidelines
Conventions
Entity-Relationship Diagram
The following diagram shows the core entities and their relationships in the chat module.Entity Reference
Channel
Channel
A chat room, conversation, or group. Channels are the top-level container for messaging. Every community has a 1:1 backing channel. Channels can be standard (open), private, direct conversations, broadcast, community-backed, or live (attached to a room).
Relationships:
1:1→ Community (community-type channels back a community; see Channel ↔ Community Relationship)1:N→ ChannelUser (members)1:N→ MessageFeed (message threads within the channel)0:1→ Room (live-type channels are attached to a room viaattachedTo.roomId)0:1→ File (avatar viaavatarFileId)
ChannelUser (Member)
ChannelUser (Member)
The join entity between User and Channel. Represents a user’s membership, roles, and read state within a channel.
Relationships:
N:1→ UserN:1→ Channel- Composite key: (
userId,channelId)
Message
Message
A message within a channel. Messages belong to a MessageFeed and support threading (replies). Each message is stored as its own document.Relationships:
Threading model: See Message Threading Model below for details on how replies work.
N:1→ User (creator viacreatorId)N:1→ Channel (viachannelId)N:1→ MessageFeed (viamessageFeedId)1:N→ Message (replies viaparentId, self-referential)1:N→ Reaction (viareaction.referenceIdwherereferenceType = "message")0:1→ File (attachment viadata.fileId)
MessageFeed
MessageFeed
A message thread/feed within a channel. Each channel has one or more message feeds. The feed tracks the latest message and provides a message preview for UI display.
Relationships:
N:1→ Channel (viachannelId)N:1→ User (creator viacreatorId)1:N→ Message (messages reference feed viamessageFeedId)
Reaction
Reaction
Tracks reactions (likes, love, etc.) on messages. Each reaction is stored as its own document — one document per user-reaction-reference combination. Reactions use a polymorphic reference that supports multiple content types across both chat and social modules.Relationships:
Reaction names are freeform strings, not a fixed enum. The
reactions field on Message aggregates these as {reactionName: count}. The same Reaction entity is shared across both social and chat modules — only the referenceType differs.N:1→ Message (whenreferenceType = "message")N:1→ User (viauserId)
File
File
An uploaded media file (image, video, audio, or generic file). Files are referenced by messages and channels via
fileId. The File entity is shared across both social and chat modules.Relationships:
Referenced by: Message (
data.fileId, data.thumbnailFileId), Channel (avatarFileId).Message Threading Model
Messages support single-level threading within a message feed:1
Top-level messages
Top-level messages have
parentId = null. They belong directly to the feed.2
Replies
Replies have
parentId set to the parent message’s ID.3
Child tracking
childCount on each message tracks its direct reply count.4
Segment ordering
Messages are ordered by
segment within their feed (monotonically increasing). All messages (top-level and replies) live in the same feed and share the same segment counter.Reconstructing Threads
- Query messages by
messageFeedId. - Top-level messages:
parentId = null. - Group replies by
parentId. - Order all messages by
segment.
Channel ↔ Community Relationship
Every community in the social module has a 1:1 backing channel withtype = "community". This relationship connects the social and chat modules:
Cross-module linking: The Community entity stores a
channelId foreign key pointing to its backing channel. Community-type channels inherit the community’s membership — a user who is a community member is also a channel member. When importing data that spans both modules, ensure the Community’s channelId FK is correctly linked.Key Enums Reference
Full Enums Table
Full Enums Table
Data Import Tips
1. ID Resolution
1. ID Resolution
Most entities expose three IDs (
channelId, channelPublicId, channelInternalId). For joining data across entities, use the public ID — these are the values used in foreign key references. Internal IDs are database-level identifiers and may not appear in all API responses.2. Channel ↔ Community Linking
2. Channel ↔ Community Linking
Every community has a 1:1 backing channel (with
type = "community"). When importing both communities and channels, ensure corresponding records are linked. The community stores a channelId foreign key.3. Message Ordering by Segment
3. Message Ordering by Segment
Messages within a feed are ordered by
segment (a monotonically increasing integer). Preserve segment ordering during import to maintain correct message sequence. Each feed maintains its own independent segment counter.4. ChannelUser Composite Key
4. ChannelUser Composite Key
The ChannelUser entity uses a composite key of (
userId, channelId). When importing, deduplicate on both fields to avoid creating duplicate membership records.5. Computed Fields — Do Not Import
5. Computed Fields — Do Not Import
Several fields are derived at read time and should not be imported as stored values:
Channel.isMuted— derived frommuteTimeout > now.Channel.isRateLimited— derived fromrateLimitTimeout > now.Channel.memberCount/messageCount— aggregated from related records.ChannelUser.isBanned— derived frommembership = "banned".ChannelUser.isMuted— derived frommuteTimeout > now.Message.myReactions— derived per-request for the current user.MessageFeed.messagePreviewId— derived from latest message.
6. Filtering Deleted Records
6. Filtering Deleted Records
Soft-deleted records have
isDeleted: true. Exclude these by default for analytics unless you need deletion history.7. Reactions on Messages
7. Reactions on Messages
Message reactions follow the same model as social reactions (see Social Data Model Reference). Each reaction is stored as a separate document with
referenceType = "message" and referenceId pointing to the message. The reactions object on Message provides pre-aggregated {name: count} maps.8. Message Threading
8. Message Threading
To get only top-level messages (not replies), filter by
parentId = null. To reconstruct threads, group replies by parentId and order by segment. See Message Threading Model for the full pattern.Related Topics
Social Data Model
Core social entities — User, Community, Post, Comment, Reaction, and more
API Overview
Server-to-server API capabilities, authentication methods, and getting started guide
SDK Chat Overview
Client-side SDK implementation for channels, messaging, and real-time chat features