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

# List Messages

> Get filtered chat history (messages only) for a specific chat. Supports filtering by direction, date range, and message UID.



## OpenAPI

````yaml get /chats/{chat_id}/messages
openapi: 3.0.3
info:
  title: Timelines Public API
  description: >
    # Timelines Public API


    _Some API calls may utilize message sending quota or be subject to message
    sending rate limits as described below._


    ### Credit Utilization 
      - Sending a message via API consumes 1 credit from message sending quota.
      - Sending a message with non-empty text and attachment consumes 2 credits from message sending quota.
      - If a message cannot be sent (invalid or not connected to WhatsApp number, WhatsApp server error), message sending quota will be restored (usually within a couple of hours).
    ### Message sending rate
      - Messages will be sent with random delay of about 2 seconds between each two messages (to avoid WhatsApp spam detection mechanisms). Contact support@timelines.global if you want to modify delay for your workspace (available on Business plan only).
      - If you exceed message sending frequency, messages be queued and sent out with delay. Each queued message will consume a message sending credit, so the number of queued messages cannot exceed the available quota.
      
    ### Authorization:
      - Copy API token from [Public API page](https://app.timelines.global/integrations/api/) in your Timelines Global account.
      - Put the token in *Authorization* header of request as follows:
      ```
      Authorization: Bearer 4d2d0239-e28c-4f4a-8a4d-3a3ca40056b8
      ```
            
    ### Message formatting:
      - use "\n" for line breaks
  version: 1.3.0
servers:
  - url: https://app.timelines.global/integrations/api
    description: Production
  - url: https://staging.app.timelines.global/integrations/api
    description: Staging
security:
  - bearerAuth: []
paths:
  /chats/{chat_id}/messages:
    get:
      summary: Get filtered chat history (messages only) of the chat
      description: >-
        Leave filtering parameters empty to get the unfiltered list of all
        messages in the specified chat. When multiple filtering parameters are
        specified, logical AND operation is applied. The result is paginated,
        page size is 50 records. The result is ordered the timestamp of messages
        (descending).
      parameters:
        - $ref: '#/components/parameters/chat_id'
        - in: query
          name: from_me
          schema:
            type: boolean
          description: >-
            specify true to filter messages sent from my WhatsApp account (from
            any session), false to filter messages received from other WhatsApp
            users.
          example: true
        - in: query
          name: after
          schema:
            type: string
          description: >-
            can specify date or datetime in ISO format to filter out messages
            created AFTER the specified date (inclusive)
          example: 2024-01-17 10:35
        - in: query
          name: before
          schema:
            type: string
          description: >-
            can specify date or datetime in ISO format to filter out messages
            created BEFORE the specified date (inclusive)
          example: 2024-01-19 15:30
        - in: query
          name: after_message
          schema:
            type: string
          description: >-
            can specify message uid to filter out messages created after the
            specified message (excluding the specified message itself)
          example: d8cc5a02-b676-4956-8710-3ee56330f356
        - in: query
          name: before_message
          schema:
            type: string
          description: >-
            can specify message uid to filter out messages created before the
            specified message (excluding the specified message itself)
          example: d8cc5a02-b676-4956-8710-3ee56330f356
        - in: query
          name: sorting_order
          schema:
            type: string
            enum:
              - asc
              - desc
          description: 'order messages by timestamp, according to possible values: asc, desc'
          example: asc
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MessageListResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/AccessDenied'
        '404':
          $ref: '#/components/responses/NotFound'
components:
  parameters:
    chat_id:
      in: path
      name: chat_id
      schema:
        type: integer
      required: true
      description: >-
        an id of the chat as appears in Timelines Global (can be found in the
        URL of the chat page, or in the payload of outbound webhook). _Supports
        sending messages to a group._
  schemas:
    MessageListResponse:
      type: object
      required:
        - status
        - data
      properties:
        status:
          type: string
          example: ok
          enum:
            - ok
            - error
        data:
          type: object
          properties:
            has_more_pages:
              type: boolean
            messages:
              type: array
              items:
                $ref: '#/components/schemas/MessageInfo'
    MessageInfo:
      type: object
      required:
        - uid
        - chat_id
        - timestamp
        - sender_phone
        - sender_name
        - recipient_phone
        - recipient_name
        - from_me
        - status
        - origin
        - has_attachment
        - message_type
        - data
        - created_by
      properties:
        uid:
          type: string
          example: de919486-0c93-409d-ae66-c2bbb544faca
        chat_id:
          example: '1000001'
          type: integer
        timestamp:
          example: 2023-06-18 15:19:23 +0300
          type: string
        sender_phone:
          example: '+972540000001'
          type: string
        sender_name:
          example: John Doe
          type: string
        recipient_phone:
          example: '+972540000002'
          type: string
        recipient_name:
          example: Kate Smith
          type: string
        from_me:
          example: true
          type: boolean
        text:
          example: Hello, Kate👍
          type: string
        attachment_url:
          example: https://acme.com/logo.png
          type: string
        attachment_filename:
          example: logo.png
          type: string
        status:
          example: Read
          type: string
        origin:
          example: Public API
          type: string
        has_attachment:
          example: true
          type: boolean
        message_type:
          example: Note
          type: string
        reactions:
          $ref: '#/components/schemas/MessageReactionsObject'
        data:
          example:
            key1: value1
            key2: value2
          type: object
        created_by:
          example: Kate Smith
          type: string
    ErrorResponse:
      required:
        - message
        - status
      type: object
      properties:
        message:
          type: string
        status:
          type: string
          example: error
          enum:
            - ok
            - error
    MessageReactionsObject:
      type: object
      example:
        👍: '2'
        ❤️: '5'
  responses:
    BadRequestError:
      description: Invalid parameters
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    UnauthorizedError:
      description: Access token is missing or invalid
    AccessDenied:
      description: Access denied
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
    NotFound:
      description: Specified entities not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````