> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-22654f5b-docs-v6-beta2-flutter-uikit.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Additional Message Filtering

> Learn how to use MessagesRequestBuilder to filter and fetch messages by conversation, type, category, tags, timestamps, and more in the CometChat React Native SDK.

<Info>
  **Quick Reference for AI Agents & Developers**

  ```javascript theme={null}
  // Fetch messages for a user conversation
  let request = new CometChat.MessagesRequestBuilder().setUID("UID").setLimit(50).build();

  // Fetch messages for a group conversation
  let request = new CometChat.MessagesRequestBuilder().setGUID("GUID").setLimit(50).build();

  // Fetch only unread messages
  let request = new CometChat.MessagesRequestBuilder().setUID("UID").setUnread(true).setLimit(30).build();

  // Fetch only media messages
  let request = new CometChat.MessagesRequestBuilder().setUID("UID").setCategories(["message"]).setTypes(["image", "video", "audio", "file"]).setLimit(30).build();

  // Fetch messages, then paginate
  let messages = await request.fetchPrevious();
  ```
</Info>

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.

<Note>
  **Available via:** [SDK](/sdk/react-native/additional-message-filtering) | [REST API](/rest-api/messages/list-messages) | [UI Kits](/ui-kit/react/message-list#filters)
</Note>

The `MessagesRequest` class is designed using the `Builder design pattern`. In order to obtain an object of the `MessagesRequest` class, you will have to make use of the `MessagesRequestBuilder` class in the `MessagesRequest` class.

The `MessagesRequestBuilder` class allows you to set various parameters to the `MessagesRequest` class based on which the messages are fetched.

Steps to generate an object of the MessagesRequest class:

1. Create an object of the `MessagesRequestBuilder` class.
2. Set all the parameters you wish to set.
3. Call the `build()` method of the `MessagesRequestBuilder` class to get an object of the `MessagesRequest` class.

Once you have an object of the `MessagesRequest` class, you can call either the `fetchNext()` method or the `fetchPrevious()` method using the object.

1. fetchNext() - Calling this method will return the messages after the specified parameters.
2. fetchPrevious() - Calling this method will give you messages before the specified parameters.

Since messages are obtained in a paginated manner, a `maximum of 100` messages can be pulled in a single iteration. Calling the `fetchPrevious()`/`fetchNext()` method on the same `MessagesRequest` object will get you the next set of messages.

Now that you are clear how to use the `MessagesRequest` class, below are the various options available:

## 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`.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setLimit(50)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    let messagesRequest: CometChat.MessagesRequest =
      new CometChat.MessagesRequestBuilder().setLimit(50).build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns an array of `Message` objects:

  <span id="filter-limit-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                 |
  | ---------------- | ------- | --------------------------------- | -------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25234"`                                    |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`     |
  | `receiverId`     | string  | Receiver's UID or GUID            | `"cometchat-uid-2"`                          |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                     |
  | `type`           | string  | Message type                      | `"text"`                                     |
  | `category`       | string  | Message category                  | `"message"`                                  |
  | `text`           | string  | Message text content              | `"Nice"`                                     |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771398092`                                 |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771398092`                                 |
  | `readAt`         | number  | Unix timestamp when read          | `1771404705`                                 |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771404705`                                 |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-limit-sender-object)   |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-limit-receiver-object) |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-limit-data-object)     |
  | `metadata`       | object  | Message metadata                  | [See below ↓](#filter-limit-metadata-object) |
  | `reactions`      | array   | Message reactions                 | `[]`                                         |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                         |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                      |

  ***

  <span id="filter-limit-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771397739`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-limit-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771397762`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-limit-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter  | Type   | Description                  | Sample Value                                      |
  | ---------- | ------ | ---------------------------- | ------------------------------------------------- |
  | `text`     | string | Message text                 | `"Nice"`                                          |
  | `resource` | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                       |
  | `entities` | object | Sender and receiver entities | [See below ↓](#filter-limit-data-entities-object) |
  | `metadata` | object | Injected metadata            | [See below ↓](#filter-limit-data-metadata-object) |

  ***

  <span id="filter-limit-data-entities-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities` Object:**

  | Parameter  | Type   | Description             | Sample Value                                               |
  | ---------- | ------ | ----------------------- | ---------------------------------------------------------- |
  | `sender`   | object | Sender entity wrapper   | [See below ↓](#filter-limit-data-entities-sender-object)   |
  | `receiver` | object | Receiver entity wrapper | [See below ↓](#filter-limit-data-entities-receiver-object) |

  ***

  <span id="filter-limit-data-entities-sender-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                    |
  | ------------ | ------ | ------------------- | --------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                        |
  | `entity`     | object | User entity details | [See below ↓](#filter-limit-data-entities-sender-entity-object) |

  ***

  <span id="filter-limit-data-entities-sender-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender.entity` Object:**

  | Parameter      | Type   | Description              | Sample Value                                                            |
  | -------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`          | string | User's unique identifier | `"cometchat-uid-3"`                                                     |
  | `name`         | string | User's display name      | `"Nancy Grace"`                                                         |
  | `avatar`       | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`       | string | User's online status     | `"online"`                                                              |
  | `role`         | string | User's role              | `"default"`                                                             |
  | `lastActiveAt` | number | Last active timestamp    | `1771397739`                                                            |
  | `tags`         | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-limit-data-entities-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                      |
  | ------------ | ------ | ------------------- | ----------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                          |
  | `entity`     | object | User entity details | [See below ↓](#filter-limit-data-entities-receiver-entity-object) |

  ***

  <span id="filter-limit-data-entities-receiver-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver.entity` Object:**

  | Parameter        | Type   | Description              | Sample Value                                                            |
  | ---------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`            | string | User's unique identifier | `"cometchat-uid-2"`                                                     |
  | `name`           | string | User's display name      | `"George Alan"`                                                         |
  | `avatar`         | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`         | string | User's online status     | `"online"`                                                              |
  | `role`           | string | User's role              | `"default"`                                                             |
  | `lastActiveAt`   | number | Last active timestamp    | `1771397762`                                                            |
  | `conversationId` | string | Conversation identifier  | `"cometchat-uid-2_user_cometchat-uid-3"`                                |
  | `tags`           | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-limit-data-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata` Object:**

  | Parameter   | Type   | Description              | Sample Value                                               |
  | ----------- | ------ | ------------------------ | ---------------------------------------------------------- |
  | `@injected` | object | Injected extensions data | [See below ↓](#filter-limit-data-metadata-injected-object) |

  ***

  <span id="filter-limit-data-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected` Object:**

  | Parameter    | Type   | Description     | Sample Value                                                 |
  | ------------ | ------ | --------------- | ------------------------------------------------------------ |
  | `extensions` | object | Extensions data | [See below ↓](#filter-limit-data-metadata-extensions-object) |

  ***

  <span id="filter-limit-data-metadata-extensions-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description                 | Sample Value                                                  |
  | -------------- | ------ | --------------------------- | ------------------------------------------------------------- |
  | `link-preview` | object | Link preview extension data | [See below ↓](#filter-limit-data-metadata-linkpreview-object) |

  ***

  <span id="filter-limit-data-metadata-linkpreview-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions.link-preview` Object:**

  | Parameter | Type  | Description            | Sample Value |
  | --------- | ----- | ---------------------- | ------------ |
  | `links`   | array | Array of link previews | `[]`         |

  ***

  <span id="filter-limit-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`metadata` Object:**

  | Parameter   | Type   | Description              | Sample Value                                          |
  | ----------- | ------ | ------------------------ | ----------------------------------------------------- |
  | `@injected` | object | Injected extensions data | [See below ↓](#filter-limit-metadata-injected-object) |

  ***

  <span id="filter-limit-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected` Object:**

  | Parameter    | Type   | Description     | Sample Value                                            |
  | ------------ | ------ | --------------- | ------------------------------------------------------- |
  | `extensions` | object | Extensions data | [See below ↓](#filter-limit-metadata-extensions-object) |

  ***

  <span id="filter-limit-metadata-extensions-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description                 | Sample Value                                             |
  | -------------- | ------ | --------------------------- | -------------------------------------------------------- |
  | `link-preview` | object | Link preview extension data | [See below ↓](#filter-limit-metadata-linkpreview-object) |

  ***

  <span id="filter-limit-metadata-linkpreview-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions.link-preview` Object:**

  | Parameter | Type  | Description            | Sample Value |
  | --------- | ----- | ---------------------- | ------------ |
  | `links`   | array | Array of link previews | `[]`         |
</Accordion>

## 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. When a valid UID is passed, the SDK will return all the messages that are a part of the conversation between the logged-in user and the UID that has been specified.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    let UID = "UID";
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setLimit(50)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    let UID: string = "UID",
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder().setUID(UID).setLimit(50).build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns an array of `Message` objects:

  <span id="filter-uid-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                               |
  | ---------------- | ------- | --------------------------------- | ------------------------------------------ |
  | `id`             | string  | Unique message identifier         | `"25234"`                                  |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`   |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                        |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                   |
  | `type`           | string  | Message type                      | `"text"`                                   |
  | `category`       | string  | Message category                  | `"message"`                                |
  | `text`           | string  | Message text content              | `"Nice"`                                   |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771398092`                               |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771398092`                               |
  | `readAt`         | number  | Unix timestamp when read          | `1771404705`                               |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771404705`                               |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-uid-sender-object)   |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-uid-receiver-object) |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-uid-data-object)     |
  | `metadata`       | object  | Message metadata                  | [See below ↓](#filter-uid-metadata-object) |
  | `reactions`      | array   | Message reactions                 | `[]`                                       |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                       |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                    |

  ***

  <span id="filter-uid-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771397739`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-uid-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771397762`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-uid-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter  | Type   | Description                  | Sample Value                                    |
  | ---------- | ------ | ---------------------------- | ----------------------------------------------- |
  | `text`     | string | Message text                 | `"Nice"`                                        |
  | `resource` | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                     |
  | `entities` | object | Sender and receiver entities | [See below ↓](#filter-uid-data-entities-object) |
  | `metadata` | object | Injected metadata            | [See below ↓](#filter-uid-data-metadata-object) |

  ***

  <span id="filter-uid-data-entities-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities` Object:**

  | Parameter  | Type   | Description             | Sample Value                                             |
  | ---------- | ------ | ----------------------- | -------------------------------------------------------- |
  | `sender`   | object | Sender entity wrapper   | [See below ↓](#filter-uid-data-entities-sender-object)   |
  | `receiver` | object | Receiver entity wrapper | [See below ↓](#filter-uid-data-entities-receiver-object) |

  ***

  <span id="filter-uid-data-entities-sender-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                  |
  | ------------ | ------ | ------------------- | ------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                      |
  | `entity`     | object | User entity details | [See below ↓](#filter-uid-data-entities-sender-entity-object) |

  ***

  <span id="filter-uid-data-entities-sender-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender.entity` Object:**

  | Parameter      | Type   | Description              | Sample Value                                                            |
  | -------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`          | string | User's unique identifier | `"cometchat-uid-3"`                                                     |
  | `name`         | string | User's display name      | `"Nancy Grace"`                                                         |
  | `avatar`       | string | User's avatar URL        | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `role`         | string | User's role              | `"default"`                                                             |
  | `status`       | string | User's online status     | `"online"`                                                              |
  | `lastActiveAt` | number | Last active timestamp    | `1771397739`                                                            |
  | `tags`         | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-uid-data-entities-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                    |
  | ------------ | ------ | ------------------- | --------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                        |
  | `entity`     | object | User entity details | [See below ↓](#filter-uid-data-entities-receiver-entity-object) |

  ***

  <span id="filter-uid-data-entities-receiver-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver.entity` Object:**

  | Parameter        | Type   | Description              | Sample Value                                                            |
  | ---------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`            | string | User's unique identifier | `"cometchat-uid-2"`                                                     |
  | `name`           | string | User's display name      | `"George Alan"`                                                         |
  | `avatar`         | string | User's avatar URL        | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `role`           | string | User's role              | `"default"`                                                             |
  | `status`         | string | User's online status     | `"online"`                                                              |
  | `lastActiveAt`   | number | Last active timestamp    | `1771397762`                                                            |
  | `conversationId` | string | Conversation identifier  | `"cometchat-uid-2_user_cometchat-uid-3"`                                |
  | `tags`           | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-uid-data-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata` Object:**

  | Parameter   | Type   | Description              | Sample Value                                             |
  | ----------- | ------ | ------------------------ | -------------------------------------------------------- |
  | `@injected` | object | Injected extensions data | [See below ↓](#filter-uid-data-metadata-injected-object) |

  ***

  <span id="filter-uid-data-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected` Object:**

  | Parameter    | Type   | Description     | Sample Value                                               |
  | ------------ | ------ | --------------- | ---------------------------------------------------------- |
  | `extensions` | object | Extensions data | [See below ↓](#filter-uid-data-metadata-extensions-object) |

  ***

  <span id="filter-uid-data-metadata-extensions-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description            | Sample Value                                                |
  | -------------- | ------ | ---------------------- | ----------------------------------------------------------- |
  | `link-preview` | object | Link preview extension | [See below ↓](#filter-uid-data-metadata-linkpreview-object) |

  ***

  <span id="filter-uid-data-metadata-linkpreview-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions.link-preview` Object:**

  | Parameter | Type  | Description     | Sample Value |
  | --------- | ----- | --------------- | ------------ |
  | `links`   | array | Extracted links | `[]`         |

  ***

  <span id="filter-uid-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`metadata` Object:**

  | Parameter   | Type   | Description              | Sample Value                                        |
  | ----------- | ------ | ------------------------ | --------------------------------------------------- |
  | `@injected` | object | Injected extensions data | [See below ↓](#filter-uid-metadata-injected-object) |

  ***

  <span id="filter-uid-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected` Object:**

  | Parameter    | Type   | Description     | Sample Value                                          |
  | ------------ | ------ | --------------- | ----------------------------------------------------- |
  | `extensions` | object | Extensions data | [See below ↓](#filter-uid-metadata-extensions-object) |

  ***

  <span id="filter-uid-metadata-extensions-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description            | Sample Value                                           |
  | -------------- | ------ | ---------------------- | ------------------------------------------------------ |
  | `link-preview` | object | Link preview extension | [See below ↓](#filter-uid-metadata-linkpreview-object) |

  ***

  <span id="filter-uid-metadata-linkpreview-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions.link-preview` Object:**

  | Parameter | Type  | Description     | Sample Value |
  | --------- | ----- | --------------- | ------------ |
  | `links`   | array | Extracted links | `[]`         |
</Accordion>

## 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. Passing a valid GUID to this method will return all the messages that are a part of the group conversation. Please note that the logged-in user must be a member of the group to fetch the messages for that group.

<Tabs>
  <Tab title="JavaScript">
    ```javascript theme={null}
    let GUID = "GUID";
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setLimit(50)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    let GUID: string = "GUID",
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder().setGUID(GUID).setLimit(50).build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns an array of `Message` objects for the group:

  <span id="filter-guid-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                 |
  | ---------------- | ------- | --------------------------------- | -------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25237"`                                    |
  | `conversationId` | string  | Conversation identifier           | `"group_group_1748415903905"`                |
  | `receiverId`     | string  | Group's GUID                      | `"group_1748415903905"`                      |
  | `receiverType`   | string  | Type of receiver                  | `"group"`                                    |
  | `type`           | string  | Message type                      | `"text"`                                     |
  | `category`       | string  | Message category                  | `"message"`                                  |
  | `text`           | string  | Message text content              | `"Nice"`                                     |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771400683`                                 |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771400683`                                 |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-guid-sender-object)    |
  | `receiver`       | object  | Receiver group details            | [See below ↓](#filter-guid-receiver-object)  |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-guid-data-object)      |
  | `metadata`       | object  | Message metadata                  | Contains `@injected.extensions.link-preview` |
  | `reactions`      | array   | Message reactions                 | `[]`                                         |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                         |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                      |

  ***

  <span id="filter-guid-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771397739`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-guid-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object (Group):**

  | Parameter            | Type    | Description                     | Sample Value                  |
  | -------------------- | ------- | ------------------------------- | ----------------------------- |
  | `guid`               | string  | Group's unique identifier       | `"group_1748415903905"`       |
  | `name`               | string  | Group's display name            | `"3 People Group"`            |
  | `type`               | string  | Group type                      | `"public"`                    |
  | `conversationId`     | string  | Conversation identifier         | `"group_group_1748415903905"` |
  | `owner`              | string  | Group owner's UID               | `"123456"`                    |
  | `scope`              | string  | Current user's scope in group   | `"admin"`                     |
  | `membersCount`       | number  | Total members in group          | `12`                          |
  | `onlineMembersCount` | number  | Online members count            | `2`                           |
  | `hasJoined`          | boolean | Whether current user has joined | `true`                        |
  | `isBanned`           | boolean | Whether current user is banned  | `false`                       |
  | `joinedAt`           | number  | Timestamp when user joined      | `1749203133`                  |
  | `createdAt`          | number  | Group creation timestamp        | `1748415957`                  |
  | `updatedAt`          | number  | Group update timestamp          | `1771245340`                  |

  ***

  <span id="filter-guid-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter  | Type   | Description                  | Sample Value                                     |
  | ---------- | ------ | ---------------------------- | ------------------------------------------------ |
  | `text`     | string | Message text                 | `"Nice"`                                         |
  | `resource` | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                      |
  | `entities` | object | Sender and receiver entities | [See below ↓](#filter-guid-data-entities-object) |
  | `metadata` | object | Injected metadata            | Contains `@injected.extensions.link-preview`     |

  ***

  <span id="filter-guid-data-entities-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities` Object:**

  | Parameter  | Type   | Description             | Sample Value                                              |
  | ---------- | ------ | ----------------------- | --------------------------------------------------------- |
  | `sender`   | object | Sender entity wrapper   | [See below ↓](#filter-guid-data-entities-sender-object)   |
  | `receiver` | object | Receiver entity wrapper | [See below ↓](#filter-guid-data-entities-receiver-object) |

  ***

  <span id="filter-guid-data-entities-sender-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                               |
  | ------------ | ------ | ------------------- | -------------------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                                   |
  | `entity`     | object | User entity details | Contains `uid`, `name`, `avatar`, `status`, `role`, `lastActiveAt`, `tags` |

  ***

  <span id="filter-guid-data-entities-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver` Object:**

  | Parameter    | Type   | Description          | Sample Value                                                     |
  | ------------ | ------ | -------------------- | ---------------------------------------------------------------- |
  | `entityType` | string | Type of entity       | `"group"`                                                        |
  | `entity`     | object | Group entity details | [See below ↓](#filter-guid-data-entities-receiver-entity-object) |

  ***

  <span id="filter-guid-data-entities-receiver-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver.entity` Object (Group):**

  | Parameter            | Type    | Description                     | Sample Value                  |
  | -------------------- | ------- | ------------------------------- | ----------------------------- |
  | `guid`               | string  | Group's unique identifier       | `"group_1748415903905"`       |
  | `name`               | string  | Group's display name            | `"3 People Group"`            |
  | `type`               | string  | Group type                      | `"public"`                    |
  | `conversationId`     | string  | Conversation identifier         | `"group_group_1748415903905"` |
  | `owner`              | string  | Group owner's UID               | `"123456"`                    |
  | `scope`              | string  | Current user's scope in group   | `"admin"`                     |
  | `membersCount`       | number  | Total members in group          | `12`                          |
  | `onlineMembersCount` | number  | Online members count            | `2`                           |
  | `hasJoined`          | boolean | Whether current user has joined | `true`                        |
  | `joinedAt`           | number  | Timestamp when user joined      | `1749203133`                  |
  | `createdAt`          | number  | Group creation timestamp        | `1748415957`                  |
  | `updatedAt`          | number  | Group update timestamp          | `1771245340`                  |
</Accordion>

<Note>
  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.> All the parameters discussed below can be used along with the setUID() or setGUID() or without any of the two to fetch all the messages that the logged-in user is a part of.
</Note>

## 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.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let messageId = 1;
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setMessageId(messageId)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let UID = "UID";
    let messageId = 1;
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setMessageId(messageId)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      messageId: number = 1,
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setUID(UID)
          .setMessageId(messageId)
          .setLimit(limit)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let UID: string = "UID",
      messageId: number = 1,
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setUID(UID)
          .setMessageId(messageId)
          .setLimit(limit)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns messages before the specified message ID:

  <span id="filter-msgid-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                 |
  | ---------------- | ------- | --------------------------------- | -------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25233"`                                    |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`     |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                          |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                     |
  | `type`           | string  | Message type                      | `"text"`                                     |
  | `category`       | string  | Message category                  | `"message"`                                  |
  | `text`           | string  | Message text content              | `"UnreadHey"`                                |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771398088`                                 |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771398088`                                 |
  | `readAt`         | number  | Unix timestamp when read          | `1771404705`                                 |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771398088`                                 |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-msgid-sender-object)   |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-msgid-receiver-object) |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-msgid-data-object)     |
  | `metadata`       | object  | Message metadata                  | Contains `@injected.extensions.link-preview` |
  | `reactions`      | array   | Message reactions                 | `[]`                                         |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                         |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                      |

  ***

  <span id="filter-msgid-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771397739`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-msgid-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771397762`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-msgid-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter  | Type   | Description                  | Sample Value                                 |
  | ---------- | ------ | ---------------------------- | -------------------------------------------- |
  | `text`     | string | Message text                 | `"UnreadHey"`                                |
  | `resource` | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                  |
  | `entities` | object | Sender and receiver entities | Contains `sender` and `receiver` wrappers    |
  | `metadata` | object | Injected metadata            | Contains `@injected.extensions.link-preview` |
</Accordion>

This method can be used along with `setUID()` or `setGUID()` methods to fetch messages after/before any specific message-id for a particular user/group conversation.

## 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 and provides messages only after/before the timestamp based on if fetchNext() or fetchPrevious() method is triggered.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let timestamp = 1602221371;
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setTimestamp(timestamp)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let UID = "UID";
    let timestamp = 1602221371;
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setTimestamp(timestamp)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID = "UID";
    let timestamp = 1602221371;
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setTimestamp(timestamp)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let UID = "UID";
    let timestamp = 1602221371;
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setTimestamp(timestamp)
      .setLimit(limit)
      .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns messages before the specified timestamp (includes custom message types):

  <span id="filter-timestamp-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                       |
  | ---------------- | ------- | --------------------------------- | -------------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25191"`                                          |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`           |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                                |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                           |
  | `type`           | string  | Message type                      | `"test-custom"`                                    |
  | `category`       | string  | Message category                  | `"custom"`                                         |
  | `customData`     | object  | Custom message data               | [See below ↓](#filter-timestamp-customdata-object) |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771324025`                                       |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771328175`                                       |
  | `readAt`         | number  | Unix timestamp when read          | `1771328175`                                       |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771328175`                                       |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-timestamp-sender-object)     |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-timestamp-receiver-object)   |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-timestamp-data-object)       |
  | `metadata`       | object  | Message metadata                  | Contains `@injected.extensions.link-preview`       |
  | `reactions`      | array   | Message reactions                 | `[]`                                               |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                               |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                            |

  ***

  <span id="filter-timestamp-customdata-object" style={{scrollMarginTop: '100px'}} />

  **`customData` Object (for custom messages):**

  | Parameter   | Type   | Description          | Sample Value                   |
  | ----------- | ------ | -------------------- | ------------------------------ |
  | `greeting`  | string | Custom greeting text | `"Hello from custom message!"` |
  | `timestamp` | number | Custom timestamp     | `1771324022864`                |

  ***

  <span id="filter-timestamp-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"offline"`                                                             |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771323567`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-timestamp-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771323089`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-timestamp-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter    | Type   | Description                  | Sample Value                                 |
  | ------------ | ------ | ---------------------------- | -------------------------------------------- |
  | `customData` | object | Custom message data          | Same as top-level `customData`               |
  | `resource`   | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                  |
  | `entities`   | object | Sender and receiver entities | Contains `sender` and `receiver` wrappers    |
  | `metadata`   | object | Injected metadata            | Contains `@injected.extensions.link-preview` |
</Accordion>

This method can be used along with `setUID()` or `setGUID()` methods to fetch messages after/before any specific date or time for a particular user/group conversation.

## 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. This method takes a boolean value as input. If the value is set to true, the SDK will return just the unread messages.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setUnread(true)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setUnread(true)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID";
    let limit: number = 30;
    let messagesRequest: CometChat.MessagesRequest =
      new CometChat.MessagesRequestBuilder()
        .setUID(UID)
        .setUnread(true)
        .setLimit(limit)
        .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setUnread(true)
          .setLimit(limit)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns only unread messages:

  <span id="filter-unread-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                  |
  | ---------------- | ------- | --------------------------------- | --------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25241"`                                     |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`      |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                           |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                      |
  | `type`           | string  | Message type                      | `"text"`                                      |
  | `category`       | string  | Message category                  | `"message"`                                   |
  | `text`           | string  | Message text content              | `"You there?"`                                |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771413707`                                  |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771413707`                                  |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771413707`                                  |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-unread-sender-object)   |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-unread-receiver-object) |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-unread-data-object)     |
  | `metadata`       | object  | Message metadata                  | Contains `@injected.extensions.link-preview`  |
  | `reactions`      | array   | Message reactions                 | `[]`                                          |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                          |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                       |

  ***

  <span id="filter-unread-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771413285`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-unread-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771413280`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-unread-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter  | Type   | Description                  | Sample Value                                 |
  | ---------- | ------ | ---------------------------- | -------------------------------------------- |
  | `text`     | string | Message text                 | `"You there?"`                               |
  | `resource` | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                  |
  | `entities` | object | Sender and receiver entities | Contains `sender` and `receiver` wrappers    |
  | `metadata` | object | Injected metadata            | Contains `@injected.extensions.link-preview` |
</Accordion>

This method along with `setGUID()` or `setUID()` can be used to fetch unread messages for a particular group or user conversation respectively.

## Exclude messages from blocked users

*In other words, how do I fetch messages excluding the messages from the users I have blocked*

This can be easily achieved using the `hideMessagesFromBlockedUsers()` method. This method accepts a boolean value which determines if the messages from users blocked by the logged-in user need to be a part if the fetched messages. If the value is set to true, the messages will be hidden and won't be a part of the messages fetched. The default value is false i.e if this method is not used, the messages from blocked users will be included in the fetched messages.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .hideMessagesFromBlockedUsers(true)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .hideMessagesFromBlockedUsers(true)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setUID(UID)
          .hideMessagesFromBlockedUsers(true)
          .setLimit(limit)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .hideMessagesFromBlockedUsers(true)
          .setLimit(limit)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns messages excluding those from blocked users (includes group-call custom messages):

  <span id="filter-blocked-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                     |
  | ---------------- | ------- | --------------------------------- | ------------------------------------------------ |
  | `id`             | string  | Unique message identifier         | `"25239"`                                        |
  | `conversationId` | string  | Conversation identifier           | `"group_group_1748415903905"`                    |
  | `receiverId`     | string  | Group's GUID                      | `"group_1748415903905"`                          |
  | `receiverType`   | string  | Type of receiver                  | `"group"`                                        |
  | `type`           | string  | Message type                      | `"group-call"`                                   |
  | `category`       | string  | Message category                  | `"custom"`                                       |
  | `customData`     | object  | Custom message data               | [See below ↓](#filter-blocked-customdata-object) |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771413265`                                     |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771413265`                                     |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-blocked-sender-object)     |
  | `receiver`       | object  | Receiver group details            | [See below ↓](#filter-blocked-receiver-object)   |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-blocked-data-object)       |
  | `metadata`       | object  | Message metadata                  | Contains `@injected.extensions.link-preview`     |
  | `reactions`      | array   | Message reactions                 | `[]`                                             |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                             |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                          |

  ***

  <span id="filter-blocked-customdata-object" style={{scrollMarginTop: '100px'}} />

  **`customData` Object (for group-call):**

  | Parameter   | Type    | Description                         | Sample Value                  |
  | ----------- | ------- | ----------------------------------- | ----------------------------- |
  | `callType`  | string  | Type of call                        | `"audio"`                     |
  | `isCaller`  | boolean | Whether current user initiated call | `true`                        |
  | `sessionId` | string  | Call session identifier             | `"v1.in.2748663902141719..."` |

  ***

  <span id="filter-blocked-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771412068`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-blocked-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object (Group):**

  | Parameter            | Type    | Description                     | Sample Value                  |
  | -------------------- | ------- | ------------------------------- | ----------------------------- |
  | `guid`               | string  | Group's unique identifier       | `"group_1748415903905"`       |
  | `name`               | string  | Group's display name            | `"3 People Group"`            |
  | `type`               | string  | Group type                      | `"public"`                    |
  | `conversationId`     | string  | Conversation identifier         | `"group_group_1748415903905"` |
  | `owner`              | string  | Group owner's UID               | `"123456"`                    |
  | `scope`              | string  | Current user's scope in group   | `"admin"`                     |
  | `membersCount`       | number  | Total members in group          | `12`                          |
  | `onlineMembersCount` | number  | Online members count            | `1`                           |
  | `hasJoined`          | boolean | Whether current user has joined | `true`                        |
  | `isBanned`           | boolean | Whether current user is banned  | `false`                       |
  | `joinedAt`           | number  | Timestamp when user joined      | `1748437105`                  |
  | `createdAt`          | number  | Group creation timestamp        | `1748415957`                  |
  | `updatedAt`          | number  | Group update timestamp          | `1771245340`                  |

  ***

  <span id="filter-blocked-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter    | Type   | Description                  | Sample Value                                          |
  | ------------ | ------ | ---------------------------- | ----------------------------------------------------- |
  | `customData` | object | Custom message data          | Same as top-level `customData`                        |
  | `text`       | string | Display text                 | `"Group video call started. Tap to join!"`            |
  | `resource`   | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                           |
  | `entities`   | object | Sender and receiver entities | Contains `sender` and `receiver` wrappers             |
  | `metadata`   | object | Injected metadata            | Contains `@injected.extensions.link-preview`          |
  | `moderation` | object | Moderation status            | [See below ↓](#filter-blocked-data-moderation-object) |

  ***

  <span id="filter-blocked-data-moderation-object" style={{scrollMarginTop: '100px'}} />

  **`data.moderation` Object:**

  | Parameter | Type   | Description       | Sample Value |
  | --------- | ------ | ----------------- | ------------ |
  | `status`  | string | Moderation status | `"approved"` |
</Accordion>

This method can be used to hide the messages by users blocked by logged in user in groups that both the members are a part of.

## Updated and received messages

*In other words, how do I fetch messages that have been received or updated after a particular date or time*

This method accepts a Unix timestamp value and will return all the messages that have been updated and the ones that have been sent/received after the specified time. The messages updated could mean the messages that have been marked as read/delivered or if the messages are edited or deleted.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let timestamp = 1602221371;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setUpdatedAfter(timestamp)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let timestamp = 1602221371;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setUpdatedAfter(timestamp)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID = "UID";
    let limit = 30;
    let timestamp = 1602221371;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setUpdatedAfter(timestamp)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      timestamp: string = "1602221371",
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setUpdatedAfter(timestamp)
          .setLimit(limit)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchNext()` returns messages received or updated after the specified timestamp:

  <span id="filter-updatedafter-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                        |
  | ---------------- | ------- | --------------------------------- | --------------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25234"`                                           |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`            |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                                 |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                            |
  | `type`           | string  | Message type                      | `"text"`                                            |
  | `category`       | string  | Message category                  | `"message"`                                         |
  | `text`           | string  | Message text content              | `"Nice"`                                            |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771398092`                                        |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771398092`                                        |
  | `readAt`         | number  | Unix timestamp when read          | `1771404705`                                        |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771404705`                                        |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-updatedafter-sender-object)   |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-updatedafter-receiver-object) |
  | `data`           | object  | Additional message data           | Contains `text`, `resource`, `entities`, `metadata` |
  | `metadata`       | object  | Message metadata                  | Contains `@injected.extensions.link-preview`        |
  | `reactions`      | array   | Message reactions                 | `[]`                                                |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                                |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                             |

  ***

  <span id="filter-updatedafter-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771397739`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-updatedafter-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771397762`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |
</Accordion>

This can be useful in finding the messages that have been received or updated after a certain time. Can prove very useful if you are saving the messages locally and would like to know the messages that have been updated or received after the last message available in your local databases.

## Updated messages only

*In other words, how do I fetch messages that have been updated after a particular date or time*

This can be achieved easily by setting the updatesOnly parameter to true. To do so, you can use the updatesOnly() method. This method takes a boolean input and can be used with the `setUpdatedAfter()` method to get just the updated messages and not the messages sent/received after the specified time. This method cannot be used independently and always needs to be used with the `setUpdatedAfter()` method.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let timestamp = 1602221371;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setUpdatedAfter(timestamp)
      .updatesOnly(true)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let timestamp = 1602221371;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setUpdatedAfter(timestamp)
      .updatesOnly(true)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      timestamp: string = "1602221371",
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setUID(UID)
          .setUpdatedAfter(timestamp)
          .updatesOnly(true)
          .setLimit(limit)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      timestamp: string = "1602221371",
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setUpdatedAfter(timestamp)
          .updatesOnly(true)
          .setLimit(limit)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchNext()` returns only updated messages (e.g., read receipt changes, edits, deletions):

  <span id="filter-updatesonly-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                       |
  | ---------------- | ------- | --------------------------------- | -------------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25189"`                                          |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`           |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-3"`                                |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                           |
  | `type`           | string  | Message type                      | `"image"`                                          |
  | `category`       | string  | Message category                  | `"message"`                                        |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771323061`                                       |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771323062`                                       |
  | `readAt`         | number  | Unix timestamp when read          | `1771323227`                                       |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771323227`                                       |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-updatesonly-sender-object)   |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-updatesonly-receiver-object) |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-updatesonly-data-object)     |
  | `reactions`      | array   | Message reactions                 | `[]`                                               |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                               |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                            |

  ***

  <span id="filter-updatesonly-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771323060`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-updatesonly-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"offline"`                                                             |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771322968`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-updatesonly-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object (for image message):**

  | Parameter     | Type   | Description                  | Sample Value                                              |
  | ------------- | ------ | ---------------------------- | --------------------------------------------------------- |
  | `type`        | string | Media type                   | `"image"`                                                 |
  | `category`    | string | Message category             | `"message"`                                               |
  | `url`         | string | Media URL                    | `"https://data-in.cometchat.io/..."`                      |
  | `resource`    | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                               |
  | `attachments` | array  | File attachments             | [See below ↓](#filter-updatesonly-data-attachments-array) |
  | `entities`    | object | Sender and receiver entities | Contains `sender` and `receiver` wrappers                 |
  | `moderation`  | object | Moderation status            | Contains `status: "approved"`                             |

  ***

  <span id="filter-updatesonly-data-attachments-array" style={{scrollMarginTop: '100px'}} />

  **`data.attachments` Array (per item):**

  | Parameter   | Type   | Description        | Sample Value                         |
  | ----------- | ------ | ------------------ | ------------------------------------ |
  | `extension` | string | File extension     | `"png"`                              |
  | `mimeType`  | string | MIME type          | `"image/png"`                        |
  | `name`      | string | File name          | `"photo.png"`                        |
  | `size`      | number | File size in bytes | `2295572`                            |
  | `url`       | string | File URL           | `"https://data-in.cometchat.io/..."` |
</Accordion>

## Messages for multiple categories

*In other words, how do I fetch messages belonging to multiple categories*

We recommend before trying this, you refer to the [Message structure and hierarchy guide](/sdk/react-native/message-structure-and-hierarchy) to get familiar with the various categories of messages.

For this, you will have to use the `setCategories()` method. This method accepts a list of categories. This tells the SDK to fetch messages only belonging to these categories.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let categories = ["message", "custom"];
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setCategories(categories)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let categories = ["message", "custom"];
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setCategories(categories)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      categories: Array<String> = ["message", "custom"],
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setUID(UID)
          .setCategories(categories)
          .setLimit(limit)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      categories: Array<String> = ["message", "custom"],
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setCategories(categories)
          .setLimit(limit)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns messages from the specified categories (includes both `custom` and `message` categories):

  <span id="filter-categories-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                               | Sample Value                                        |
  | ---------------- | ------- | ----------------------------------------- | --------------------------------------------------- |
  | `id`             | string  | Unique message identifier                 | `"25251"`                                           |
  | `conversationId` | string  | Conversation identifier                   | `"cometchat-uid-2_user_cometchat-uid-3"`            |
  | `receiverId`     | string  | Receiver's UID                            | `"cometchat-uid-2"`                                 |
  | `receiverType`   | string  | Type of receiver                          | `"user"`                                            |
  | `type`           | string  | Message type                              | `"extension_poll"` or `"text"`                      |
  | `category`       | string  | Message category                          | `"custom"` or `"message"`                           |
  | `customData`     | object  | Custom message data (for custom category) | [See below ↓](#filter-categories-customdata-object) |
  | `text`           | string  | Message text (for text type)              | `"Hello Message"`                                   |
  | `sentAt`         | number  | Unix timestamp when sent                  | `1771474256`                                        |
  | `deliveredAt`    | number  | Unix timestamp when delivered             | `1771474256`                                        |
  | `readAt`         | number  | Unix timestamp when read                  | `1771474256`                                        |
  | `updatedAt`      | number  | Unix timestamp when updated               | `1771474256`                                        |
  | `sender`         | object  | Sender user details                       | [See below ↓](#filter-categories-sender-object)     |
  | `receiver`       | object  | Receiver user details                     | [See below ↓](#filter-categories-receiver-object)   |
  | `data`           | object  | Additional message data                   | [See below ↓](#filter-categories-data-object)       |
  | `metadata`       | object  | Message metadata                          | [See below ↓](#filter-categories-metadata-object)   |
  | `reactions`      | array   | Message reactions                         | `[]`                                                |
  | `mentionedUsers` | array   | Users mentioned in message                | `[]`                                                |
  | `mentionedMe`    | boolean | Whether current user is mentioned         | `false`                                             |

  ***

  <span id="filter-categories-customdata-object" style={{scrollMarginTop: '100px'}} />

  **`customData` Object (for poll extension):**

  | Parameter  | Type   | Description            | Sample Value                             |
  | ---------- | ------ | ---------------------- | ---------------------------------------- |
  | `id`       | string | Poll unique identifier | `"fde49a5e-baa8-4e04-95e9-c2c09557caa0"` |
  | `question` | string | Poll question          | `"Custom"`                               |
  | `options`  | object | Poll options           | `{"1": "Yes", "2": "No"}`                |

  ***

  <span id="filter-categories-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771474104`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-categories-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"offline"`                                                             |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771474191`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-categories-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter            | Type    | Description                       | Sample Value                              |
  | -------------------- | ------- | --------------------------------- | ----------------------------------------- |
  | `text`               | string  | Display text                      | `"Custom"` or `"Hello Message"`           |
  | `customData`         | object  | Custom data (for custom messages) | Same as top-level `customData`            |
  | `updateConversation` | boolean | Whether to update conversation    | `true`                                    |
  | `resource`           | string  | SDK resource identifier           | `"REACT_NATIVE-4_0_14-..."`               |
  | `entities`           | object  | Sender and receiver entities      | Contains `sender` and `receiver` wrappers |
  | `metadata`           | object  | Injected metadata                 | Contains extensions data                  |

  ***

  <span id="filter-categories-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`metadata` Object (for poll extension):**

  | Parameter              | Type    | Description                       | Sample Value                                               |
  | ---------------------- | ------- | --------------------------------- | ---------------------------------------------------------- |
  | `@injected`            | object  | Injected extensions data          | [See below ↓](#filter-categories-metadata-injected-object) |
  | `incrementUnreadCount` | boolean | Whether to increment unread count | `true`                                                     |
  | `pushNotification`     | string  | Push notification text            | `"Poll: Custom"`                                           |

  ***

  <span id="filter-categories-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description         | Sample Value                                            |
  | -------------- | ------ | ------------------- | ------------------------------------------------------- |
  | `link-preview` | object | Link preview data   | `{"links": []}`                                         |
  | `polls`        | object | Poll extension data | [See below ↓](#filter-categories-metadata-polls-object) |

  ***

  <span id="filter-categories-metadata-polls-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions.polls` Object:**

  | Parameter  | Type   | Description            | Sample Value                             |
  | ---------- | ------ | ---------------------- | ---------------------------------------- |
  | `id`       | string | Poll unique identifier | `"fde49a5e-baa8-4e04-95e9-c2c09557caa0"` |
  | `question` | string | Poll question          | `"Custom"`                               |
  | `options`  | object | Poll options           | `{"1": "Yes", "2": "No"}`                |
  | `results`  | object | Poll results           | Contains `options` and `total`           |
</Accordion>

The above snippet will help you get only the messages belonging to the `message` and `custom` category. This can also be used to disable certain categories of messages like `call` and `action`. This along with `setGUID()` and `setUID()` can help display only the messages you wish to display avoiding the other category of messages.

## Messages for multiple types

*In other words, how do I fetch messages belonging to multiple types*

We recommend before trying this, you refer to the [Message structure and hierarchy guide](/sdk/react-native/message-structure-and-hierarchy) to get familiar with the various types of messages.

This can be easily achieved using the `setTypes()` method. This method accepts a list of types. This tells the SDK to fetch messages only belonging to these types.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let categories = ["message"];
    let types = ["image", "video", "audio", "file"];
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setCategories(categories)
      .setTypes(types)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let categories = ["message"];
    let types = ["image", "video", "audio", "file"];
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setCategories(categories)
      .setTypes(types)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let categories = ["message"];
    let types = ["image", "video", "audio", "file"];
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setCategories(categories)
      .setTypes(types)
      .setLimit(limit)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      categories: Array<String> = ["message", "custom"],
      types: Array<String> = ["image", "video", "audio", "file"],
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setCategories(categories)
          .setTypes(types)
          .setLimit(limit)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns only media messages (image, video, audio, file types):

  <span id="filter-types-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                 |
  | ---------------- | ------- | --------------------------------- | -------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25253"`                                    |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`     |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                          |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                     |
  | `type`           | string  | Message type                      | `"image"` or `"audio"`                       |
  | `category`       | string  | Message category                  | `"message"`                                  |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771474540`                                 |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771474540`                                 |
  | `readAt`         | number  | Unix timestamp when read          | `1771474540`                                 |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771474540`                                 |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-types-sender-object)   |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-types-receiver-object) |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-types-data-object)     |
  | `reactions`      | array   | Message reactions                 | `[]`                                         |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                         |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                      |

  ***

  <span id="filter-types-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"offline"`                                                             |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771474535`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-types-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"offline"`                                                             |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771474191`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-types-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object (for media messages):**

  | Parameter     | Type   | Description                  | Sample Value                                        |
  | ------------- | ------ | ---------------------------- | --------------------------------------------------- |
  | `type`        | string | Media type                   | `"image"` or `"audio"`                              |
  | `category`    | string | Message category             | `"message"`                                         |
  | `url`         | string | Media URL                    | `"https://data-in.cometchat.io/..."`                |
  | `resource`    | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                         |
  | `attachments` | array  | File attachments             | [See below ↓](#filter-types-data-attachments-array) |
  | `entities`    | object | Sender and receiver entities | Contains `sender` and `receiver` wrappers           |

  ***

  <span id="filter-types-data-attachments-array" style={{scrollMarginTop: '100px'}} />

  **`data.attachments` Array (per item):**

  | Parameter   | Type   | Description        | Sample Value                          |
  | ----------- | ------ | ------------------ | ------------------------------------- |
  | `extension` | string | File extension     | `"jpg"` or `"ogg"`                    |
  | `mimeType`  | string | MIME type          | `"image/jpeg"` or `"application/ogg"` |
  | `name`      | string | File name          | `"photo.jpg"` or `"audio.ogg"`        |
  | `size`      | number | File size in bytes | `142099`                              |
  | `url`       | string | File URL           | `"https://data-in.cometchat.io/..."`  |
</Accordion>

Using the above code snippet, you can fetch all the media messages. This along with setUID() or setGUID() can be used to fetch media messages for any particular conversation. This can be useful in many other scenarios as well.

## Messages for a specific thread

*In other words, how do I fetch messages that are a part of a thread and not directly a user/group conversation*

This can be done using the `setParentMessageId()` method. This method needs to be used when you have implemented threaded conversations in your app. This method will return the messages only belonging to the thread with the specified parent Id.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let messageId = 1; // Use msg.getId() on a message where msg.getReplyCount() > 0
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setLimit(limit)
      .setParentMessageId(messageId)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let messageId = 1; // Use msg.getId() on a message where msg.getReplyCount() > 0
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setLimit(limit)
      .setParentMessageId(messageId)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      messageId: number = 1, // Use msg.getId() on a message where msg.getReplyCount() > 0
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setUID(UID)
          .setLimit(limit)
          .setParentMessageId(messageId)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      messageId: number = 1, // Use msg.getId() on a message where msg.getReplyCount() > 0
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setLimit(limit)
          .setParentMessageId(messageId)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns messages belonging to the specified thread:

  <span id="filter-thread-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter         | Type    | Description                       | Sample Value                                        |
  | ----------------- | ------- | --------------------------------- | --------------------------------------------------- |
  | `id`              | string  | Unique message identifier         | `"25257"`                                           |
  | `conversationId`  | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`            |
  | `receiverId`      | string  | Receiver's UID                    | `"cometchat-uid-2"`                                 |
  | `receiverType`    | string  | Type of receiver                  | `"user"`                                            |
  | `type`            | string  | Message type                      | `"text"`                                            |
  | `category`        | string  | Message category                  | `"message"`                                         |
  | `text`            | string  | Message text content              | `"Thread Message"`                                  |
  | `parentMessageId` | string  | Parent message ID (thread root)   | `"25256"`                                           |
  | `sentAt`          | number  | Unix timestamp when sent          | `1771476403`                                        |
  | `deliveredAt`     | number  | Unix timestamp when delivered     | `1771476404`                                        |
  | `readAt`          | number  | Unix timestamp when read          | `1771476404`                                        |
  | `updatedAt`       | number  | Unix timestamp when updated       | `1771476404`                                        |
  | `sender`          | object  | Sender user details               | [See below ↓](#filter-thread-sender-object)         |
  | `receiver`        | object  | Receiver user details             | [See below ↓](#filter-thread-receiver-object)       |
  | `data`            | object  | Additional message data           | Contains `text`, `resource`, `entities`, `metadata` |
  | `metadata`        | object  | Message metadata                  | Contains `@injected.extensions.link-preview`        |
  | `reactions`       | array   | Message reactions                 | `[]`                                                |
  | `mentionedUsers`  | array   | Users mentioned in message        | `[]`                                                |
  | `mentionedMe`     | boolean | Whether current user is mentioned | `false`                                             |

  ***

  <span id="filter-thread-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771475038`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-thread-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771475047`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |
</Accordion>

The above code snippet returns the messages that belong to the thread with parent id 100.

## Hide threaded messages in user/group conversations

*In other words, how do I exclude threaded messages from the normal user/group conversations*

In order to do this, you can use the `hideReplies()` method. This method is also related to threaded conversations. This method takes boolean as input. This boolean when set to true will make sure that the messages that belong to threads are not fetched. If set to false, which is also the default value, the messages belong to the threads will also be fetched along with other messages.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setLimit(limit)
      .hideReplies(true)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setLimit(limit)
      .hideReplies(true)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setUID(UID)
          .setLimit(limit)
          .hideReplies(true)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setLimit(limit)
          .hideReplies(true)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns messages excluding threaded replies (parent messages with threads still appear):

  <span id="filter-hidereplies-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                             | Sample Value                                                         |
  | ---------------- | ------- | --------------------------------------- | -------------------------------------------------------------------- |
  | `id`             | string  | Unique message identifier               | `"25256"`                                                            |
  | `conversationId` | string  | Conversation identifier                 | `"cometchat-uid-2_user_cometchat-uid-3"`                             |
  | `receiverId`     | string  | Receiver's UID                          | `"cometchat-uid-2"`                                                  |
  | `receiverType`   | string  | Type of receiver                        | `"user"`                                                             |
  | `type`           | string  | Message type                            | `"text"` or `"audio"`                                                |
  | `category`       | string  | Message category                        | `"message"`                                                          |
  | `text`           | string  | Message text content                    | `"New Message for Thread"`                                           |
  | `replyCount`     | number  | Number of replies (for parent messages) | `1`                                                                  |
  | `sentAt`         | number  | Unix timestamp when sent                | `1771476391`                                                         |
  | `deliveredAt`    | number  | Unix timestamp when delivered           | `1771476392`                                                         |
  | `readAt`         | number  | Unix timestamp when read                | `1771476392`                                                         |
  | `updatedAt`      | number  | Unix timestamp when updated             | `1771476392`                                                         |
  | `sender`         | object  | Sender user details                     | [See below ↓](#filter-hidereplies-sender-object)                     |
  | `receiver`       | object  | Receiver user details                   | [See below ↓](#filter-hidereplies-receiver-object)                   |
  | `data`           | object  | Additional message data                 | Contains `text`, `resource`, `entities`, `metadata` or `attachments` |
  | `metadata`       | object  | Message metadata                        | Contains `@injected.extensions.link-preview`                         |
  | `reactions`      | array   | Message reactions                       | `[]`                                                                 |
  | `mentionedUsers` | array   | Users mentioned in message              | `[]`                                                                 |
  | `mentionedMe`    | boolean | Whether current user is mentioned       | `false`                                                              |

  ***

  <span id="filter-hidereplies-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771475038`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-hidereplies-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771475047`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |
</Accordion>

## Hide deleted messages in user/group conversations

*In other words, how do I exclude deleted messages from a user/group conversation*

In order to do this, you can use the `hideDeletedMessages()` method. This method takes boolean as input. This boolean when set to true will make sure that the deleted messages are not fetched. If set to false, which is also the default value, the deleted messages will also be fetched along with other messages.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setLimit(limit)
      .hideDeletedMessages(true)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setLimit(limit)
      .hideDeletedMessages(true)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setUID(UID)
          .setLimit(limit)
          .hideDeletedMessages(true)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setLimit(limit)
          .hideDeletedMessages(true)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns messages excluding deleted messages:

  <span id="filter-hidedeleted-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter         | Type    | Description                           | Sample Value                                        |
  | ----------------- | ------- | ------------------------------------- | --------------------------------------------------- |
  | `id`              | string  | Unique message identifier             | `"25256"`                                           |
  | `conversationId`  | string  | Conversation identifier               | `"cometchat-uid-2_user_cometchat-uid-3"`            |
  | `receiverId`      | string  | Receiver's UID                        | `"cometchat-uid-2"`                                 |
  | `receiverType`    | string  | Type of receiver                      | `"user"`                                            |
  | `type`            | string  | Message type                          | `"text"`                                            |
  | `category`        | string  | Message category                      | `"message"`                                         |
  | `text`            | string  | Message text content                  | `"New Message for Thread"`                          |
  | `replyCount`      | number  | Number of replies (if parent message) | `1`                                                 |
  | `parentMessageId` | string  | Parent message ID (if threaded reply) | `"25256"`                                           |
  | `sentAt`          | number  | Unix timestamp when sent              | `1771476391`                                        |
  | `deliveredAt`     | number  | Unix timestamp when delivered         | `1771476392`                                        |
  | `readAt`          | number  | Unix timestamp when read              | `1771476392`                                        |
  | `updatedAt`       | number  | Unix timestamp when updated           | `1771476392`                                        |
  | `sender`          | object  | Sender user details                   | [See below ↓](#filter-hidedeleted-sender-object)    |
  | `receiver`        | object  | Receiver user details                 | [See below ↓](#filter-hidedeleted-receiver-object)  |
  | `data`            | object  | Additional message data               | Contains `text`, `resource`, `entities`, `metadata` |
  | `metadata`        | object  | Message metadata                      | Contains `@injected.extensions.link-preview`        |
  | `reactions`       | array   | Message reactions                     | `[]`                                                |
  | `mentionedUsers`  | array   | Users mentioned in message            | `[]`                                                |
  | `mentionedMe`     | boolean | Whether current user is mentioned     | `false`                                             |

  ***

  <span id="filter-hidedeleted-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771475038`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-hidedeleted-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771475047`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |
</Accordion>

## Messages by tags

*In other words, how do I fetch messages by tags*

In order to do this, you can use the `setTags()` method. This method accepts a list of tags. This tells the SDK to fetch messages only belonging to these tags.

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let tags = ["starredMessage"];
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setLimit(limit)
      .setTags(tags)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let tags = ["starredMessage"];
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setLimit(limit)
      .setTags(tags)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      tags: Array<String> = ["starredMessage"],
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setUID(UID)
          .setLimit(limit)
          .setTags(tags)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      tags: Array<String> = ["starredMessage"],
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setLimit(limit)
          .setTags(tags)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns only messages matching the specified tags:

  <span id="filter-settags-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                        |
  | ---------------- | ------- | --------------------------------- | --------------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25259"`                                           |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`            |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                                 |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                            |
  | `type`           | string  | Message type                      | `"text"`                                            |
  | `category`       | string  | Message category                  | `"message"`                                         |
  | `text`           | string  | Message text content              | `"Tagged message for docs"`                         |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771478898`                                        |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771478900`                                        |
  | `readAt`         | number  | Unix timestamp when read          | `1771478900`                                        |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771478900`                                        |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-settags-sender-object)        |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-settags-receiver-object)      |
  | `data`           | object  | Additional message data           | Contains `text`, `resource`, `entities`, `metadata` |
  | `metadata`       | object  | Message metadata                  | Contains `@injected.extensions.link-preview`        |
  | `reactions`      | array   | Message reactions                 | `[]`                                                |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                                |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                             |

  ***

  <span id="filter-settags-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771478591`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-settags-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"offline"`                                                             |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771477541`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |
</Accordion>

## Messages with tags

*In other words, how do I fetch messages with the tags information*

In order to do this, you can use the `withTags()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages along with the tags. When set to `false` , the SDK will not fetch tags associated with messages. The default value for this parameter is `false` .

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setLimit(limit)
      .withTags(true)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setLimit(limit)
      .withTags(tags)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(UID)
          .setLimit(limit)
          .withTags(true)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setLimit(limit)
          .withTags(true)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns messages with the `tags` field included:

  <span id="filter-withtags-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                                      |
  | ---------------- | ------- | --------------------------------- | ----------------------------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25265"`                                                         |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`                          |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-3"`                                               |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                                          |
  | `type`           | string  | Message type                      | `"text"`                                                          |
  | `category`       | string  | Message category                  | `"message"`                                                       |
  | `text`           | string  | Message text content              | `"Tagged message for docs"`                                       |
  | `tags`           | array   | Message tags                      | `["starredMessage"]`                                              |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771481257`                                                      |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771481257`                                                      |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-withtags-sender-object)                     |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-withtags-receiver-object)                   |
  | `data`           | object  | Additional message data           | Contains `text`, `resource`, `entities`, `metadata`, `moderation` |
  | `metadata`       | object  | Message metadata                  | Contains `@injected.extensions.link-preview`                      |
  | `reactions`      | array   | Message reactions                 | `[]`                                                              |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                                              |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                                           |

  ***

  <span id="filter-withtags-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771480243`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-withtags-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771480251`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |
</Accordion>

## Messages with links

*In other words, as a logged-in user, how do I fetch messages that contain links?*

In order to do this, you can use the `hasLinks()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages which have links in the text. The default value for this parameter is `false`.

<Note>
  This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration)
</Note>

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setLimit(limit)
      .hasLinks(true)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setLimit(limit)
      .hasLinks(true)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(UID)
          .setLimit(limit)
          .hasLinks(true)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setLimit(limit)
          .hasLinks(true)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns an array of `Message` objects containing links:

  <span id="filter-haslinks-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                          |
  | ---------------- | ------- | --------------------------------- | ----------------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25269"`                                             |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`              |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                                   |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                              |
  | `type`           | string  | Message type                      | `"text"`                                              |
  | `category`       | string  | Message category                  | `"message"`                                           |
  | `text`           | string  | Message text content              | `"Please checkout our website https://cometchat.com"` |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771481824`                                          |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771481825`                                          |
  | `readAt`         | number  | Unix timestamp when read          | `1771481825`                                          |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771481825`                                          |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-haslinks-sender-object)         |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-haslinks-receiver-object)       |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-haslinks-data-object)           |
  | `metadata`       | object  | Message metadata                  | [See below ↓](#filter-haslinks-metadata-object)       |
  | `reactions`      | array   | Message reactions                 | `[]`                                                  |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                                  |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                               |

  ***

  <span id="filter-haslinks-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771480251`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-haslinks-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771480243`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-haslinks-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter  | Type   | Description                  | Sample Value                                          |
  | ---------- | ------ | ---------------------------- | ----------------------------------------------------- |
  | `text`     | string | Message text                 | `"Please checkout our website https://cometchat.com"` |
  | `resource` | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                           |
  | `entities` | object | Sender and receiver entities | [See below ↓](#filter-haslinks-data-entities-object)  |
  | `metadata` | object | Injected metadata            | [See below ↓](#filter-haslinks-data-metadata-object)  |

  ***

  <span id="filter-haslinks-data-entities-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities` Object:**

  | Parameter  | Type   | Description             | Sample Value                                                  |
  | ---------- | ------ | ----------------------- | ------------------------------------------------------------- |
  | `sender`   | object | Sender entity wrapper   | [See below ↓](#filter-haslinks-data-entities-sender-object)   |
  | `receiver` | object | Receiver entity wrapper | [See below ↓](#filter-haslinks-data-entities-receiver-object) |

  ***

  <span id="filter-haslinks-data-entities-sender-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                       |
  | ------------ | ------ | ------------------- | ------------------------------------------------------------------ |
  | `entityType` | string | Type of entity      | `"user"`                                                           |
  | `entity`     | object | User entity details | [See below ↓](#filter-haslinks-data-entities-sender-entity-object) |

  ***

  <span id="filter-haslinks-data-entities-sender-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender.entity` Object:**

  | Parameter      | Type   | Description              | Sample Value                                                            |
  | -------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`          | string | User's unique identifier | `"cometchat-uid-3"`                                                     |
  | `name`         | string | User's display name      | `"Nancy Grace"`                                                         |
  | `avatar`       | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`       | string | User's online status     | `"online"`                                                              |
  | `role`         | string | User's role              | `"default"`                                                             |
  | `lastActiveAt` | number | Last active timestamp    | `1771480251`                                                            |
  | `tags`         | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-haslinks-data-entities-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                         |
  | ------------ | ------ | ------------------- | -------------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                             |
  | `entity`     | object | User entity details | [See below ↓](#filter-haslinks-data-entities-receiver-entity-object) |

  ***

  <span id="filter-haslinks-data-entities-receiver-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver.entity` Object:**

  | Parameter        | Type   | Description              | Sample Value                                                            |
  | ---------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`            | string | User's unique identifier | `"cometchat-uid-2"`                                                     |
  | `name`           | string | User's display name      | `"George Alan"`                                                         |
  | `avatar`         | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`         | string | User's online status     | `"online"`                                                              |
  | `role`           | string | User's role              | `"default"`                                                             |
  | `lastActiveAt`   | number | Last active timestamp    | `1771480243`                                                            |
  | `conversationId` | string | Conversation identifier  | `"cometchat-uid-2_user_cometchat-uid-3"`                                |
  | `tags`           | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-haslinks-data-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata` Object:**

  | Parameter   | Type   | Description              | Sample Value                                                  |
  | ----------- | ------ | ------------------------ | ------------------------------------------------------------- |
  | `@injected` | object | Injected extensions data | [See below ↓](#filter-haslinks-data-metadata-injected-object) |

  ***

  <span id="filter-haslinks-data-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected` Object:**

  | Parameter    | Type   | Description     | Sample Value                                                    |
  | ------------ | ------ | --------------- | --------------------------------------------------------------- |
  | `extensions` | object | Extensions data | [See below ↓](#filter-haslinks-data-metadata-extensions-object) |

  ***

  <span id="filter-haslinks-data-metadata-extensions-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description                 | Sample Value                                                     |
  | -------------- | ------ | --------------------------- | ---------------------------------------------------------------- |
  | `link-preview` | object | Link preview extension data | [See below ↓](#filter-haslinks-data-metadata-linkpreview-object) |

  ***

  <span id="filter-haslinks-data-metadata-linkpreview-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions.link-preview` Object:**

  | Parameter | Type  | Description            | Sample Value                                              |
  | --------- | ----- | ---------------------- | --------------------------------------------------------- |
  | `links`   | array | Array of link previews | [See below ↓](#filter-haslinks-data-metadata-links-array) |

  ***

  <span id="filter-haslinks-data-metadata-links-array" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions.link-preview.links` Array (per item):**

  | Parameter     | Type   | Description                  | Sample Value                                                                              |
  | ------------- | ------ | ---------------------------- | ----------------------------------------------------------------------------------------- |
  | `url`         | string | The URL found in the message | `"https://cometchat.com"`                                                                 |
  | `title`       | string | Page title                   | `"In-app Chat SDK & API For Messaging And Calling - CometChat"`                           |
  | `description` | string | Page description             | `"Build real time chat, voice and video calling experience..."`                           |
  | `favicon`     | string | URL to site favicon          | `"https://cometchat.com/_static/favicon.png"`                                             |
  | `image`       | string | URL to preview image         | `"https://a.storyblok.com/f/231922/1200x630/d639d0748b/open-graph-image.png/m/1200x630/"` |

  ***

  <span id="filter-haslinks-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`metadata` Object:**

  | Parameter   | Type   | Description              | Sample Value                                             |
  | ----------- | ------ | ------------------------ | -------------------------------------------------------- |
  | `@injected` | object | Injected extensions data | [See below ↓](#filter-haslinks-metadata-injected-object) |

  ***

  <span id="filter-haslinks-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected` Object:**

  | Parameter    | Type   | Description     | Sample Value                                               |
  | ------------ | ------ | --------------- | ---------------------------------------------------------- |
  | `extensions` | object | Extensions data | [See below ↓](#filter-haslinks-metadata-extensions-object) |

  ***

  <span id="filter-haslinks-metadata-extensions-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description            | Sample Value                                                |
  | -------------- | ------ | ---------------------- | ----------------------------------------------------------- |
  | `link-preview` | object | Link preview extension | [See below ↓](#filter-haslinks-metadata-linkpreview-object) |

  ***

  <span id="filter-haslinks-metadata-linkpreview-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions.link-preview` Object:**

  | Parameter | Type  | Description            | Sample Value                                         |
  | --------- | ----- | ---------------------- | ---------------------------------------------------- |
  | `links`   | array | Array of link previews | [See below ↓](#filter-haslinks-metadata-links-array) |

  ***

  <span id="filter-haslinks-metadata-links-array" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions.link-preview.links` Array (per item):**

  | Parameter     | Type   | Description                  | Sample Value                                                                              |
  | ------------- | ------ | ---------------------------- | ----------------------------------------------------------------------------------------- |
  | `url`         | string | The URL found in the message | `"https://cometchat.com"`                                                                 |
  | `title`       | string | Page title                   | `"In-app Chat SDK & API For Messaging And Calling - CometChat"`                           |
  | `description` | string | Page description             | `"Build real time chat, voice and video calling experience..."`                           |
  | `favicon`     | string | URL to site favicon          | `"https://cometchat.com/_static/favicon.png"`                                             |
  | `image`       | string | URL to preview image         | `"https://a.storyblok.com/f/231922/1200x630/d639d0748b/open-graph-image.png/m/1200x630/"` |
</Accordion>

## Messages with attachments

*In other words, as a logged-in user, how do I fetch messages that contain attachments?*

In order to do this, you can use the `hasAttachments()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages which have attachments (image, audio, video or file). The default value for this parameter is `false`.

<Note>
  This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration)
</Note>

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setLimit(limit)
      .hasAttachments(true)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setLimit(limit)
      .hasAttachments(true)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(UID)
          .setLimit(limit)
          .hasAttachments(true)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setLimit(limit)
          .hasAttachments(true)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns an array of `Message` objects with attachments:

  <span id="filter-attachments-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                       |
  | ---------------- | ------- | --------------------------------- | -------------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25253"`                                          |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`           |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                                |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                           |
  | `type`           | string  | Message type                      | `"image"`                                          |
  | `category`       | string  | Message category                  | `"message"`                                        |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771474540`                                       |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771474540`                                       |
  | `readAt`         | number  | Unix timestamp when read          | `1771474540`                                       |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771474540`                                       |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-attachments-sender-object)   |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-attachments-receiver-object) |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-attachments-data-object)     |
  | `reactions`      | array   | Message reactions                 | `[]`                                               |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                               |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                            |

  ***

  <span id="filter-attachments-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"offline"`                                                             |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771474535`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-attachments-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"offline"`                                                             |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771474191`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-attachments-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter     | Type   | Description                  | Sample Value                                                |
  | ------------- | ------ | ---------------------------- | ----------------------------------------------------------- |
  | `type`        | string | Attachment type              | `"image"`                                                   |
  | `category`    | string | Message category             | `"message"`                                                 |
  | `url`         | string | URL to the attachment        | `"https://data-in.cometchat.io/2748663902141719/media/..."` |
  | `resource`    | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                                 |
  | `attachments` | array  | Array of attachment objects  | [See below ↓](#filter-attachments-data-attachments-array)   |
  | `entities`    | object | Sender and receiver entities | [See below ↓](#filter-attachments-data-entities-object)     |

  ***

  <span id="filter-attachments-data-attachments-array" style={{scrollMarginTop: '100px'}} />

  **`data.attachments` Array (per item):**

  | Parameter   | Type   | Description           | Sample Value                                                |
  | ----------- | ------ | --------------------- | ----------------------------------------------------------- |
  | `extension` | string | File extension        | `"jpg"`                                                     |
  | `mimeType`  | string | MIME type of the file | `"image/jpeg"`                                              |
  | `name`      | string | File name             | `"IMG_20260217_150412.jpg"`                                 |
  | `size`      | number | File size in bytes    | `142099`                                                    |
  | `url`       | string | URL to the attachment | `"https://data-in.cometchat.io/2748663902141719/media/..."` |

  ***

  <span id="filter-attachments-data-entities-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities` Object:**

  | Parameter  | Type   | Description             | Sample Value                                                     |
  | ---------- | ------ | ----------------------- | ---------------------------------------------------------------- |
  | `sender`   | object | Sender entity wrapper   | [See below ↓](#filter-attachments-data-entities-sender-object)   |
  | `receiver` | object | Receiver entity wrapper | [See below ↓](#filter-attachments-data-entities-receiver-object) |

  ***

  <span id="filter-attachments-data-entities-sender-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                          |
  | ------------ | ------ | ------------------- | --------------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                              |
  | `entity`     | object | User entity details | [See below ↓](#filter-attachments-data-entities-sender-entity-object) |

  ***

  <span id="filter-attachments-data-entities-sender-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender.entity` Object:**

  | Parameter      | Type   | Description              | Sample Value                                                            |
  | -------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`          | string | User's unique identifier | `"cometchat-uid-3"`                                                     |
  | `name`         | string | User's display name      | `"Nancy Grace"`                                                         |
  | `avatar`       | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`       | string | User's online status     | `"offline"`                                                             |
  | `role`         | string | User's role              | `"default"`                                                             |
  | `lastActiveAt` | number | Last active timestamp    | `1771474535`                                                            |
  | `tags`         | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-attachments-data-entities-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                            |
  | ------------ | ------ | ------------------- | ----------------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                                |
  | `entity`     | object | User entity details | [See below ↓](#filter-attachments-data-entities-receiver-entity-object) |

  ***

  <span id="filter-attachments-data-entities-receiver-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver.entity` Object:**

  | Parameter        | Type   | Description              | Sample Value                                                            |
  | ---------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`            | string | User's unique identifier | `"cometchat-uid-2"`                                                     |
  | `name`           | string | User's display name      | `"George Alan"`                                                         |
  | `avatar`         | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`         | string | User's online status     | `"offline"`                                                             |
  | `role`           | string | User's role              | `"default"`                                                             |
  | `lastActiveAt`   | number | Last active timestamp    | `1771474191`                                                            |
  | `conversationId` | string | Conversation identifier  | `"cometchat-uid-2_user_cometchat-uid-3"`                                |
  | `tags`           | array  | User tags                | `[]`                                                                    |
</Accordion>

## Messages with reactions

*In other words, as a logged-in user, how do I fetch messages that contain reactions?*

In order to do this, you can use the `hasReactions()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages which have reactions. The default value for this parameter is `false`.

<Note>
  This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration)
</Note>

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setLimit(limit)
      .hasReactions(true)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setLimit(limit)
      .hasReactions(true)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(UID)
          .setLimit(limit)
          .hasReactions(true)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setLimit(limit)
          .hasReactions(true)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns an array of `Message` objects with reactions:

  <span id="filter-reactions-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                     |
  | ---------------- | ------- | --------------------------------- | ------------------------------------------------ |
  | `id`             | string  | Unique message identifier         | `"25275"`                                        |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`         |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                              |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                         |
  | `type`           | string  | Message type                      | `"text"`                                         |
  | `category`       | string  | Message category                  | `"message"`                                      |
  | `text`           | string  | Message text content              | `"Message with reactions"`                       |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771495045`                                     |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771495045`                                     |
  | `readAt`         | number  | Unix timestamp when read          | `1771495045`                                     |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771495045`                                     |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-reactions-sender-object)   |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-reactions-receiver-object) |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-reactions-data-object)     |
  | `metadata`       | object  | Message metadata                  | [See below ↓](#filter-reactions-metadata-object) |
  | `reactions`      | array   | Message reactions                 | `[]`                                             |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                             |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                          |

  ***

  <span id="filter-reactions-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771495034`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-reactions-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771494233`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-reactions-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter   | Type   | Description                  | Sample Value                                          |
  | ----------- | ------ | ---------------------------- | ----------------------------------------------------- |
  | `text`      | string | Message text                 | `"Message with reactions"`                            |
  | `resource`  | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                           |
  | `reactions` | array  | Reactions on the message     | [See below ↓](#filter-reactions-data-reactions-array) |
  | `entities`  | object | Sender and receiver entities | [See below ↓](#filter-reactions-data-entities-object) |
  | `metadata`  | object | Injected metadata            | [See below ↓](#filter-reactions-data-metadata-object) |

  ***

  <span id="filter-reactions-data-reactions-array" style={{scrollMarginTop: '100px'}} />

  **`data.reactions` Array (per item):**

  | Parameter     | Type    | Description                             | Sample Value |
  | ------------- | ------- | --------------------------------------- | ------------ |
  | `reaction`    | string  | The reaction emoji                      | `"❤️"`       |
  | `count`       | number  | Number of users who reacted             | `1`          |
  | `reactedByMe` | boolean | Whether current user reacted (optional) | `true`       |

  ***

  <span id="filter-reactions-data-entities-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities` Object:**

  | Parameter  | Type   | Description             | Sample Value                                                   |
  | ---------- | ------ | ----------------------- | -------------------------------------------------------------- |
  | `sender`   | object | Sender entity wrapper   | [See below ↓](#filter-reactions-data-entities-sender-object)   |
  | `receiver` | object | Receiver entity wrapper | [See below ↓](#filter-reactions-data-entities-receiver-object) |

  ***

  <span id="filter-reactions-data-entities-sender-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                        |
  | ------------ | ------ | ------------------- | ------------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                            |
  | `entity`     | object | User entity details | [See below ↓](#filter-reactions-data-entities-sender-entity-object) |

  ***

  <span id="filter-reactions-data-entities-sender-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender.entity` Object:**

  | Parameter      | Type   | Description              | Sample Value                                                            |
  | -------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`          | string | User's unique identifier | `"cometchat-uid-3"`                                                     |
  | `name`         | string | User's display name      | `"Nancy Grace"`                                                         |
  | `avatar`       | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`       | string | User's online status     | `"online"`                                                              |
  | `role`         | string | User's role              | `"default"`                                                             |
  | `lastActiveAt` | number | Last active timestamp    | `1771495034`                                                            |
  | `tags`         | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-reactions-data-entities-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                          |
  | ------------ | ------ | ------------------- | --------------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                              |
  | `entity`     | object | User entity details | [See below ↓](#filter-reactions-data-entities-receiver-entity-object) |

  ***

  <span id="filter-reactions-data-entities-receiver-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver.entity` Object:**

  | Parameter        | Type   | Description              | Sample Value                                                            |
  | ---------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`            | string | User's unique identifier | `"cometchat-uid-2"`                                                     |
  | `name`           | string | User's display name      | `"George Alan"`                                                         |
  | `avatar`         | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`         | string | User's online status     | `"online"`                                                              |
  | `role`           | string | User's role              | `"default"`                                                             |
  | `lastActiveAt`   | number | Last active timestamp    | `1771494233`                                                            |
  | `conversationId` | string | Conversation identifier  | `"cometchat-uid-2_user_cometchat-uid-3"`                                |
  | `tags`           | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-reactions-data-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata` Object:**

  | Parameter   | Type   | Description              | Sample Value                                                   |
  | ----------- | ------ | ------------------------ | -------------------------------------------------------------- |
  | `@injected` | object | Injected extensions data | [See below ↓](#filter-reactions-data-metadata-injected-object) |

  ***

  <span id="filter-reactions-data-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected` Object:**

  | Parameter    | Type   | Description     | Sample Value                                                     |
  | ------------ | ------ | --------------- | ---------------------------------------------------------------- |
  | `extensions` | object | Extensions data | [See below ↓](#filter-reactions-data-metadata-extensions-object) |

  ***

  <span id="filter-reactions-data-metadata-extensions-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description                 | Sample Value                                                      |
  | -------------- | ------ | --------------------------- | ----------------------------------------------------------------- |
  | `link-preview` | object | Link preview extension data | [See below ↓](#filter-reactions-data-metadata-linkpreview-object) |

  ***

  <span id="filter-reactions-data-metadata-linkpreview-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions.link-preview` Object:**

  | Parameter | Type  | Description     | Sample Value |
  | --------- | ----- | --------------- | ------------ |
  | `links`   | array | Extracted links | `[]`         |

  ***

  <span id="filter-reactions-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`metadata` Object:**

  | Parameter   | Type   | Description              | Sample Value                                              |
  | ----------- | ------ | ------------------------ | --------------------------------------------------------- |
  | `@injected` | object | Injected extensions data | [See below ↓](#filter-reactions-metadata-injected-object) |

  ***

  <span id="filter-reactions-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected` Object:**

  | Parameter    | Type   | Description     | Sample Value                                                |
  | ------------ | ------ | --------------- | ----------------------------------------------------------- |
  | `extensions` | object | Extensions data | [See below ↓](#filter-reactions-metadata-extensions-object) |

  ***

  <span id="filter-reactions-metadata-extensions-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description                 | Sample Value                                                 |
  | -------------- | ------ | --------------------------- | ------------------------------------------------------------ |
  | `link-preview` | object | Link preview extension data | [See below ↓](#filter-reactions-metadata-linkpreview-object) |

  ***

  <span id="filter-reactions-metadata-linkpreview-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions.link-preview` Object:**

  | Parameter | Type  | Description     | Sample Value |
  | --------- | ----- | --------------- | ------------ |
  | `links`   | array | Extracted links | `[]`         |
</Accordion>

## Messages with mentions

*In other words, as a logged-in user, how do I fetch messages that contain mentions?*

In order to do this, you can use the `hasMentions()` method. This method accepts boolean as input. When set to `true` , the SDK will fetch messages which have mentions. The default value for this parameter is `false`.

<Note>
  This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration)
</Note>

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setLimit(limit)
      .hasMentions(true)
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setLimit(limit)
      .hasMentions(true)
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(UID)
          .setLimit(limit)
          .hasMentions(true)
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setLimit(limit)
          .hasMentions(true)
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns an array of `Message` objects containing mentions:

  <span id="filter-mentions-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                         |
  | ---------------- | ------- | --------------------------------- | ---------------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25271"`                                            |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`             |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                                  |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                             |
  | `type`           | string  | Message type                      | `"text"`                                             |
  | `category`       | string  | Message category                  | `"message"`                                          |
  | `text`           | string  | Message text content              | `"<@uid:cometchat-uid-2> Hello"`                     |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771482742`                                         |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771482743`                                         |
  | `readAt`         | number  | Unix timestamp when read          | `1771482743`                                         |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771482743`                                         |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-mentions-sender-object)        |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-mentions-receiver-object)      |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-mentions-data-object)          |
  | `metadata`       | object  | Message metadata                  | [See below ↓](#filter-mentions-metadata-object)      |
  | `reactions`      | array   | Message reactions                 | `[]`                                                 |
  | `mentionedUsers` | array   | Users mentioned in message        | [See below ↓](#filter-mentions-mentionedusers-array) |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `true`                                               |

  ***

  <span id="filter-mentions-mentionedusers-array" style={{scrollMarginTop: '100px'}} />

  **`mentionedUsers` Array (per item):**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771494233`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |

  ***

  <span id="filter-mentions-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771482552`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-mentions-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771482544`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-mentions-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter  | Type   | Description                   | Sample Value                                         |
  | ---------- | ------ | ----------------------------- | ---------------------------------------------------- |
  | `text`     | string | Message text                  | `"<@uid:cometchat-uid-2> Hello"`                     |
  | `resource` | string | SDK resource identifier       | `"REACT_NATIVE-4_0_14-..."`                          |
  | `mentions` | object | Map of mentioned users by UID | [See below ↓](#filter-mentions-data-mentions-object) |
  | `entities` | object | Sender and receiver entities  | [See below ↓](#filter-mentions-data-entities-object) |
  | `metadata` | object | Injected metadata             | [See below ↓](#filter-mentions-data-metadata-object) |

  ***

  <span id="filter-mentions-data-mentions-object" style={{scrollMarginTop: '100px'}} />

  **`data.mentions` Object (keyed by UID):**

  | Parameter      | Type   | Description              | Sample Value                                                            |
  | -------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`          | string | User's unique identifier | `"cometchat-uid-2"`                                                     |
  | `name`         | string | User's display name      | `"George Alan"`                                                         |
  | `avatar`       | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`       | string | User's online status     | `"online"`                                                              |
  | `role`         | string | User's role              | `"default"`                                                             |
  | `lastActiveAt` | number | Last active timestamp    | `1771494233`                                                            |

  ***

  <span id="filter-mentions-data-entities-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities` Object:**

  | Parameter  | Type   | Description             | Sample Value                                                  |
  | ---------- | ------ | ----------------------- | ------------------------------------------------------------- |
  | `sender`   | object | Sender entity wrapper   | [See below ↓](#filter-mentions-data-entities-sender-object)   |
  | `receiver` | object | Receiver entity wrapper | [See below ↓](#filter-mentions-data-entities-receiver-object) |

  ***

  <span id="filter-mentions-data-entities-sender-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                       |
  | ------------ | ------ | ------------------- | ------------------------------------------------------------------ |
  | `entityType` | string | Type of entity      | `"user"`                                                           |
  | `entity`     | object | User entity details | [See below ↓](#filter-mentions-data-entities-sender-entity-object) |

  ***

  <span id="filter-mentions-data-entities-sender-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender.entity` Object:**

  | Parameter      | Type   | Description              | Sample Value                                                            |
  | -------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`          | string | User's unique identifier | `"cometchat-uid-3"`                                                     |
  | `name`         | string | User's display name      | `"Nancy Grace"`                                                         |
  | `avatar`       | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`       | string | User's online status     | `"online"`                                                              |
  | `role`         | string | User's role              | `"default"`                                                             |
  | `lastActiveAt` | number | Last active timestamp    | `1771482552`                                                            |
  | `tags`         | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-mentions-data-entities-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                         |
  | ------------ | ------ | ------------------- | -------------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                             |
  | `entity`     | object | User entity details | [See below ↓](#filter-mentions-data-entities-receiver-entity-object) |

  ***

  <span id="filter-mentions-data-entities-receiver-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver.entity` Object:**

  | Parameter        | Type   | Description              | Sample Value                                                            |
  | ---------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`            | string | User's unique identifier | `"cometchat-uid-2"`                                                     |
  | `name`           | string | User's display name      | `"George Alan"`                                                         |
  | `avatar`         | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`         | string | User's online status     | `"online"`                                                              |
  | `role`           | string | User's role              | `"default"`                                                             |
  | `lastActiveAt`   | number | Last active timestamp    | `1771482544`                                                            |
  | `conversationId` | string | Conversation identifier  | `"cometchat-uid-2_user_cometchat-uid-3"`                                |
  | `tags`           | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-mentions-data-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata` Object:**

  | Parameter   | Type   | Description              | Sample Value                                                  |
  | ----------- | ------ | ------------------------ | ------------------------------------------------------------- |
  | `@injected` | object | Injected extensions data | [See below ↓](#filter-mentions-data-metadata-injected-object) |

  ***

  <span id="filter-mentions-data-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected` Object:**

  | Parameter    | Type   | Description     | Sample Value                                                    |
  | ------------ | ------ | --------------- | --------------------------------------------------------------- |
  | `extensions` | object | Extensions data | [See below ↓](#filter-mentions-data-metadata-extensions-object) |

  ***

  <span id="filter-mentions-data-metadata-extensions-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description            | Sample Value                                                     |
  | -------------- | ------ | ---------------------- | ---------------------------------------------------------------- |
  | `link-preview` | object | Link preview extension | [See below ↓](#filter-mentions-data-metadata-linkpreview-object) |

  ***

  <span id="filter-mentions-data-metadata-linkpreview-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions.link-preview` Object:**

  | Parameter | Type  | Description     | Sample Value |
  | --------- | ----- | --------------- | ------------ |
  | `links`   | array | Extracted links | `[]`         |

  ***

  <span id="filter-mentions-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`metadata` Object:**

  | Parameter   | Type   | Description              | Sample Value                                             |
  | ----------- | ------ | ------------------------ | -------------------------------------------------------- |
  | `@injected` | object | Injected extensions data | [See below ↓](#filter-mentions-metadata-injected-object) |

  ***

  <span id="filter-mentions-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected` Object:**

  | Parameter    | Type   | Description     | Sample Value                                               |
  | ------------ | ------ | --------------- | ---------------------------------------------------------- |
  | `extensions` | object | Extensions data | [See below ↓](#filter-mentions-metadata-extensions-object) |

  ***

  <span id="filter-mentions-metadata-extensions-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description            | Sample Value                                                |
  | -------------- | ------ | ---------------------- | ----------------------------------------------------------- |
  | `link-preview` | object | Link preview extension | [See below ↓](#filter-mentions-metadata-linkpreview-object) |

  ***

  <span id="filter-mentions-metadata-linkpreview-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions.link-preview` Object:**

  | Parameter | Type  | Description     | Sample Value |
  | --------- | ----- | --------------- | ------------ |
  | `links`   | array | Extracted links | `[]`         |
</Accordion>

## Messages with particular user mentions

*In other words, as a logged-in user, how do I fetch messages that mention specific users?*

In order to do this, you can use the `setMentionedUIDs()` method. This method accepts an array of UIDs as input. When set, the SDK will fetch messages which have the mentions of the UIDs passed.

<Note>
  This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration)
</Note>

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setLimit(limit)
      .setMentionedUIDs(["UID"])
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setLimit(limit)
      .setMentionedUIDs(["UID"])
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(UID)
          .setLimit(limit)
          .setMentionedUIDs(["UID"])
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setLimit(limit)
          .setMentionedUIDs(["UID"])
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns an array of `Message` objects mentioning the specified UIDs:

  <span id="filter-mentioneduid-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                             |
  | ---------------- | ------- | --------------------------------- | -------------------------------------------------------- |
  | `id`             | string  | Unique message identifier         | `"25271"`                                                |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`                 |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                                      |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                                 |
  | `type`           | string  | Message type                      | `"text"`                                                 |
  | `category`       | string  | Message category                  | `"message"`                                              |
  | `text`           | string  | Message text content              | `"<@uid:cometchat-uid-2> Hello"`                         |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771482742`                                             |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771482743`                                             |
  | `readAt`         | number  | Unix timestamp when read          | `1771482743`                                             |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771482743`                                             |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-mentioneduid-sender-object)        |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-mentioneduid-receiver-object)      |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-mentioneduid-data-object)          |
  | `metadata`       | object  | Message metadata                  | [See below ↓](#filter-mentioneduid-metadata-object)      |
  | `reactions`      | array   | Message reactions                 | `[]`                                                     |
  | `mentionedUsers` | array   | Users mentioned in message        | [See below ↓](#filter-mentioneduid-mentionedusers-array) |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `true`                                                   |

  ***

  <span id="filter-mentioneduid-mentionedusers-array" style={{scrollMarginTop: '100px'}} />

  **`mentionedUsers` Array (per item):**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771494233`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |

  ***

  <span id="filter-mentioneduid-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771482552`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-mentioneduid-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"online"`                                                              |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771482544`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-mentioneduid-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter  | Type   | Description                   | Sample Value                                             |
  | ---------- | ------ | ----------------------------- | -------------------------------------------------------- |
  | `text`     | string | Message text                  | `"<@uid:cometchat-uid-2> Hello"`                         |
  | `resource` | string | SDK resource identifier       | `"REACT_NATIVE-4_0_14-..."`                              |
  | `mentions` | object | Map of mentioned users by UID | [See below ↓](#filter-mentioneduid-data-mentions-object) |
  | `entities` | object | Sender and receiver entities  | [See below ↓](#filter-mentioneduid-data-entities-object) |
  | `metadata` | object | Injected metadata             | [See below ↓](#filter-mentioneduid-data-metadata-object) |

  ***

  <span id="filter-mentioneduid-data-mentions-object" style={{scrollMarginTop: '100px'}} />

  **`data.mentions` Object (keyed by UID):**

  | Parameter      | Type   | Description              | Sample Value                                                            |
  | -------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`          | string | User's unique identifier | `"cometchat-uid-2"`                                                     |
  | `name`         | string | User's display name      | `"George Alan"`                                                         |
  | `avatar`       | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`       | string | User's online status     | `"online"`                                                              |
  | `role`         | string | User's role              | `"default"`                                                             |
  | `lastActiveAt` | number | Last active timestamp    | `1771494233`                                                            |

  ***

  <span id="filter-mentioneduid-data-entities-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities` Object:**

  | Parameter  | Type   | Description             | Sample Value                                                      |
  | ---------- | ------ | ----------------------- | ----------------------------------------------------------------- |
  | `sender`   | object | Sender entity wrapper   | [See below ↓](#filter-mentioneduid-data-entities-sender-object)   |
  | `receiver` | object | Receiver entity wrapper | [See below ↓](#filter-mentioneduid-data-entities-receiver-object) |

  ***

  <span id="filter-mentioneduid-data-entities-sender-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                           |
  | ------------ | ------ | ------------------- | ---------------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                               |
  | `entity`     | object | User entity details | [See below ↓](#filter-mentioneduid-data-entities-sender-entity-object) |

  ***

  <span id="filter-mentioneduid-data-entities-sender-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender.entity` Object:**

  | Parameter      | Type   | Description              | Sample Value                                                            |
  | -------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`          | string | User's unique identifier | `"cometchat-uid-3"`                                                     |
  | `name`         | string | User's display name      | `"Nancy Grace"`                                                         |
  | `avatar`       | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`       | string | User's online status     | `"online"`                                                              |
  | `role`         | string | User's role              | `"default"`                                                             |
  | `lastActiveAt` | number | Last active timestamp    | `1771482552`                                                            |
  | `tags`         | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-mentioneduid-data-entities-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                             |
  | ------------ | ------ | ------------------- | ------------------------------------------------------------------------ |
  | `entityType` | string | Type of entity      | `"user"`                                                                 |
  | `entity`     | object | User entity details | [See below ↓](#filter-mentioneduid-data-entities-receiver-entity-object) |

  ***

  <span id="filter-mentioneduid-data-entities-receiver-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver.entity` Object:**

  | Parameter        | Type   | Description              | Sample Value                                                            |
  | ---------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`            | string | User's unique identifier | `"cometchat-uid-2"`                                                     |
  | `name`           | string | User's display name      | `"George Alan"`                                                         |
  | `avatar`         | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`         | string | User's online status     | `"online"`                                                              |
  | `role`           | string | User's role              | `"default"`                                                             |
  | `lastActiveAt`   | number | Last active timestamp    | `1771482544`                                                            |
  | `conversationId` | string | Conversation identifier  | `"cometchat-uid-2_user_cometchat-uid-3"`                                |
  | `tags`           | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-mentioneduid-data-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata` Object:**

  | Parameter   | Type   | Description              | Sample Value                                                      |
  | ----------- | ------ | ------------------------ | ----------------------------------------------------------------- |
  | `@injected` | object | Injected extensions data | [See below ↓](#filter-mentioneduid-data-metadata-injected-object) |

  ***

  <span id="filter-mentioneduid-data-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected` Object:**

  | Parameter    | Type   | Description     | Sample Value                                                        |
  | ------------ | ------ | --------------- | ------------------------------------------------------------------- |
  | `extensions` | object | Extensions data | [See below ↓](#filter-mentioneduid-data-metadata-extensions-object) |

  ***

  <span id="filter-mentioneduid-data-metadata-extensions-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description            | Sample Value                                                         |
  | -------------- | ------ | ---------------------- | -------------------------------------------------------------------- |
  | `link-preview` | object | Link preview extension | [See below ↓](#filter-mentioneduid-data-metadata-linkpreview-object) |

  ***

  <span id="filter-mentioneduid-data-metadata-linkpreview-object" style={{scrollMarginTop: '100px'}} />

  **`data.metadata.@injected.extensions.link-preview` Object:**

  | Parameter | Type  | Description     | Sample Value |
  | --------- | ----- | --------------- | ------------ |
  | `links`   | array | Extracted links | `[]`         |

  ***

  <span id="filter-mentioneduid-metadata-object" style={{scrollMarginTop: '100px'}} />

  **`metadata` Object:**

  | Parameter   | Type   | Description              | Sample Value                                                 |
  | ----------- | ------ | ------------------------ | ------------------------------------------------------------ |
  | `@injected` | object | Injected extensions data | [See below ↓](#filter-mentioneduid-metadata-injected-object) |

  ***

  <span id="filter-mentioneduid-metadata-injected-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected` Object:**

  | Parameter    | Type   | Description     | Sample Value                                                   |
  | ------------ | ------ | --------------- | -------------------------------------------------------------- |
  | `extensions` | object | Extensions data | [See below ↓](#filter-mentioneduid-metadata-extensions-object) |

  ***

  <span id="filter-mentioneduid-metadata-extensions-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions` Object:**

  | Parameter      | Type   | Description            | Sample Value                                                    |
  | -------------- | ------ | ---------------------- | --------------------------------------------------------------- |
  | `link-preview` | object | Link preview extension | [See below ↓](#filter-mentioneduid-metadata-linkpreview-object) |

  ***

  <span id="filter-mentioneduid-metadata-linkpreview-object" style={{scrollMarginTop: '100px'}} />

  **`metadata.@injected.extensions.link-preview` Object:**

  | Parameter | Type  | Description     | Sample Value |
  | --------- | ----- | --------------- | ------------ |
  | `links`   | array | Extracted links | `[]`         |
</Accordion>

## Messages with specific attachment types

*In other words, as a logged-in user, how do I fetch messages that contain specific types of attachments?*

In order to do this, you can use the `setAttachmentTypes()` method. This method accepts an array of `CometChat.AttachmentType` ENUM values as input. When provided, the SDK will fetch only those messages that include attachments of the specified types (such as image, audio, video, or file).

<Note>
  This feature is only available with `Conversation & Advanced Search`. The `Conversation & Advanced Search` is only available in `Advanced` & `Custom` [plans](https://www.cometchat.com/pricing). If you're already on one of these plans, please enable the `Conversation & Advanced Search` from [CometChat Dashboard](https://app.cometchat.com) (Open your app, navigate to Chats -> Settings -> General Configuration)
</Note>

<Tabs>
  <Tab title="To User">
    ```javascript theme={null}
    let UID = "UID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setUID(UID)
      .setLimit(limit)
      .setAttachmentTypes([CometChat.AttachmentType.IMAGE, CometChat.AttachmentType.VIDEO])
      .build();
    ```
  </Tab>

  <Tab title="To Group">
    ```javascript theme={null}
    let GUID = "GUID";
    let limit = 30;
    let messagesRequest = new CometChat.MessagesRequestBuilder()
      .setGUID(GUID)
      .setLimit(limit)
      .setAttachmentTypes([CometChat.AttachmentType.IMAGE, CometChat.AttachmentType.VIDEO])
      .build();
    ```
  </Tab>

  <Tab title="TypeScript (User)">
    ```typescript theme={null}
    let UID: string = "UID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(UID)
          .setLimit(limit)
          .setAttachmentTypes([CometChat.AttachmentType.IMAGE, CometChat.AttachmentType.VIDEO])
          .build();
    ```
  </Tab>

  <Tab title="TypeScript (Group)">
    ```typescript theme={null}
    let GUID: string = "GUID",
      limit: number = 30,
      messagesRequest: CometChat.MessagesRequest =
        new CometChat.MessagesRequestBuilder()
          .setGUID(GUID)
          .setLimit(limit)
          .setAttachmentTypes([CometChat.AttachmentType.IMAGE, CometChat.AttachmentType.VIDEO])
          .build();
    ```
  </Tab>
</Tabs>

<Accordion title="Response">
  **On Success** — `fetchPrevious()` returns an array of `Message` objects with the specified attachment types:

  <span id="filter-attachmenttypes-message-object" style={{scrollMarginTop: '100px'}} />

  **Message Object (per item in array):**

  | Parameter        | Type    | Description                       | Sample Value                                           |
  | ---------------- | ------- | --------------------------------- | ------------------------------------------------------ |
  | `id`             | string  | Unique message identifier         | `"25196"`                                              |
  | `conversationId` | string  | Conversation identifier           | `"cometchat-uid-2_user_cometchat-uid-3"`               |
  | `receiverId`     | string  | Receiver's UID                    | `"cometchat-uid-2"`                                    |
  | `receiverType`   | string  | Type of receiver                  | `"user"`                                               |
  | `type`           | string  | Message type                      | `"image"`                                              |
  | `category`       | string  | Message category                  | `"message"`                                            |
  | `sentAt`         | number  | Unix timestamp when sent          | `1771386517`                                           |
  | `deliveredAt`    | number  | Unix timestamp when delivered     | `1771386517`                                           |
  | `readAt`         | number  | Unix timestamp when read          | `1771483750`                                           |
  | `updatedAt`      | number  | Unix timestamp when updated       | `1771483750`                                           |
  | `sender`         | object  | Sender user details               | [See below ↓](#filter-attachmenttypes-sender-object)   |
  | `receiver`       | object  | Receiver user details             | [See below ↓](#filter-attachmenttypes-receiver-object) |
  | `data`           | object  | Additional message data           | [See below ↓](#filter-attachmenttypes-data-object)     |
  | `reactions`      | array   | Message reactions                 | `[]`                                                   |
  | `mentionedUsers` | array   | Users mentioned in message        | `[]`                                                   |
  | `mentionedMe`    | boolean | Whether current user is mentioned | `false`                                                |

  ***

  <span id="filter-attachmenttypes-sender-object" style={{scrollMarginTop: '100px'}} />

  **`sender` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-3"`                                                     |
  | `name`          | string  | User's display name                    | `"Nancy Grace"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`        | string  | User's online status                   | `"offline"`                                                             |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771386507`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-attachmenttypes-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`receiver` Object:**

  | Parameter       | Type    | Description                            | Sample Value                                                            |
  | --------------- | ------- | -------------------------------------- | ----------------------------------------------------------------------- |
  | `uid`           | string  | User's unique identifier               | `"cometchat-uid-2"`                                                     |
  | `name`          | string  | User's display name                    | `"George Alan"`                                                         |
  | `avatar`        | string  | URL to user's avatar                   | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`        | string  | User's online status                   | `"offline"`                                                             |
  | `role`          | string  | User's role                            | `"default"`                                                             |
  | `lastActiveAt`  | number  | Last active timestamp                  | `1771386436`                                                            |
  | `hasBlockedMe`  | boolean | Whether user has blocked current user  | `false`                                                                 |
  | `blockedByMe`   | boolean | Whether current user blocked this user | `false`                                                                 |
  | `deactivatedAt` | number  | Deactivation timestamp (0 if active)   | `0`                                                                     |
  | `tags`          | array   | User tags                              | `[]`                                                                    |

  ***

  <span id="filter-attachmenttypes-data-object" style={{scrollMarginTop: '100px'}} />

  **`data` Object:**

  | Parameter     | Type   | Description                  | Sample Value                                                  |
  | ------------- | ------ | ---------------------------- | ------------------------------------------------------------- |
  | `type`        | string | Attachment type              | `"image"`                                                     |
  | `category`    | string | Message category             | `"message"`                                                   |
  | `url`         | string | URL to the attachment        | `"https://data-in.cometchat.io/2748663902141719/media/..."`   |
  | `resource`    | string | SDK resource identifier      | `"REACT_NATIVE-4_0_14-..."`                                   |
  | `attachments` | array  | Array of attachment objects  | [See below ↓](#filter-attachmenttypes-data-attachments-array) |
  | `entities`    | object | Sender and receiver entities | [See below ↓](#filter-attachmenttypes-data-entities-object)   |

  ***

  <span id="filter-attachmenttypes-data-attachments-array" style={{scrollMarginTop: '100px'}} />

  **`data.attachments` Array (per item):**

  | Parameter   | Type   | Description           | Sample Value                                                |
  | ----------- | ------ | --------------------- | ----------------------------------------------------------- |
  | `extension` | string | File extension        | `"jpg"`                                                     |
  | `mimeType`  | string | MIME type of the file | `"image/jpeg"`                                              |
  | `name`      | string | File name             | `"IMG_20260217_150412.jpg"`                                 |
  | `size`      | number | File size in bytes    | `142099`                                                    |
  | `url`       | string | URL to the attachment | `"https://data-in.cometchat.io/2748663902141719/media/..."` |

  ***

  <span id="filter-attachmenttypes-data-entities-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities` Object:**

  | Parameter  | Type   | Description             | Sample Value                                                         |
  | ---------- | ------ | ----------------------- | -------------------------------------------------------------------- |
  | `sender`   | object | Sender entity wrapper   | [See below ↓](#filter-attachmenttypes-data-entities-sender-object)   |
  | `receiver` | object | Receiver entity wrapper | [See below ↓](#filter-attachmenttypes-data-entities-receiver-object) |

  ***

  <span id="filter-attachmenttypes-data-entities-sender-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                              |
  | ------------ | ------ | ------------------- | ------------------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                                  |
  | `entity`     | object | User entity details | [See below ↓](#filter-attachmenttypes-data-entities-sender-entity-object) |

  ***

  <span id="filter-attachmenttypes-data-entities-sender-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.sender.entity` Object:**

  | Parameter      | Type   | Description              | Sample Value                                                            |
  | -------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`          | string | User's unique identifier | `"cometchat-uid-3"`                                                     |
  | `name`         | string | User's display name      | `"Nancy Grace"`                                                         |
  | `avatar`       | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp"` |
  | `status`       | string | User's online status     | `"offline"`                                                             |
  | `role`         | string | User's role              | `"default"`                                                             |
  | `lastActiveAt` | number | Last active timestamp    | `1771386507`                                                            |
  | `tags`         | array  | User tags                | `[]`                                                                    |

  ***

  <span id="filter-attachmenttypes-data-entities-receiver-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver` Object:**

  | Parameter    | Type   | Description         | Sample Value                                                                |
  | ------------ | ------ | ------------------- | --------------------------------------------------------------------------- |
  | `entityType` | string | Type of entity      | `"user"`                                                                    |
  | `entity`     | object | User entity details | [See below ↓](#filter-attachmenttypes-data-entities-receiver-entity-object) |

  ***

  <span id="filter-attachmenttypes-data-entities-receiver-entity-object" style={{scrollMarginTop: '100px'}} />

  **`data.entities.receiver.entity` Object:**

  | Parameter        | Type   | Description              | Sample Value                                                            |
  | ---------------- | ------ | ------------------------ | ----------------------------------------------------------------------- |
  | `uid`            | string | User's unique identifier | `"cometchat-uid-2"`                                                     |
  | `name`           | string | User's display name      | `"George Alan"`                                                         |
  | `avatar`         | string | URL to user's avatar     | `"https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp"` |
  | `status`         | string | User's online status     | `"offline"`                                                             |
  | `role`           | string | User's role              | `"default"`                                                             |
  | `lastActiveAt`   | number | Last active timestamp    | `1771386436`                                                            |
  | `conversationId` | string | Conversation identifier  | `"cometchat-uid-2_user_cometchat-uid-3"`                                |
  | `tags`           | array  | User tags                | `[]`                                                                    |
</Accordion>

## Best Practices & Troubleshooting

<AccordionGroup>
  <Accordion title="Reuse MessagesRequest objects for pagination">
    Always call `fetchNext()` or `fetchPrevious()` on the same `MessagesRequest` object to paginate through results. Creating a new `MessagesRequest` object will reset pagination and start from the beginning.
  </Accordion>

  <Accordion title="Combine filters for precise results">
    You can chain multiple builder methods together (e.g., `setCategories()` + `setTypes()` + `setUID()`) to narrow down results. This is more efficient than fetching all messages and filtering client-side.
  </Accordion>

  <Accordion title="Use setUpdatedAfter() for local caching">
    If you store messages locally, use `setUpdatedAfter()` with the timestamp of your last synced message to fetch only new or updated messages. Combine with `updatesOnly(true)` if you only need edits, deletions, and read/delivery status changes.
  </Accordion>

  <Accordion title="Set an appropriate limit">
    The maximum limit per fetch is `100`. For most UI use cases, a limit of `30–50` provides a good balance between performance and user experience. Smaller limits mean faster responses and less memory usage.
  </Accordion>

  <Accordion title="Troubleshooting: No messages returned">
    If `fetchNext()` or `fetchPrevious()` returns an empty array, verify that: the logged-in user is a member of the group (for group conversations), the UID/GUID is correct, and the applied filters aren't too restrictive. Try removing filters one at a time to isolate the issue.
  </Accordion>

  <Accordion title="Troubleshooting: Conversation & Advanced Search features not working">
    Methods like `hasLinks()`, `hasAttachments()`, `hasReactions()`, `hasMentions()`, `setMentionedUIDs()`, and `setAttachmentTypes()` require the Conversation & Advanced Search feature to be enabled. Ensure you are on an Advanced or Custom [plan](https://www.cometchat.com/pricing) and have enabled the feature from the [CometChat Dashboard](https://app.cometchat.com) (Chats → Settings → General Configuration).
  </Accordion>
</AccordionGroup>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Receive Messages" icon="inbox" href="/sdk/react-native/receive-messages">
    Listen for and handle incoming real-time messages
  </Card>

  <Card title="Send Messages" icon="paper-plane" href="/sdk/react-native/send-message">
    Send text, media, and custom messages to users and groups
  </Card>

  <Card title="Message Structure & Hierarchy" icon="sitemap" href="/sdk/react-native/message-structure-and-hierarchy">
    Understand message categories, types, and structure
  </Card>

  <Card title="Retrieve Conversations" icon="comments" href="/sdk/react-native/retrieve-conversations">
    Fetch and display conversation lists with latest messages
  </Card>
</CardGroup>
