> ## Documentation Index
> Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> Fetches messages between onBehalfOfuid and an uid from path param.

# List User Messages

For the complete error reference, see [Error Guide](/articles/error-guide).


## OpenAPI

````yaml get /users/{uid}/messages
openapi: 3.0.0
info:
  title: Chat APIs
  description: Manage messages, users, groups for a particular app using our Chat API.
  version: '3.0'
servers:
  - url: https://{appId}.api-{region}.cometchat.io/v3
    variables:
      appId:
        default: appId
        description: (Required) App ID
      region:
        enum:
          - us
          - eu
          - in
        default: us
        description: Select Region
security: []
tags:
  - name: API Keys
    description: The API keys are used to authorise the APIs
  - name: Roles
    description: The roles are used to give user access rights
  - name: Users
    description: The REST collection for users.
  - name: Auth Tokens
    description: The auth tokens are used to login end users using client SDKs.
  - name: Blocked Users
    description: The REST collections for blocked users.
  - name: Friends
    description: List,add and remove friends by passing UID in path variables
  - name: Groups
    description: The REST collections for groups.
  - name: Banned Users
    description: Ban and Unban user by passing other UID in path variables.
  - name: Group Members
    description: The REST collections for group members.
  - name: Messages
    description: The REST collections for messages.
  - name: Conversations
    description: The REST collections for conversations.
  - name: Restrict Features
    description: Allows Restricting Features
  - name: Metrics
    description: Allows accessing Data Metrics
  - name: Triggers
    description: Allows adding triggers to a webhook.
  - name: Webhooks
    description: Allows accessing Webhooks.
  - name: Notifications
    description: Allows configuring Notifications core.
paths:
  /users/{uid}/messages:
    get:
      tags:
        - Messages
      summary: List User Messages
      description: Fetches messages between onBehalfOfuid and an uid from path param.
      operationId: user-list-user-messages
      parameters:
        - $ref: '#/components/parameters/onBehalfOf'
        - $ref: '#/components/parameters/uid'
        - name: searchKey
          in: query
          description: searches for occurence of message.
          schema:
            type: string
        - name: hasAttachments
          in: query
          description: Fetches messages that include attachments.
          schema:
            type: boolean
        - name: attachmentTypes
          in: query
          description: >-
            Displays messages according to the type of attachment. Supported
            types include: image, video, audio, and file.
          schema:
            type: string
            enum:
              - image
              - video
              - audio
              - file
            description: Media message type.
        - name: hasMentions
          in: query
          description: Fetches messages that include mentions.
          schema:
            type: boolean
        - name: hasLinks
          in: query
          description: Fetches messages that include links.
          schema:
            type: boolean
        - name: mentionedUids
          in: query
          description: Fetches messages that include the mentioned comma-separated UIDs.
          schema:
            type: boolean
        - name: unread
          in: query
          description: displays all the unread messages of the user.
          schema:
            type: boolean
        - name: undelivered
          in: query
          description: displays all the messages those are undelivered.
          schema:
            type: boolean
        - name: count
          in: query
          description: displays the count of messages as per group/user
          schema:
            type: boolean
        - name: hideReplies
          in: query
          description: Shows only messages skipping the replies in the message thread.
          schema:
            type: boolean
        - name: affix
          in: query
          description: >-
            Determines whether to pull the messages either before or after any
            message id. Possible values are append(after) and prepend(before).
          schema:
            type: string
            enum:
              - append
              - prepend
            description: Cursor pagination direction.
        - name: id
          in: query
          description: Retrieves all those messages after the passed id.
          schema:
            type: string
        - name: category
          in: query
          description: Fetches messages that belongs to specific category.
          schema:
            type: string
        - name: categories
          in: query
          description: Fetches messages that contains multiple categories.
          schema:
            type: array
            items: {}
        - name: type
          in: query
          description: Fetches messages that belongs to a specific type.
          schema:
            type: string
        - name: types
          in: query
          description: Fetches messages with multiple types.
          schema:
            type: array
            items: {}
        - name: myMentionsOnly
          in: query
          description: Filters messages with mentions for the UID in onBehalfOf header.
          schema:
            type: boolean
            default: 'false'
        - name: hasReactions
          in: query
          description: >-
            Filters messages sent by a the uid given in sender query param and
            has reactions. If onBehalfOf header is also set then the messages
            from their common conversations will be filtered.
          schema:
            type: boolean
            default: 'false'
        - name: sender
          in: query
          description: >-
            Filters messages with sender. If onBehalfOf header is also set then
            the messages from their common conversations will be filtered.
          schema:
            type: string
        - name: mentionsWithBlockedInfo
          in: query
          description: >-
            For the mentioned users, provides blocked information with respect
            to the UID in onBehalfOf header.
          schema:
            type: boolean
            default: 'false'
        - name: mentionsWithTagInfo
          in: query
          description: Provides user tags for the mentioned users.
          schema:
            type: boolean
            default: 'false'
        - name: perPage
          in: query
          description: >-
            The number of records to fetch. Minimum value: 1, Maximum value:
            1000
          schema:
            type: integer
            default: '100'
        - name: limit
          in: query
          description: >-
            The number of records to fetch. Minimum value: 1, Maximum value:
            1000 (works alongside onBehalfOf header)
          schema:
            type: integer
            default: '10'
        - name: fromTimestamp
          in: query
          description: Fetches the messages from this timestamp.
          schema:
            type: integer
        - name: toTimestamp
          in: query
          description: Fetches the messages till this timestamp.
          schema:
            type: integer
        - name: withTags
          in: query
          description: This will fetch messages along with the tags.
          schema:
            type: boolean
        - name: tags
          in: query
          description: This will fetch only those messages belonging to the mentioned tags.
          schema:
            type: array
            items:
              type: string
      responses:
        '200':
          description: Get User Messages
          content:
            application/json:
              schema:
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        conversationId:
                          type: string
                        sender:
                          type: string
                        receiverType:
                          type: string
                        receiver:
                          type: string
                        category:
                          type: string
                        type:
                          type: string
                        data:
                          type: object
                        sentAt:
                          type: integer
                        updatedAt:
                          type: integer
                  meta:
                    type: object
                type: object
              example:
                data:
                  - id: '1776'
                    conversationId: cometchat-uid-2_user_cometchat-uid-3
                    sender: cometchat-uid-2
                    receiverType: user
                    receiver: cometchat-uid-3
                    category: call
                    type: audio
                    data:
                      action: initiated
                      entities:
                        by:
                          entity:
                            uid: cometchat-uid-2
                            name: George Alan
                            role: default
                            avatar: >-
                              https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp
                            status: offline
                          entityType: user
                        'on':
                          entity:
                            data:
                              entities:
                                sender:
                                  entity:
                                    uid: cometchat-uid-2
                                    name: George Alan
                                    role: default
                                    avatar: >-
                                      https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp
                                    status: offline
                                  entityType: user
                                receiver:
                                  entity:
                                    uid: cometchat-uid-3
                                    name: Nancy Grace
                                    role: default
                                    avatar: >-
                                      https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp
                                    status: offline
                                    conversationId: cometchat-uid-2_user_cometchat-uid-3
                                  entityType: user
                              metadata:
                                key:
                                  one: two
                            type: audio
                            sender: cometchat-uid-2
                            status: initiated
                            joinedAt: 1646995097
                            receiver: cometchat-uid-3
                            sessionid: 16469950973f7f6a1ea6d5166db11c929cdbde6a61902e10ba
                            wsChannel:
                              secret: 083c2a7f660150e42c2bf07a17231e90980b290d
                              service: 19757e59e8b9669.call
                              identity: >-
                                [19757e59e8b9669]16469950973f7f6a1ea6d5166db11c929cdbde6a61902e10ba
                            initiatedAt: 1646995097
                            receiverType: user
                            conversationId: cometchat-uid-2_user_cometchat-uid-3
                          entityType: call
                        for:
                          entity:
                            uid: cometchat-uid-3
                            name: Nancy Grace
                            role: default
                            avatar: >-
                              https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp
                            status: offline
                            conversationId: cometchat-uid-2_user_cometchat-uid-3
                          entityType: user
                    sentAt: 1646995097
                    updatedAt: 1646995097
                  - id: '1777'
                    conversationId: cometchat-uid-2_user_cometchat-uid-3
                    sender: cometchat-uid-3
                    receiverType: user
                    receiver: cometchat-uid-2
                    category: call
                    type: video
                    data:
                      action: ongoing
                      entities:
                        by:
                          entity:
                            uid: cometchat-uid-3
                            name: Nancy Grace
                            role: default
                            avatar: >-
                              https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp
                            status: offline
                          entityType: user
                        'on':
                          entity:
                            data:
                              entities:
                                sender:
                                  entity:
                                    uid: cometchat-uid-2
                                    name: George Alan
                                    role: default
                                    avatar: >-
                                      https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp
                                    status: offline
                                  entityType: user
                                receiver:
                                  entity:
                                    uid: cometchat-uid-3
                                    name: Nancy Grace
                                    role: default
                                    avatar: >-
                                      https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp
                                    status: offline
                                    conversationId: cometchat-uid-2_user_cometchat-uid-3
                                  entityType: user
                              metadata:
                                key:
                                  one: two
                            type: video
                            sender: cometchat-uid-2
                            status: ongoing
                            joinedAt: 1646995512
                            receiver: cometchat-uid-3
                            sessionid: 16469950973f7f6a1ea6d5166db11c929cdbde6a61902e10ba
                            startedAt: 1646995512
                            wsChannel:
                              secret: 083c2a7f660150e42c2bf07a17231e90980b290d
                              service: 19757e59e8b9669.call
                              identity: >-
                                [19757e59e8b9669]16469950973f7f6a1ea6d5166db11c929cdbde6a61902e10ba
                            initiatedAt: 1646995097
                            receiverType: user
                            conversationId: cometchat-uid-2_user_cometchat-uid-3
                          entityType: call
                        for:
                          entity:
                            uid: cometchat-uid-2
                            name: George Alan
                            role: default
                            avatar: >-
                              https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-2.webp
                            status: offline
                            conversationId: cometchat-uid-2_user_cometchat-uid-3
                          entityType: user
                    sentAt: 1646995512
                    updatedAt: 1646995512
                meta:
                  pagination:
                    total: 0
                    count: 2
                    per_page: 100
                    current_page: 1
                    total_pages: 1
                  cursor:
                    id: 1786
                    affix: prepend
      security:
        - apiKey: []
components:
  parameters:
    onBehalfOf:
      name: onBehalfOf
      in: header
      description: UID of the user on whose behalf the action is performed.
      schema:
        type: string
    uid:
      name: uid
      in: path
      description: An UID of a user.
      required: true
      schema:
        type: string
      examples:
        string:
          summary: UID
          value: cometchat-uid-1
  securitySchemes:
    apiKey:
      type: apiKey
      description: API Key with fullAccess scope(i.e. Rest API Key from the Dashboard).
      name: apikey
      in: header

````