GET
/
messages
List Messages
curl --request GET \
  --url https://{appid}.api-{region}.cometchat.io/v3/messages \
  --header 'apikey: <api-key>'
{
  "data": [
    {
      "id": "1",
      "conversationId": "superhero3_user_superhero5",
      "sender": "superhero3",
      "receiverType": "user",
      "receiver": "superhero5",
      "category": "message",
      "type": "text",
      "data": {
        "text": "test     hello",
        "entities": {
          "sender": {
            "entity": {
              "uid": "superhero3",
              "name": "Spiderman",
              "role": "default",
              "avatar": "https://data-us.cometchat.io/assets/images/avatars/spiderman.png",
              "status": "offline",
              "createdAt": 1638361550
            },
            "entityType": "user"
          },
          "receiver": {
            "entity": {
              "uid": "superhero5",
              "name": "Cyclops",
              "role": "default",
              "avatar": "https://data-us.cometchat.io/assets/images/avatars/cyclops.png",
              "status": "offline",
              "createdAt": 1638361550,
              "conversationId": "superhero3_user_superhero5"
            },
            "entityType": "user"
          }
        },
        "metadata": {
          "key1": "val1"
        }
      },
      "sentAt": 1638423490,
      "updatedAt": 1638423490
    }
  ],
  "meta": {
    "current": {
      "limit": 100,
      "count": 1
    },
    "next": {
      "affix": "append",
      "sentAt": 1638423490,
      "id": "1"
    }
  }
}

Authorizations

apikey
string
header
required

API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).

Headers

onBehalfOf
string

UID of the user on whose behalf the action is performed.

Query Parameters

searchKey
string

Fetches messages that include the searchKey.

hideMessagesFromBlockedUsers
boolean

Fetches messages sent by users who are blocked by the requesting user.

hasAttachments
boolean

Fetches messages that include attachments.

attachmentTypes
enum<string>

Displays messages according to the type of attachment. Supported types include: image, video, audio, and file.

Available options:
image,
video,
audio,
file
hasMentions
boolean

Fetches messages that include mentions.

Fetches messages that include links.

mentionedUids
boolean

Fetches messages that include the mentioned comma-separated UIDs.

hasReactions
boolean

Fetches messages that include reactions.

receiverType
enum<string>

Displays messages based on receiverType (user/group)

Available options:
user,
group
affix
string

Determines whether to pull the messages either before or after any message id. Possible values are append(after) and prepend(before).

id
string

Retrieves all those messages after the passed id.

category
enum<string>

Filters messages by category. Possible values: message, action and custom.

Available options:
message,
action,
custom
type
string

Filters messages by type.

sender
string

Filters messages with sender. If onBehalfOf header is also set then the messages from their common conversations will be filtered.

mentionsWithBlockedInfo
boolean

For the mentioned users, provides blocked information with respect to the UID in onBehalfOf header.

mentionswithTagInfo
boolean

Provides user tags for the mentioned users.

hideDeleted
boolean

Hides deleted messages from List.

onlyDeleted
boolean

Includes only deleted messages in List.

hideReplies
boolean

Shows only messages skipping the replies in the message thread.

count
boolean

Includes unread message count in List.

unread
boolean

Retrieves all the unread messages in a conversation. It must be used alongside count query parameter.

sentAt
integer

Fetches the messages list after a particular sentAt timestamp.

limit
integer
default:10

The number of records to fetch. Minimum value: 1, Maximum value: 1000

conversationId
string

Fetches all the messages belong to a particular conversation.

withTags
boolean

This will fetch messages along with the tags.

tags
string[]

This will fetch only those messages belonging to the mentioned tags.

categories
string[]

Fetches messages based on multiple categories.

types
any[]

Fetches messages based on multiple types.

fromTimestamp
integer

Fetches the messages from this timestamp.

toTimestamp
integer

Fetches the messages till this timestamp. It will be ignored if fromTimestamp is missing or empty.

Response

200 - application/json

List Message

The response is of type object.