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

# List Conversation Messages

> Returns historical chat records in a scrolling load format, with the first page returning the latest `limit` messages, i.e., in reverse order.



## OpenAPI

````yaml /en/api-reference/openapi_chatflow.json get /messages
openapi: 3.0.1
info:
  title: Chatflow App API
  description: >-
    Chatflow applications support session persistence, allowing previous chat
    history to be used as context for responses. Chatflow apps use the
    `advanced-chat` mode, providing workflow-level streaming events for detailed
    execution tracking including node starts, finishes, iterations, and workflow
    lifecycle.
  version: 1.0.0
servers:
  - url: '{api_base_url}'
    description: >-
      The base URL for the Chatflow App API. Replace {api_base_url} with the
      actual API base URL provided for your application.
    variables:
      api_base_url:
        default: https://api.dify.ai/v1
        description: Actual base URL of the API
security:
  - ApiKeyAuth: []
tags:
  - name: Chatflows
    description: >-
      Operations for Chatflow apps, including chat messaging, workflow run
      details, and event streaming.
  - name: Files
    description: File upload and preview operations.
  - name: End Users
    description: Operations related to end user information.
  - name: Feedback
    description: User feedback operations.
  - name: Conversations
    description: Operations related to managing conversations.
  - name: TTS
    description: Text-to-Speech and Speech-to-Text operations.
  - name: Applications
    description: Operations to retrieve application settings and information.
  - name: Annotations
    description: Operations related to managing annotations for direct replies.
  - name: Human Input
    description: Endpoints for resuming paused workflows that require human input.
paths:
  /messages:
    get:
      tags:
        - Conversations
      summary: List Conversation Messages
      description: >-
        Returns historical chat records in a scrolling load format, with the
        first page returning the latest `limit` messages, i.e., in reverse
        order.
      operationId: getAdvancedConversationHistory
      parameters:
        - name: conversation_id
          in: query
          required: true
          description: Conversation ID.
          schema:
            type: string
        - name: user
          in: query
          required: false
          description: User identifier.
          schema:
            type: string
        - name: first_id
          in: query
          required: false
          description: >-
            The ID of the first chat record on the current page. Default is
            `null` (fetches the latest messages). For subsequent pages, use the
            ID of the first message from the current list to get older messages.
          schema:
            type: string
        - name: limit
          in: query
          required: false
          description: Number of chat history messages to return per request.
          schema:
            type: integer
            default: 20
            minimum: 1
            maximum: 100
      responses:
        '200':
          description: Successfully retrieved conversation history.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationHistoryResponse'
              examples:
                conversationHistory:
                  summary: Response Example
                  value:
                    limit: 20
                    has_more: false
                    data:
                      - id: 9da23599-e713-473b-982c-4328d4f5c78a
                        conversation_id: 45701982-8118-4bc5-8e9b-64562b4555f2
                        parent_message_id: null
                        inputs:
                          city: San Francisco
                        query: What are the specs of the iPhone 13 Pro Max?
                        answer: iPhone 13 Pro Max specs are listed here:...
                        status: normal
                        error: null
                        message_files: []
                        feedback:
                          rating: like
                        retriever_resources: []
                        agent_thoughts: []
                        created_at: 1705407629
        '400':
          description: '`not_chat_app` : App mode does not match the API route.'
          content:
            application/json:
              examples:
                not_chat_app:
                  summary: not_chat_app
                  value:
                    status: 400
                    code: not_chat_app
                    message: Please check if your app mode matches the right API route.
        '404':
          description: |-
            - `not_found` : Conversation does not exist.
            - `not_found` : First message does not exist.
          content:
            application/json:
              examples:
                conversation_not_exists:
                  summary: not_found
                  value:
                    status: 404
                    code: not_found
                    message: Conversation Not Exists.
                first_message_not_exists:
                  summary: not_found
                  value:
                    status: 404
                    code: not_found
                    message: First Message Not Exists.
components:
  schemas:
    ConversationHistoryResponse:
      type: object
      properties:
        limit:
          type: integer
          description: Number of items per page.
        has_more:
          type: boolean
          description: Whether there are more messages.
        data:
          type: array
          description: List of messages.
          items:
            $ref: '#/components/schemas/ConversationMessageItem'
    ConversationMessageItem:
      type: object
      description: A single message in a conversation.
      properties:
        id:
          type: string
          format: uuid
          description: Message ID.
        conversation_id:
          type: string
          format: uuid
          description: Conversation ID.
        parent_message_id:
          type: string
          format: uuid
          nullable: true
          description: Parent message ID for threaded conversations.
        inputs:
          type: object
          additionalProperties: true
          description: Input variables for this message.
        query:
          type: string
          description: User query text.
        answer:
          type: string
          description: Assistant answer text.
        status:
          type: string
          description: >-
            Message status. `normal` for successful messages, `error` when
            generation failed.
        error:
          type: string
          nullable: true
          description: Error message if `status` is `error`.
        message_files:
          type: array
          description: Files attached to this message.
          items:
            $ref: '#/components/schemas/MessageFileItem'
        feedback:
          type: object
          nullable: true
          description: User feedback for this message.
          properties:
            rating:
              type: string
              description: Feedback rating. `like` for positive, `dislike` for negative.
        retriever_resources:
          type: array
          description: Retriever resources used for this message.
          items:
            $ref: '#/components/schemas/RetrieverResource'
        agent_thoughts:
          type: array
          description: Agent thoughts for this message.
          items:
            $ref: '#/components/schemas/AgentThoughtItem'
        created_at:
          type: integer
          format: int64
          description: Creation timestamp (Unix epoch seconds).
        extra_contents:
          type: array
          description: >-
            Additional execution content associated with this message, such as
            human input form data from Human Input nodes in chatflow workflows.
          items:
            $ref: '#/components/schemas/HumanInputContent'
    MessageFileItem:
      type: object
      description: A file attached to a message.
      properties:
        id:
          type: string
          format: uuid
          description: File ID.
        filename:
          type: string
          description: Original filename.
        type:
          type: string
          description: File type, e.g., `image`.
        url:
          type: string
          format: url
          nullable: true
          description: Preview URL for the file.
        mime_type:
          type: string
          nullable: true
          description: MIME type of the file.
        size:
          type: integer
          nullable: true
          description: File size in bytes.
        transfer_method:
          type: string
          description: >-
            Transfer method used. `remote_url` for URL-based files, `local_file`
            for uploaded files, `tool_file` for tool-generated files.
        belongs_to:
          type: string
          nullable: true
          description: >-
            Who this file belongs to. `user` for user-uploaded files,
            `assistant` for assistant-generated files.
        upload_file_id:
          type: string
          format: uuid
          nullable: true
          description: Upload file ID if transferred via `local_file`.
    RetrieverResource:
      type: object
      description: Citation and attribution information for a retriever resource.
      properties:
        id:
          type: string
          format: uuid
          description: Unique ID of the retriever resource.
        message_id:
          type: string
          format: uuid
          description: ID of the message this resource belongs to.
        position:
          type: integer
          description: Position of the resource in the list.
        dataset_id:
          type: string
          format: uuid
          description: ID of the knowledge base.
        dataset_name:
          type: string
          description: Name of the knowledge base.
        document_id:
          type: string
          format: uuid
          description: ID of the document.
        document_name:
          type: string
          description: Name of the document.
        data_source_type:
          type: string
          description: Type of the data source.
        segment_id:
          type: string
          format: uuid
          description: ID of the specific chunk within the document.
        score:
          type: number
          format: float
          description: Similarity score of the resource.
        hit_count:
          type: integer
          description: Number of times this chunk was hit.
        word_count:
          type: integer
          description: Word count of the chunk.
        segment_position:
          type: integer
          description: Position of the chunk within the document.
        index_node_hash:
          type: string
          description: Hash of the index node.
        content:
          type: string
          description: Content snippet from the resource.
        summary:
          type: string
          nullable: true
          description: Summary of the chunk content.
        created_at:
          type: integer
          format: int64
          description: Creation timestamp (Unix epoch seconds).
    AgentThoughtItem:
      type: object
      description: An agent thought step in the message.
      properties:
        id:
          type: string
          format: uuid
          description: Agent thought ID.
        chain_id:
          type: string
          nullable: true
          description: Chain ID for this thought.
        message_id:
          type: string
          format: uuid
          description: Unique message ID this thought belongs to.
        position:
          type: integer
          description: Position of this thought.
        thought:
          type: string
          description: What LLM is thinking.
        tool:
          type: string
          description: Tools called, split by `;`.
        tool_labels:
          type: object
          nullable: true
          additionalProperties: true
          description: Labels for tools used.
        tool_input:
          type: string
          description: Input of tools in JSON format.
        observation:
          type: string
          description: Response from tool calls.
        files:
          type: array
          items:
            type: string
          description: File IDs related to this thought.
        created_at:
          type: integer
          format: int64
          description: Creation timestamp.
    HumanInputContent:
      type: object
      description: >-
        Execution content from a Human Input node, including form definition and
        submission data.
      properties:
        workflow_run_id:
          type: string
          description: ID of the workflow run this content belongs to.
        submitted:
          type: boolean
          description: Whether the human input form has been submitted.
        type:
          type: string
          description: '`human_input` for human input content.'
        form_definition:
          $ref: '#/components/schemas/HumanInputFormDefinition'
          nullable: true
          description: >-
            Form definition from the Human Input node. `null` when the content
            represents a submission response.
        form_submission_data:
          $ref: '#/components/schemas/HumanInputFormSubmissionData'
          nullable: true
          description: >-
            Submitted form data. `null` when the form has not been submitted
            yet.
    HumanInputFormDefinition:
      type: object
      description: Definition of a human input form rendered by a Human Input node.
      properties:
        form_id:
          type: string
          description: Unique form identifier.
        node_id:
          type: string
          description: ID of the Human Input node that generated this form.
        node_title:
          type: string
          description: Title of the Human Input node.
        form_content:
          type: string
          description: Markdown or text content displayed with the form.
        inputs:
          type: array
          description: Input fields in the form.
          items:
            $ref: '#/components/schemas/FormInput'
        actions:
          type: array
          description: Action buttons available on the form.
          items:
            $ref: '#/components/schemas/UserAction'
        display_in_ui:
          type: boolean
          description: Whether the form should be displayed in the UI.
        form_token:
          type: string
          nullable: true
          description: Token for form submission authentication.
        resolved_default_values:
          type: object
          additionalProperties: true
          description: >-
            Resolved default values for form inputs, keyed by output variable
            name.
        expiration_time:
          type: integer
          description: Unix timestamp when the form expires.
    HumanInputFormSubmissionData:
      type: object
      description: Data from a submitted human input form.
      properties:
        node_id:
          type: string
          description: ID of the Human Input node.
        node_title:
          type: string
          description: Title of the Human Input node.
        rendered_content:
          type: string
          description: Rendered content of the form submission.
        action_id:
          type: string
          description: ID of the action button that was clicked.
        action_text:
          type: string
          description: Display text of the action button that was clicked.
    FormInput:
      type: object
      description: A form input field definition.
      properties:
        type:
          type: string
          description: '`text_input` for single-line text, `paragraph` for multi-line text.'
        output_variable_name:
          type: string
          description: Variable name where the input value is stored.
        default:
          $ref: '#/components/schemas/FormInputDefault'
          nullable: true
          description: Default value configuration for this input.
    UserAction:
      type: object
      description: An action button on a human input form.
      properties:
        id:
          type: string
          description: Unique action identifier.
        title:
          type: string
          description: Button display text.
        button_style:
          type: string
          description: '`primary`, `default`, `accent`, or `ghost`.'
    FormInputDefault:
      type: object
      description: Default value configuration for a form input.
      properties:
        type:
          type: string
          description: >-
            `variable` for dynamic values from workflow variables, `constant`
            for static values.
        selector:
          type: array
          items:
            type: string
          description: Variable selector path when `type` is `variable`.
        value:
          type: string
          description: Static value when `type` is `constant`.
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        API Key authentication. For all API requests, include your API Key in
        the `Authorization` HTTP Header, prefixed with `Bearer `. Example:
        `Authorization: Bearer {API_KEY}`. **Strongly recommend storing your API
        Key on the server-side, not shared or stored on the client-side, to
        avoid possible API-Key leakage that can lead to serious consequences.**

````