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

# 会話履歴メッセージ一覧を取得

> スクロール読み込み形式で過去のチャット記録を返します。最初のページは最新の `limit` 件のメッセージを返します（時系列の逆順）。



## OpenAPI

````yaml /ja/api-reference/openapi_chatflow.json get /messages
openapi: 3.0.1
info:
  title: 高度なチャットアプリAPI (Chatflow API)
  description: >-
    Chatflow アプリケーションはセッションの永続化をサポートし、過去のチャット履歴をレスポンスのコンテキストとして使用できます。Chatflow
    アプリは `advanced-chat`
    モードを使用し、ノードの開始・完了、イテレーション、ワークフローのライフサイクルを含む詳細な実行追跡のためのワークフローレベルのストリーミングイベントを提供します。
  version: 1.0.0
servers:
  - url: https://{api_base_url}
    description: Chatflow アプリ API のベース URL です。セルフホスト環境では、独自の API ベース URL に置き換えてください。
    variables:
      api_base_url:
        default: api.dify.ai/v1
        description: API ベース URL のホストとパス（`https://` を除く）。
security:
  - ApiKeyAuth: []
tags:
  - name: チャットフロー
    description: チャットフローアプリケーションの操作です（チャットメッセージ、ワークフロー実行詳細、イベントストリーミングを含む）。
  - name: ファイル操作
    description: ファイルのアップロードとプレビューの操作です。
  - name: エンドユーザー
    description: エンドユーザー情報に関連する操作です。
  - name: メッセージフィードバック
    description: ユーザーフィードバックの操作です。
  - name: 会話管理
    description: 会話管理に関連する操作です。
  - name: 音声・テキスト変換
    description: テキスト読み上げと音声認識の操作です。
  - name: アプリケーション設定
    description: アプリケーション設定と情報を取得する操作です。
  - name: アノテーション管理
    description: ダイレクト返信用のアノテーション管理に関連する操作です。
  - name: 人間の入力
    description: 人間の入力を要する一時停止中のワークフローの再開操作です。
paths:
  /messages:
    get:
      tags:
        - 会話管理
      summary: 会話履歴メッセージ一覧を取得
      description: スクロール読み込み形式で過去のチャット記録を返します。最初のページは最新の `limit` 件のメッセージを返します（時系列の逆順）。
      operationId: getChatflowConversationHistoryJp
      parameters:
        - name: conversation_id
          in: query
          required: true
          description: 会話 ID。
          schema:
            type: string
        - name: user
          in: query
          required: false
          description: ユーザー識別子。
          schema:
            type: string
        - name: first_id
          in: query
          required: false
          description: >-
            現在のページの最初のチャット記録の ID です。デフォルトは
            `null`（最新のメッセージを取得）です。次のページを取得するには、現在のリストの最初のメッセージの ID
            を使用して、より古いメッセージを取得します。
          schema:
            type: string
        - name: limit
          in: query
          required: false
          description: リクエストごとに返すチャット履歴メッセージの数です。
          schema:
            type: integer
            default: 20
            minimum: 1
            maximum: 100
      responses:
        '200':
          description: 会話履歴の取得に成功しました。
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ConversationHistoryResponse'
              examples:
                conversationHistory:
                  summary: レスポンス例
                  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` : アプリモードが API ルートと一致しません。'
          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` : 会話が存在しません。
            - `not_found` : 最初のメッセージが存在しません。
          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: 1 ページあたりの件数です。
        has_more:
          type: boolean
          description: さらにメッセージがあるかどうかです。
        data:
          type: array
          description: メッセージのリストです。
          items:
            $ref: '#/components/schemas/ConversationMessageItem'
    ConversationMessageItem:
      type: object
      description: 会話内の単一メッセージです。
      properties:
        id:
          type: string
          format: uuid
          description: メッセージ ID。
        conversation_id:
          type: string
          format: uuid
          description: 会話 ID。
        parent_message_id:
          type: string
          format: uuid
          nullable: true
          description: スレッド会話の親メッセージ ID です。
        inputs:
          type: object
          additionalProperties: true
          description: このメッセージの入力変数です。
        query:
          type: string
          description: ユーザークエリテキストです。
        answer:
          type: string
          description: アシスタントの回答テキストです。
        status:
          type: string
          description: メッセージステータスです。成功したメッセージの場合は `normal`、生成に失敗した場合は `error` です。
        error:
          type: string
          nullable: true
          description: '`status` が `error` の場合のエラーメッセージです。'
        message_files:
          type: array
          description: このメッセージに添付されたファイルです。
          items:
            $ref: '#/components/schemas/MessageFileItem'
        feedback:
          type: object
          nullable: true
          description: このメッセージのユーザーフィードバックです。
          properties:
            rating:
              type: string
              description: フィードバック評価。肯定的な場合は `like`、否定的な場合は `dislike`。
        retriever_resources:
          type: array
          description: このメッセージに使用された検索リソースです。
          items:
            $ref: '#/components/schemas/RetrieverResource'
        agent_thoughts:
          type: array
          description: このメッセージのエージェント思考です。
          items:
            $ref: '#/components/schemas/AgentThoughtItem'
        created_at:
          type: integer
          format: int64
          description: 作成タイムスタンプ（Unix エポック秒）。
        extra_contents:
          type: array
          description: このメッセージに関連する追加の実行コンテンツです。chatflow ワークフローの人間の入力ノードからのフォームデータなどが含まれます。
          items:
            $ref: '#/components/schemas/HumanInputContent'
    MessageFileItem:
      type: object
      description: メッセージに添付されたファイルです。
      properties:
        id:
          type: string
          format: uuid
          description: File ID.
        filename:
          type: string
          description: 元のファイル名です。
        type:
          type: string
          description: 'ファイルの種類（例: `image`）です。'
        url:
          type: string
          format: url
          nullable: true
          description: ファイルのプレビュー URL。
        mime_type:
          type: string
          nullable: true
          description: ファイルの MIME タイプ。
        size:
          type: integer
          nullable: true
          description: ファイルサイズ（バイト）。
        transfer_method:
          type: string
          description: >-
            使用された転送方法です。`remote_url` は URL ベースのファイル、`local_file`
            はアップロード済みファイル、`tool_file` はツール生成ファイルを示します。
        belongs_to:
          type: string
          nullable: true
          description: >-
            このファイルの所有者です。ユーザーがアップロードしたファイルの場合は `user`、アシスタントが生成したファイルの場合は
            `assistant` です。
        upload_file_id:
          type: string
          format: uuid
          nullable: true
          description: '`local_file` で転送された場合のアップロードファイル ID です。'
    RetrieverResource:
      type: object
      description: 検索リソースの引用および帰属情報です。
      properties:
        id:
          type: string
          format: uuid
          description: 検索リソースの一意の ID。
        message_id:
          type: string
          format: uuid
          description: このリソースが属するメッセージの ID。
        position:
          type: integer
          description: リスト内のリソースの位置。
        dataset_id:
          type: string
          format: uuid
          description: ナレッジベース ID。
        dataset_name:
          type: string
          description: ナレッジベース名。
        document_id:
          type: string
          format: uuid
          description: ドキュメント ID。
        document_name:
          type: string
          description: ドキュメント名。
        data_source_type:
          type: string
          description: データソースのタイプ。
        segment_id:
          type: string
          format: uuid
          description: ドキュメント内の特定のチャンクの ID。
        score:
          type: number
          format: float
          description: リソースの関連性スコア。
        hit_count:
          type: integer
          description: このチャンクがヒットした回数。
        word_count:
          type: integer
          description: チャンクの単語数。
        segment_position:
          type: integer
          description: ドキュメント内のチャンクの位置。
        index_node_hash:
          type: string
          description: インデックスノードのハッシュ。
        content:
          type: string
          description: リソースからのコンテンツスニペット。
        summary:
          type: string
          nullable: true
          description: チャンクコンテンツの要約。
        created_at:
          type: integer
          format: int64
          description: 作成タイムスタンプ（Unix エポック秒）。
    AgentThoughtItem:
      type: object
      description: メッセージ内のエージェント思考ステップです。
      properties:
        id:
          type: string
          format: uuid
          description: エージェント思考 ID です。
        chain_id:
          type: string
          nullable: true
          description: この思考のチェーン ID です。
        message_id:
          type: string
          format: uuid
          description: この思考が属する一意のメッセージ ID です。
        position:
          type: integer
          description: この思考の位置です。
        thought:
          type: string
          description: LLM が思考している内容です。
        tool:
          type: string
          description: 呼び出されたツール（`;` で区切り）です。
        tool_labels:
          type: object
          nullable: true
          additionalProperties: true
          description: 使用されたツールのラベルです。
        tool_input:
          type: string
          description: ツールの入力（JSON 形式）です。
        observation:
          type: string
          description: ツール呼び出しからのレスポンスです。
        files:
          type: array
          items:
            type: string
          description: この思考に関連するファイル ID です。
        created_at:
          type: integer
          format: int64
          description: 作成タイムスタンプ。
    HumanInputContent:
      type: object
      description: 人間の入力ノードからの実行コンテンツです。フォーム定義と送信データを含みます。
      properties:
        workflow_run_id:
          type: string
          description: このコンテンツが属するワークフロー実行の ID です。
        submitted:
          type: boolean
          description: 人間の入力フォームが送信されたかどうかです。
        type:
          type: string
          description: '`human_input` は人間の入力コンテンツを示します。'
        form_definition:
          $ref: '#/components/schemas/HumanInputFormDefinition'
          nullable: true
          description: 人間の入力ノードからのフォーム定義です。コンテンツが送信レスポンスを表す場合は `null` です。
        form_submission_data:
          $ref: '#/components/schemas/HumanInputFormSubmissionData'
          nullable: true
          description: 送信されたフォームデータです。フォームがまだ送信されていない場合は `null` です。
    HumanInputFormDefinition:
      type: object
      description: 人間の入力ノードによってレンダリングされる人間の入力フォームの定義です。
      properties:
        form_id:
          type: string
          description: フォームの一意識別子です。
        node_id:
          type: string
          description: このフォームを生成した人間の入力ノードの ID です。
        node_title:
          type: string
          description: 人間の入力ノードのタイトルです。
        form_content:
          type: string
          description: フォームと共に表示される Markdown またはテキストコンテンツです。
        inputs:
          type: array
          description: フォーム内の入力フィールドです。
          items:
            $ref: '#/components/schemas/FormInput'
        actions:
          type: array
          description: フォームで利用可能なアクションボタンです。
          items:
            $ref: '#/components/schemas/UserAction'
        display_in_ui:
          type: boolean
          description: フォームを UI に表示するかどうかです。
        form_token:
          type: string
          nullable: true
          description: フォーム送信認証用のトークンです。
        resolved_default_values:
          type: object
          additionalProperties: true
          description: 出力変数名をキーとする、フォーム入力の解決済みデフォルト値です。
        expiration_time:
          type: integer
          description: フォームが期限切れになる Unix タイムスタンプです。
    HumanInputFormSubmissionData:
      type: object
      description: 送信された人間の入力フォームからのデータです。
      properties:
        node_id:
          type: string
          description: 人間の入力ノードの ID です。
        node_title:
          type: string
          description: 人間の入力ノードのタイトルです。
        rendered_content:
          type: string
          description: フォーム送信のレンダリングされた内容です。
        action_id:
          type: string
          description: クリックされたアクションボタンの ID です。
        action_text:
          type: string
          description: クリックされたアクションボタンの表示テキストです。
    FormInput:
      type: object
      description: フォーム入力フィールドの定義です。
      properties:
        type:
          type: string
          description: >-
            フォーム入力コントロールの種類。使用可能な値：`paragraph`（複数行テキスト）、`select`（リストからの単一選択）、`file`（単一ファイルのアップロード）、`file-list`（複数ファイルのアップロード）。
        output_variable_name:
          type: string
          description: 入力値が格納される変数名です。
        default:
          $ref: '#/components/schemas/FormInputDefault'
          nullable: true
          description: この入力のデフォルト値設定です。
    UserAction:
      type: object
      description: 人間の入力フォーム上のアクションボタンです。
      properties:
        id:
          type: string
          description: アクションの一意識別子です。
        title:
          type: string
          description: ボタンの表示テキストです。
        button_style:
          type: string
          description: '`primary`, `default`, `accent`, or `ghost`.'
    FormInputDefault:
      type: object
      description: フォーム入力のデフォルト値設定です。
      properties:
        type:
          type: string
          description: '`variable` はワークフロー変数からの動的な値、`constant` は静的な値です。'
        selector:
          type: array
          items:
            type: string
          description: '`type` が `variable` の場合の変数セレクターパスです。'
        value:
          type: string
          description: '`type` が `constant` の場合の静的値。'
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        API Key 認証です。すべての API リクエストにおいて、`Authorization` HTTP ヘッダーに `Bearer `
        プレフィックスを付けた API Key を含めてください。例：`Authorization: Bearer {API_KEY}`。**API
        Key はサーバーサイドに保存し、クライアントサイドで共有・保存しないことを強く推奨します。API Key
        の漏洩は深刻な結果につながる可能性があります。**

````