Skip to main content
Quick Reference for AI Agents & Developers
  • Filter by type: .set(types:) — e.g., ["text", "image"]
  • Filter by category: .set(categories:) — e.g., ["message", "action"]
  • Filter by tags: .setTags(_:), .withTags(true)
  • Filter by sender: .set(uid:) for specific user’s messages
  • Exclude: .hideReplies(true), .hideDeletedMessages(true)
  • Related: Receive Message · Message Structure · Messaging Overview
The MessagesRequest class as you must be familiar with helps you to fetch messages based on the various parameters provided to it. This document will help you understand better the various options that are available using the MessagesRequest class.

Object Structures

For complete object structure definitions, see Send Message - Object Structures:

Number of messages fetched

In other words, how do I set the number of messages fetched in a single iteration To achieve this, you can use the setLimit() method. This method takes an integer value as the input and informs the SDK to fetch the specified number of messages in one iteration. The maximum number of messages that can be fetched in one go is 100.
Method: MessagesRequest.fetchPrevious()

Messages for a user conversation

In other words, how do I fetch messages between me and any user This can be achieved using the setUID() method. This method takes the UID of the user with whom the conversation is to be fetched.
Method: MessagesRequest.fetchPrevious()

Messages for a group conversation

In other words, how do I fetch messages for any group conversation You can achieve this using the setGUID() method. This method takes the GUID of a group for which the conversations are to be fetched.
Method: MessagesRequest.fetchPrevious()
If none of the above two methods setUID() and setGUID() is used, all the messages for the logged-in user will be fetched. This means that messages from all the one-on-one and group conversations which the logged-in user is a part of will be returned.

Messages before/after a message

In other words, how do I fetch messages before or after a particular message This can be achieved using the setMessageId() method. This method takes the message-id as input and provides messages only after/before the message-id based on if the fetchNext() or fetchPrevious() method is triggered.
Method: MessagesRequest.fetchPrevious()

Messages before/after a given time

In other words, how do I fetch messages before or after a particular date or time You can easily achieve this using the setTimestamp() method. This method takes the Unix timestamp as input.
Method: MessagesRequest.fetchPrevious()

Unread messages

In other words, how do I fetch unread messages This can easily be achieved using setting the unread flag to true. For this, you need to use the setUnread() method.
Method: MessagesRequest.fetchPrevious()

Messages for multiple categories

In other words, how do I fetch messages belonging to multiple categories For this, you will have to use the setCategories() method. This method accepts a list of categories.
Method: MessagesRequest.fetchPrevious()categories ([String]):

Messages for multiple types

In other words, how do I fetch messages belonging to multiple types This can be easily achieved using the setTypes() method. This method accepts a list of types.
Method: MessagesRequest.fetchPrevious()types ([String]):

Messages by tags

In other words, how do I fetch messages belonging to specific tags In order to do this, you can use the setTags() method. This method accepts a list of tags.
Method: MessagesRequest.fetchPrevious()tags ([String]):

Common Error Codes