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

# Find messages by query

> Get messages by query with support for filtering, sorting, and pagination.

**Filtering:**
- Filter by ticket: `ticket=507f1f77bcf86cd799439011`
- Filter by type: `type=COMMENT` or `type=COMMENT,NOTE`
- Filter by bot messages: `bot=true` or `bot=false`
- Filter by date range: `createdAt>=2024-01-01&createdAt<=2024-12-31`

**Sorting:**
- Sort by creation date: `sort=-createdAt` (newest first) or `sort=createdAt` (oldest first)
- Sort by updated date: `sort=-updatedAt`

**Pagination:**
- Limit results: `limit=50` (default up to 10000)
- Skip results: `skip=0` (for pagination: `skip=(page-1)*limit`)

**Translation:**
- Auto-translate messages: `language=es` (language code for target language)



## OpenAPI

````yaml https://api.gleap.io/api-docs.json get /messages
openapi: 3.0.0
info:
  title: gleap-server
  version: 14.0.0
  contact: {}
servers:
  - url: https://api.gleap.io/v3
security: []
paths:
  /messages:
    get:
      tags:
        - Messages
      summary: Find messages by query
      description: >-
        Get messages by query with support for filtering, sorting, and
        pagination.


        **Filtering:**

        - Filter by ticket: `ticket=507f1f77bcf86cd799439011`

        - Filter by type: `type=COMMENT` or `type=COMMENT,NOTE`

        - Filter by bot messages: `bot=true` or `bot=false`

        - Filter by date range: `createdAt>=2024-01-01&createdAt<=2024-12-31`


        **Sorting:**

        - Sort by creation date: `sort=-createdAt` (newest first) or
        `sort=createdAt` (oldest first)

        - Sort by updated date: `sort=-updatedAt`


        **Pagination:**

        - Limit results: `limit=50` (default up to 10000)

        - Skip results: `skip=0` (for pagination: `skip=(page-1)*limit`)


        **Translation:**

        - Auto-translate messages: `language=es` (language code for target
        language)
      operationId: GetMessages
      parameters:
        - in: header
          name: project
          required: true
          schema:
            type: string
        - in: query
          name: paginated
          required: false
          schema:
            type: boolean
        - in: query
          name: before
          required: false
          schema:
            type: string
        - description: >-
            - Maximum number of messages to return (default: no limit, max:
            10000)
          in: query
          name: limit
          required: false
          schema:
            type: number
            format: double
          example: '50'
        - in: query
          name: showHistory
          required: false
          schema:
            type: boolean
      responses:
        '200':
          description: Ok
          content:
            application/json:
              schema:
                anyOf:
                  - items: {}
                    type: array
                  - properties:
                      nextBefore: {}
                      hasMore:
                        type: boolean
                      items:
                        items: {}
                        type: array
                    required:
                      - nextBefore
                      - hasMore
                      - items
                    type: object
              examples:
                Example 1:
                  value:
                    - _id: 507f1f77bcf86cd799439015
                      id: 507f1f77bcf86cd799439015
                      ticket: 507f1f77bcf86cd799439011
                      comment:
                        type: doc
                        content:
                          - type: paragraph
                            content:
                              - type: text
                                text: This is a sample message content.
                      type: COMMENT
                      bot: false
                      user:
                        _id: 507f1f77bcf86cd799439012
                        email: support@example.com
                        firstName: John
                        lastName: Doe
                      session:
                        _id: 507f1f77bcf86cd799439013
                        email: user@example.com
                      createdAt: '2024-01-15T10:30:00.000Z'
                      updatedAt: '2024-01-15T10:30:00.000Z'
                      index: 0
                    - _id: 507f1f77bcf86cd799439016
                      id: 507f1f77bcf86cd799439016
                      ticket: 507f1f77bcf86cd799439011
                      comment:
                        type: doc
                        content:
                          - type: paragraph
                            content:
                              - type: text
                                text: Thank you for the update!
                      type: COMMENT
                      bot: false
                      user:
                        _id: 507f1f77bcf86cd799439017
                        email: user@example.com
                        firstName: Jane
                        lastName: Smith
                      session:
                        _id: 507f1f77bcf86cd799439013
                        email: user@example.com
                      createdAt: '2024-01-15T11:00:00.000Z'
                      updatedAt: '2024-01-15T11:00:00.000Z'
                      index: 1
      security:
        - jwt: []
components:
  securitySchemes:
    jwt:
      type: http
      scheme: bearer
      bearerFormat: JWT

````