> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gleap.ai/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 and pagination.

**Filtering:**
- Filter by ticket: `ticket=507f1f77bcf86cd799439011`. Any identifier `GET /tickets/{ticketId}` accepts works
  here too — the human-facing ticket number shown in the dashboard (`ticket=143790`), the 24-char ObjectId, or
  the shareToken.
- Filter by type: `type=TEXT` or `type=TEXT,NOTE` (comma-separated values match any; bracket syntax such
  as `type[$in]=...` is NOT supported)
- Filter by bot messages: `bot=true` or `bot=false`
- Filter by date range: `createdAt>=2024-01-01&createdAt<=2024-12-31`

**Ordering:** Messages are always returned oldest-first (ascending `createdAt`); the sort order is not
configurable.

**Pagination:**
- Cursor mode (recommended): pass `paginated=true` to receive `{ items, hasMore, nextBefore }`; pass
  `before=<messageId>` (the previous `nextBefore`) to fetch the next older page. `skip` is ignored in this
  mode; `limit` defaults to 30 and is clamped to 1-100.
- Legacy mode (no `paginated`): returns a flat array; `limit` defaults to 1000 and values above 100 are
  clamped to 100; `skip` is applied.

**Exporting a full conversation:**
Filter by `ticket` rather than by `bot`. `bot=true` selects messages exchanged with the AI bot, so on a
conversation that was handed over to a human it omits the agent's replies — `ticket={ticketId}` returns
the complete transcript. Thread replies are not part of the main feed either; fetch them per message with
`GET /messages/{messageId}/thread`. Which conversations still exist is governed by retention — AI-only
(`type=BOT`) conversations are deleted about 33 days after they are created, see GET /tickets.

**Ticket history:**
Since August 2026 this endpoint returns conversation messages only. Audit entries — `FEEDBACK_UPDATED`
(status, assignee, team, priority, type, tag, title changes, …) and workflow/system entries — are no
longer part of the response; filtering by those types returns an empty result. Fetch them from
`GET /tickets/{ticketId}/history`, which returns them in the same message-compatible shape.

**Translation:**
- `language=es` returns messages translated into the given language. Requires the project setting
  'translate customer messages'; only conversation messages (`TEXT`, `USER_TEXT`, `NOTE`, `BOT`,
  `BOT_REPLY`, `SHARED_COMMENT`) are translated, and messages already in the target language are returned
  unchanged.



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


        **Filtering:**

        - Filter by ticket: `ticket=507f1f77bcf86cd799439011`. Any identifier
        `GET /tickets/{ticketId}` accepts works
          here too — the human-facing ticket number shown in the dashboard (`ticket=143790`), the 24-char ObjectId, or
          the shareToken.
        - Filter by type: `type=TEXT` or `type=TEXT,NOTE` (comma-separated
        values match any; bracket syntax such
          as `type[$in]=...` is NOT supported)
        - Filter by bot messages: `bot=true` or `bot=false`

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


        **Ordering:** Messages are always returned oldest-first (ascending
        `createdAt`); the sort order is not

        configurable.


        **Pagination:**

        - Cursor mode (recommended): pass `paginated=true` to receive `{ items,
        hasMore, nextBefore }`; pass
          `before=<messageId>` (the previous `nextBefore`) to fetch the next older page. `skip` is ignored in this
          mode; `limit` defaults to 30 and is clamped to 1-100.
        - Legacy mode (no `paginated`): returns a flat array; `limit` defaults
        to 1000 and values above 100 are
          clamped to 100; `skip` is applied.

        **Exporting a full conversation:**

        Filter by `ticket` rather than by `bot`. `bot=true` selects messages
        exchanged with the AI bot, so on a

        conversation that was handed over to a human it omits the agent's
        replies — `ticket={ticketId}` returns

        the complete transcript. Thread replies are not part of the main feed
        either; fetch them per message with

        `GET /messages/{messageId}/thread`. Which conversations still exist is
        governed by retention — AI-only

        (`type=BOT`) conversations are deleted about 33 days after they are
        created, see GET /tickets.


        **Ticket history:**

        Since August 2026 this endpoint returns conversation messages only.
        Audit entries — `FEEDBACK_UPDATED`

        (status, assignee, team, priority, type, tag, title changes, …) and
        workflow/system entries — are no

        longer part of the response; filtering by those types returns an empty
        result. Fetch them from

        `GET /tickets/{ticketId}/history`, which returns them in the same
        message-compatible shape.


        **Translation:**

        - `language=es` returns messages translated into the given language.
        Requires the project setting
          'translate customer messages'; only conversation messages (`TEXT`, `USER_TEXT`, `NOTE`, `BOT`,
          `BOT_REPLY`, `SHARED_COMMENT`) are translated, and messages already in the target language are returned
          unchanged.
      operationId: GetMessages
      parameters:
        - in: header
          name: project
          required: true
          schema:
            type: string
        - description: >-
            - Set to `true` for cursor mode: returns `{ items, hasMore,
            nextBefore }`
          in: query
          name: paginated
          required: false
          schema:
            type: boolean
        - description: >-
            - Cursor for the next older page (the previous response's
            `nextBefore`); only with `paginated=true`
          in: query
          name: before
          required: false
          schema:
            type: string
        - description: >-
            - Maximum number of messages to return. Cursor mode: default 30,
            clamped to 1-100. Legacy mode: default 1000, values above 100 are
            clamped to 100.
          in: query
          name: limit
          required: false
          schema:
            type: number
            format: double
          example: '50'
        - description: >-
            - Deprecated, accepted and ignored. Ticket-history entries are
            served by `GET /tickets/{ticketId}/history`.
          in: query
          name: showHistory
          required: false
          schema:
            type: boolean
          deprecated: true
      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
                      ticket: 507f1f77bcf86cd799439011
                      type: TEXT
                      data:
                        content:
                          type: doc
                          content:
                            - type: paragraph
                              content:
                                - type: text
                                  text: This is a sample message content.
                      comment: This is a sample message content.
                      bot: false
                      user:
                        id: 507f1f77bcf86cd799439012
                        email: support@example.com
                        firstName: John
                        lastName: Doe
                      session:
                        _id: 507f1f77bcf86cd799439013
                        id: 507f1f77bcf86cd799439013
                        email: user@example.com
                      createdAt: '2024-01-15T10:30:00.000Z'
                      updatedAt: '2024-01-15T10:30:00.000Z'
                      index: 0
                    - id: 507f1f77bcf86cd799439016
                      ticket: 507f1f77bcf86cd799439011
                      type: TEXT
                      data:
                        content:
                          type: doc
                          content:
                            - type: paragraph
                              content:
                                - type: text
                                  text: Thank you for the update!
                      comment: Thank you for the update!
                      bot: false
                      user:
                        id: 507f1f77bcf86cd799439017
                        email: user@example.com
                        firstName: Jane
                        lastName: Smith
                      session:
                        _id: 507f1f77bcf86cd799439013
                        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

````