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

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

> **対象アプリ**：Chatflow。

会話の履歴をスクロール読み込み向けの形式で返します。`first_id` を指定しない場合は、最新の `limit` 件を古い順に返します。`first_id` を指定すると、そのメッセージより前の履歴を返します。

**標準 API の対応する操作**：[会話履歴メッセージ一覧を取得](/ja/3.13.x/develop/api/conversations/list-conversation-messages)。相違点は次のとおりです。

- `user` が必須です。
- 次のレスポンスフィールドは値が固定です。
    - `feedback` は常に `null` です。
    - `retriever_resources` は常に空です。
    - `agent_thoughts` は常に空です。
    - `parent_message_id` は常にすべて 0 の UUID です。
- エラーコードが異なります。



## OpenAPI

````yaml /ja/3.13.x/develop/api/openapi_service.json get /v2/messages
openapi: 3.0.1
info:
  title: Dify サービス API
  description: >-
    Dify アプリケーションとナレッジベースのための REST API です。アプリケーション系エンドポイントはアプリの API
    キーで、ナレッジ系エンドポイントはナレッジベースの API キーで認証します。
  version: 1.0.0
servers:
  - url: https://{api_base_url}
    description: Dify サービス API のベース URL です。ご利用のデプロイ環境の API ベース URL に置き換えてください。
    variables:
      api_base_url:
        default: api.example.com/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: 人間の入力を要する一時停止中のワークフローの再開操作です。
  - name: ワークフロー実行
    description: ワークフローの実行と管理のための操作です。
  - name: 完了メッセージ
    description: テキスト生成に関連する操作です。
  - name: ナレッジベース
    description: ナレッジベースの作成、設定、取得を含むナレッジベース管理の操作です。
  - name: ドキュメント
    description: ナレッジベース内のドキュメントの作成、更新、管理のための操作です。
  - name: チャンク
    description: ドキュメントチャンクと子チャンクの管理のための操作です。
  - name: メタデータ
    description: ナレッジベースのメタデータフィールドとドキュメントメタデータ値の管理のための操作です。
  - name: タグ管理
    description: ナレッジベースタグとタグバインディングの管理のための操作です。
  - name: モデル
    description: 利用可能なモデルを取得するための操作です。
  - name: ナレッジパイプライン
    description: データソースプラグインとパイプライン実行を含むナレッジパイプラインの管理と実行のための操作です。
  - name: デプロイ環境
    description: >-
      デプロイ環境が `v2` ベース URL
      で提供するエンドポイントです。デプロイ環境が提供するのはこのグループのエンドポイントだけで、それ以外のパスを呼び出すと `404
      not_found` が返ります。認証とエラーは標準の Service API
      とは異なります。デプロイ環境については、このグループの各ページが正式な情報源です。
paths:
  /v2/messages:
    get:
      tags:
        - デプロイ環境
      summary: 会話履歴メッセージ一覧を取得
      description: >-
        **対象アプリ**：Chatflow。


        会話の履歴をスクロール読み込み向けの形式で返します。`first_id` を指定しない場合は、最新の `limit`
        件を古い順に返します。`first_id` を指定すると、そのメッセージより前の履歴を返します。


        **標準 API
        の対応する操作**：[会話履歴メッセージ一覧を取得](/ja/3.13.x/develop/api/conversations/list-conversation-messages)。相違点は次のとおりです。


        - `user` が必須です。

        - 次のレスポンスフィールドは値が固定です。
            - `feedback` は常に `null` です。
            - `retriever_resources` は常に空です。
            - `agent_thoughts` は常に空です。
            - `parent_message_id` は常にすべて 0 の UUID です。
        - エラーコードが異なります。
      operationId: listDeployedMessagesJa
      parameters:
        - name: user
          in: query
          required: true
          description: >-
            エンドユーザーの識別子。アプリ側で定義し、アプリ内で一意にします。会話はアプリ、環境、この `user`
            の組み合わせに属します。後から読み取りや変更を行うときは、同じ値を送信してください。[エンドユーザーの識別](/ja/3.13.x/develop/api/guides/end-user-identity)
            を参照してください。
          schema:
            type: string
            minLength: 1
            maxLength: 255
        - name: conversation_id
          in: query
          required: true
          description: >-
            読み取る会話の ID です。会話 ID は
            [会話一覧を取得](/ja/3.13.x/develop/api/deployed-environments/list-conversations)
            で取得します。
          schema:
            type: string
            format: uuid
        - name: first_id
          in: query
          required: false
          description: >-
            ページネーションカーソルです。現在のページの最初のメッセージの `id`
            を指定します。渡すと前（より古い）ページを取得し、省略すると最新のメッセージを取得します。
          schema:
            type: string
            format: uuid
        - name: limit
          in: query
          required: false
          description: リクエストごとに返すチャット履歴メッセージの数です。
          schema:
            type: integer
            default: 20
            minimum: 1
            maximum: 100
      responses:
        '200':
          description: この会話のメッセージの 1 ページ分です。古い順に並びます。
          content:
            application/json:
              schema:
                type: object
                properties:
                  limit:
                    type: integer
                    description: このページに適用されたページサイズです。
                  has_more:
                    type: boolean
                    description: さらに古いメッセージがあるかどうかです。
                  data:
                    type: array
                    description: メッセージです。古いものから順に並びます。
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          description: メッセージ ID。
                        conversation_id:
                          type: string
                          description: 会話 ID。
                        parent_message_id:
                          type: string
                          description: この API で作成したメッセージでは、常にすべて 0 の UUID です。
                        inputs:
                          type: object
                          description: このターンの入力変数です。
                          additionalProperties: true
                        query:
                          type: string
                          description: ユーザーの質問です。
                        answer:
                          type: string
                          description: アプリの回答です。認識できるファイルリンクは、最新のダウンロード URL に更新されます。
                        feedback:
                          type: object
                          nullable: true
                          description: 常に `null` です。デプロイ環境ではメッセージフィードバックを利用できません。
                          additionalProperties: true
                        retriever_resources:
                          type: array
                          description: デプロイ環境では常に空の配列です。
                          items:
                            type: object
                            properties: {}
                        created_at:
                          type: integer
                          description: 作成時刻（Unix タイムスタンプ、秒）です。
                        agent_thoughts:
                          type: array
                          description: デプロイ環境では常に空の配列です。
                          items:
                            type: object
                            properties: {}
                        message_files:
                          type: array
                          description: このターンに添付されたファイルです。
                          items:
                            type: object
                            properties:
                              id:
                                type: string
                                description: メッセージとファイルを結び付ける安定した ID です。
                              filename:
                                type: string
                                description: ファイル名。
                              type:
                                type: string
                                description: >-
                                  ファイルの分類です。`image`、`audio`、`video`、`document`
                                  のいずれかです。
                              url:
                                type: string
                                description: >-
                                  相対的なダウンロード URL です。`user`
                                  のクエリ値（ツールが生成したファイルの場合は `kind=tool`
                                  も）を既に含みます。デプロイ環境のベース URL に対して取得してください。
                              mime_type:
                                type: string
                                description: MIME タイプです。
                              size:
                                type: integer
                                description: ファイルサイズ（バイト）。
                              transfer_method:
                                type: string
                                description: >-
                                  アップロードしたファイルは `local_file`、ツールが生成したファイルは
                                  `tool_file` です。
                              belongs_to:
                                type: string
                                description: '`user` または `assistant` です。'
                              upload_file_id:
                                type: string
                                description: >-
                                  ファイル自体の ID
                                  です。[ファイルをダウンロード](/ja/3.13.x/develop/api/deployed-environments/download-file)
                                  で使用できます。
                        message_tokens:
                          type: integer
                          description: 入力トークン数です。
                        answer_tokens:
                          type: integer
                          description: 出力トークン数です。
                        total_tokens:
                          type: integer
                          description: >-
                            このターンの合計トークン数です。`message_tokens` と `answer_tokens`
                            の合計になります。
                        provider_response_latency:
                          type: number
                          description: デプロイ環境では常に `0` です。
                        total_price:
                          type: string
                          nullable: true
                          description: このターンの合計コストです。取得できない場合は `null` です。
                        currency:
                          type: string
                          nullable: true
                          description: コストの通貨です。取得できない場合は `null` です。
                        status:
                          type: string
                          description: >-
                            `normal`、`stopped`、`error` のいずれかです。実行中のターンは `normal`
                            として返ります。
                        error:
                          type: string
                          nullable: true
                          description: 実行のエラーメッセージです。成功した場合は `null` です。
                        extra_contents:
                          type: array
                          description: デプロイ環境では常に空の配列です。
                          items:
                            type: object
                            properties: {}
              examples:
                ok:
                  summary: レスポンス例
                  value:
                    limit: 20
                    has_more: false
                    data:
                      - id: 7c9e6679-7425-40de-944b-e07fc1f90ae7
                        conversation_id: 0f8fad5b-d9cb-469f-a165-70867728950e
                        parent_message_id: 00000000-0000-0000-0000-000000000000
                        inputs:
                          order_id: ORDER-1001
                        query: Where is my refund now?
                        answer: Your refund is being processed by the bank.
                        feedback: null
                        retriever_resources: []
                        created_at: 1787788860
                        agent_thoughts: []
                        message_files:
                          - id: a8098c1a-f86e-51da-bd1e-66d42f3f323a
                            filename: receipt.pdf
                            type: document
                            url: >-
                              /v2/files/16fd2706-8baf-433b-82eb-8c7fada847da/preview?user=customer-001
                            mime_type: application/pdf
                            size: 48231
                            transfer_method: local_file
                            belongs_to: user
                            upload_file_id: 16fd2706-8baf-433b-82eb-8c7fada847da
                        message_tokens: 28
                        answer_tokens: 19
                        total_tokens: 47
                        provider_response_latency: 0
                        total_price: '0.0012'
                        currency: USD
                        status: normal
                        error: null
                        extra_contents: []
        '400':
          description: >-
            - `invalid_param`：パスまたはクエリの値が検証ルールに違反しています。`message`
            には、値が違反したルールが入ります。たとえば `conversation_id` の形式が不正な場合は `value must be a
            valid UUID` です。

            - `invalid_param`：`user` が空白文字だけです。`message` は `invalid argument`
            です。

            - `not_chat_app`：API キーが Chatflow 以外のアプリのものです。

            - `app_unavailable`：このアプリは現在、この環境で API リクエストを処理できません。
                - API アクセスが無効になっています。
                - アプリがこの環境にデプロイされていません。
                - デプロイがまだ進行中です。
                - 環境が削除中です。

                アプリの担当者に **アクセスポイント** タブを、管理者にエンタープライズ ダッシュボードで環境を確認してもらってください。アプリが応答できるようになったら再試行してください。
          content:
            application/json:
              examples:
                invalid_param:
                  summary: invalid_param
                  value:
                    code: invalid_param
                    message: >-
                      invalid ListServiceAPIMessagesRequest.ConversationId:
                      value must be a valid UUID | caused by: invalid uuid
                      format
                    status: 400
                invalid_param_user:
                  summary: invalid_param（空白のみの user）
                  value:
                    code: invalid_param
                    message: invalid argument
                    status: 400
                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.
                app_unavailable:
                  summary: app_unavailable
                  value:
                    status: 400
                    code: app_unavailable
                    message: App unavailable, please check your app configurations.
        '401':
          description: '`unauthorized`：API キーがない、形式が不正、不明、または取り消されています。'
          content:
            application/json:
              examples:
                unauthorized:
                  summary: unauthorized
                  value:
                    code: unauthorized
                    message: Access token is invalid
                    status: 401
        '404':
          description: |-
            - `not_found`：会話が存在しないか、この `user` に属していません。
            - `not_found`：`first_id` が指すメッセージがこの会話にありません。
          content:
            application/json:
              examples:
                not_found:
                  summary: not_found
                  value:
                    status: 404
                    code: not_found
                    message: Conversation Not Exists.
                not_found_first_message:
                  summary: not_found（first_id）
                  value:
                    code: not_found
                    message: First Message Not Exists.
                    status: 404
        '500':
          description: >-
            `internal_server_error`：プラットフォームがリクエストを完了できませんでした。再試行し、それでも続く場合は管理者に連絡してください。
          content:
            application/json:
              examples:
                internal_server_error:
                  summary: internal_server_error
                  value:
                    code: internal_server_error
                    message: internal error
                    status: 500
      servers:
        - url: https://{deployed_api_base_url}
          description: >-
            すべてのデプロイ環境が共有するベース URL です。標準の Service API アドレスで `/v1` を `/v2`
            に置き換えたものです。
          variables:
            deployed_api_base_url:
              default: api.example.com
              description: >-
                アプリの **アクセスポイント** タブで、いずれかのデプロイ環境の **バックエンドサービス API** カードから完全な
                URL をコピーし、先頭の `https://` と末尾の `/v2` を除いてください。
components:
  securitySchemes:
    ApiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API_KEY
      description: >-
        すべてのリクエストは API キーで認証します：`Authorization: Bearer
        {API_KEY}`。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API
        キーを使用します（[Dify API
        クイックスタート](/ja/3.13.x/develop/api/guides/get-started)）。


        キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーが欠落または無効なリクエストは HTTP
        `401`（`unauthorized`）で失敗します。

````