Overview
TheSearch request allows you to search for messages within a chat using text queries. You can search within a specific channel or across an entire community, with support for pagination.
Proto Definition
Request Fields
The chat context for the search. The behavior depends on the
scoped parameter:- If
scopedistrue: Search only in this specific chat - If
scopedisfalseandchat_refis a channel: Search across the entire parent community - If
scopedisfalseandchat_refis not a channel: Search only in this chat (equivalent to scoped)
The search query text. Messages matching this query will be returned.The exact matching behavior (case-sensitivity, partial matches, etc.) depends on the server implementation.
Controls the search scope:
true: Search only the specific channel/chat specified inchat_reffalse: For channels, search across the entire parent community (all channels)
messages.searchAll (not documented here).Return search results after this message ID (exclusive). Useful for pagination when loading more results.Type: Snowflake ID representing a MessageNote: Only one of
since or before can be specified.Return search results before this message ID (exclusive). Useful for pagination when loading previous results.Type: Snowflake ID representing a MessageNote: Only one of
since or before can be specified.Response
The response uses the sameMessages structure as GetHistory:
Array of messages matching the search query, sorted by relevance or chronological order.
Array of user objects for all users referenced in the search results (authors, mentioned users, etc.).
Array of community member data for community channels (includes roles, nicknames, etc.).
Array of reactions for the returned messages.
Examples
Search Within a Specific Channel
111111111111111111 for messages containing “important announcement”.
Search Across Entire Community
987654321098765432 for messages containing “meeting notes”.
Search in a Direct Message
123456789012345678.
Search in a Group Chat
222222222222222222.
Paginated Search (Load More Results)
555555555555555555.
Search Behavior
Scoped vs Unscoped Search
Scoped Search
- Searches only the specific chat in
chat_ref - Faster and more focused results
- Best for finding messages in a known location
Unscoped Search
- For channels: Searches all channels in the parent community
- For other chat types: Behaves the same as scoped
- Broader results, may be slower
- Best for finding messages when you’re unsure of the exact channel
Pagination
Search results support pagination using thesince and before parameters:
- Initial search: Omit both
sinceandbeforeto get the first page of results - Load more recent results: Use
sincewith the newest message ID from current results - Load older results: Use
beforewith the oldest message ID from current results
Use Cases
Finding Specific Content
Community-Wide Search
Historical Message Lookup
Notes
- Search queries are text-based; the server determines matching logic
- The
scopedparameter only affects channels; for other chat types, search is always within that chat - For global search across all your conversations, use
messages.searchAllinstead - Search results include all necessary user and member data for rendering
- Pagination works the same way as in
GetHistory, using snowflake IDs for efficient ordering - Search performance may vary based on chat size and query complexity