{
  "openapi": "3.0.1",
  "info": {
    "title": "v2 - Harvey History Export API",
    "description": "The Harvey API enables customers to fetch query and workspace history for their workspace. This includes query events and usage history with relevant metadata.\n",
    "version": "2.0.0",
    "contact": {
      "email": "support@harvey.ai"
    }
  },
  "servers": [
    {
      "url": "https://api.harvey.ai",
      "description": "Harvey API server"
    }
  ],
  "x-readme": {
    "explorer-enabled": false,
    "proxy-enabled": true
  },
  "paths": {
    "/api/v1/history/usage": {
      "get": {
        "x-mint": {
          "content": "### Permissions\nRequires `Access Sensitive Usage History via API` permission. If this permission is not available to select, contact support@harvey.ai."
        },
        "tags": [
          "Usage"
        ],
        "summary": "Get Usage History",
        "description": "Fetches the usage history and metadata for a specified time range. Includes query events from your workspace users across Harvey product areas. The data includes basic metadata like user, timestamp and event kind. \n\nIt does **not** include sensitive information such as inputs to or outputs from the AI system.\n",
        "operationId": "getUsageHistory",
        "parameters": [
          {
            "name": "start_time",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "date-time",
              "description": "UTC epoch timestamp, up to 1 year ago from now"
            }
          },
          {
            "name": "end_time",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "date-time",
              "description": "UTC epoch timestamp, up to 30 days from start_time. Note: The API supports a maximum range of 30 days, but it's best to retrieve a max of one day at a time on a regular cadence."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of events with UsageHistory entries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/UsageHistory"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request."
          },
          "401": {
            "description": "Unauthorized."
          },
          "429": {
            "description": "Rate limit exceeded."
          },
          "500": {
            "description": "Internal server error."
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/history/query": {
      "get": {
        "x-mint": {
          "content": "### Permissions\nRequires `Access Sensitive Usage History via API` permission. If this permission is not available to select, contact support@harvey.ai."
        },
        "tags": [
          "Queries"
        ],
        "summary": "Get Query History",
        "description": "Fetches the query history and metadata for a specified time range, including sensitive information such as inputs to and outputs from the AI system.\n\n> **Warning:** These APIs include sensitive data for resource names across your entire workspace, and are not gated by any form of client-matter or ethical wall boundaries. We recommend caution when pulling this information via API and sharing API tokens carefully and selectively.\n",
        "operationId": "getQueryHistory",
        "parameters": [
          {
            "name": "start_time",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "date-time",
              "description": "UTC epoch timestamp, up to 2023-07-14"
            }
          },
          {
            "name": "end_time",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "date-time",
              "description": "UTC epoch timestamp, up to 30 days from start_time. Note: The API supports a maximum range of 30 days, but it's best to retrieve a max of one day at a time on a regular cadence."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Array of events with QueryHistory entries",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/QueryHistory"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad request."
          },
          "401": {
            "description": "Unauthorized."
          },
          "429": {
            "description": "Rate limit exceeded."
          },
          "500": {
            "description": "Internal server error."
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v2/history/usage": {
      "get": {
        "x-mint": {
          "content": "### Permissions\nRequires `Access Sensitive Usage History via API` permission. If this permission is not available to select, contact support@harvey.ai."
        },
        "tags": [
          "Usage"
        ],
        "summary": "Get Usage History (v2)",
        "description": "Fetches the usage history and metadata for a specified time range. Returns enriched event data with product surface area, subsurface details, and additional metadata across Harvey product areas.\n\n> **Warning:** These APIs include sensitive data for resource names across your entire workspace, and are not gated by any form of client-matter or ethical wall boundaries. We recommend caution when pulling this information via API and sharing API tokens carefully and selectively.\n",
        "operationId": "getUsageHistoryV2",
        "parameters": [
          {
            "name": "start_time",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "date-time",
              "description": "UTC epoch timestamp, up to 1 year ago from now"
            }
          },
          {
            "name": "end_time",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "date-time",
              "description": "UTC epoch timestamp, up to 30 days from start_time. Note: The API supports a maximum range of 30 days, but it's best to retrieve a max of one day at a time on a regular cadence."
            }
          },
          {
            "name": "include_file_ids",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false,
              "description": "When set to true, the response will include file_ids for each event. This may impact performance, so only enable when needed (e.g., to use with the file download endpoint)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Object containing an array of V2UsageHistory events",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2UsageHistoryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request."
          },
          "401": {
            "description": "Unauthorized."
          },
          "429": {
            "description": "Rate limit exceeded."
          },
          "500": {
            "description": "Internal server error."
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v2/history/query": {
      "get": {
        "x-mint": {
          "content": "### Permissions\nRequires `Access Sensitive Usage History via API` permission. If this permission is not available to select, contact support@harvey.ai."
        },
        "tags": [
          "Queries"
        ],
        "summary": "Get Query History (v2)",
        "description": "Fetches the query history and metadata for a specified time range, including sensitive information such as inputs to and outputs from the AI system. Returns enriched event data with product surface area, subsurface details, and additional metadata.\n\n> **Warning:** These APIs include sensitive data for resource names across your entire workspace, and are not gated by any form of client-matter or ethical wall boundaries. We recommend caution when pulling this information via API and sharing API tokens carefully and selectively.\n",
        "operationId": "getQueryHistoryV2",
        "parameters": [
          {
            "name": "start_time",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "date-time",
              "description": "UTC epoch timestamp, up to 1 year ago from now"
            }
          },
          {
            "name": "end_time",
            "in": "query",
            "required": true,
            "schema": {
              "type": "integer",
              "format": "date-time",
              "description": "UTC epoch timestamp, up to 30 days from start_time. Note: The API supports a maximum range of 30 days, but it's best to retrieve a max of one day at a time on a regular cadence."
            }
          },
          {
            "name": "include_file_ids",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false,
              "description": "When set to true, the response will include file_ids for each event. This may impact performance, so only enable when needed (e.g., to use with the file download endpoint)."
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Object containing an array of V2QueryHistory events",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2QueryHistoryResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request."
          },
          "401": {
            "description": "Unauthorized."
          },
          "429": {
            "description": "Rate limit exceeded."
          },
          "500": {
            "description": "Internal server error."
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/api/v1/files/download": {
      "post": {
        "x-hidden": true,
        "x-mint": {
          "metadata": {
            "title": "POST Download Files"
          }
        },
        "tags": [
          "Queries"
        ],
        "summary": "Download Files",
        "description": "Returns time-limited download URLs for files by their IDs. Provide one or more file IDs (as returned from Get Query History) to receive pre-signed URLs for downloading those files.",
        "operationId": "fileDownload",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/FileDownloadRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Download URLs returned successfully",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FileDownloadResponse"
                }
              }
            }
          },
          "400": {
            "description": "Bad request."
          },
          "401": {
            "description": "Unauthorized."
          },
          "429": {
            "description": "Rate limit exceeded."
          },
          "500": {
            "description": "Internal server error."
          }
        },
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "UsageHistory": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "integer",
            "description": "Unique identifier for the usage event.",
            "example": 103230489
          },
          "message_ID": {
            "type": "string",
            "format": "uuid",
            "description": "ID of the message.",
            "example": "ab12a1ab-abcd-1a12-1234-1234ab123456"
          },
          "Time": {
            "type": "string",
            "format": "date-time",
            "description": "Timestamp of the event.",
            "example": "2024-09-03T14:47:12.000Z"
          },
          "User": {
            "type": "string",
            "description": "Email of the user who triggered the event.",
            "example": "user@example.com"
          },
          "Task": {
            "type": "string",
            "description": "Type of query.",
            "enum": [
              "Assist",
              "Company Profile",
              "Draft",
              "Redlines Issues List",
              "Redlines Q&A",
              "Translation",
              "Vault Review",
              "Workflows"
            ],
            "example": "Assist"
          },
          "Client Matter #": {
            "type": "string",
            "description": "Client matter ID, if exists.",
            "example": 1234.56
          },
          "Source": {
            "type": "string",
            "description": "Source of the event.",
            "enum": [
              "Files",
              "EDGAR",
              "EUR-Lex",
              "Vault"
            ],
            "example": "Files"
          },
          "Number of documents": {
            "type": "integer",
            "description": "Sum of all uploaded documents",
            "example": 5
          },
          "Feedback Comments": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Description of negative feedback - can be all or any of Hallucination, Incomplete response, Poor formatting, Something else. Only Negative Feedback can have comments.",
            "example": "Incomplete response"
          },
          "Feedback Sentiment": {
            "type": "string",
            "description": "The sentiment of the feedback given, if any, either Positive or Negative.",
            "example": "negative"
          }
        }
      },
      "QueryHistory": {
        "type": "object",
        "properties": {
          "event_id": {
            "type": "integer",
            "description": "Unique identifier for the usage event.",
            "example": 103230489
          },
          "Time": {
            "type": "string",
            "format": "date-time",
            "description": "Timestamp of the event.",
            "example": "2024-09-03T14:47:12.000Z"
          },
          "User": {
            "type": "string",
            "description": "Email of the user who triggered the event.",
            "example": "user@example.com"
          },
          "Task": {
            "type": "string",
            "description": "Type of query.",
            "enum": [
              "Assist",
              "Company Profile",
              "Draft",
              "Redlines Issues List",
              "Redlines Q&A",
              "Translation",
              "Vault Review",
              "Workflows"
            ],
            "example": "Assist"
          },
          "Client Matter #": {
            "type": "string",
            "description": "Client matter ID, if exists.",
            "example": 1234.56
          },
          "Source": {
            "type": "string",
            "description": "Source of the event.",
            "enum": [
              "Files",
              "EDGAR",
              "EUR-Lex",
              "Vault"
            ],
            "example": "Files"
          },
          "Query": {
            "type": "string",
            "description": "Query submitted by the user.",
            "example": "In 3 sentences, can you explain how indemnity and limitation of liability clauses typically work in commercial contracts?"
          },
          "Response": {
            "type": "string",
            "description": "Response for the query.",
            "example": "Indemnity clauses in commercial contracts require one party to compensate the other for certain losses or damages arising from specified events, such as breaches or third-party claims. Limitation of liability clauses cap the amount or types of damages one party can recover from the other, often excluding indirect or consequential losses. Together, these clauses allocate and manage risk between the parties, providing predictability and protecting against potentially catastrophic financial exposure."
          },
          "Documents": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Document names associated with the query, if any.",
            "example": "2025_IP_Licensing_Terms_Redline_vs_2024.docx"
          },
          "Number of documents": {
            "type": "integer",
            "description": "Sum of all uploaded documents",
            "example": 1
          },
          "Link": {
            "type": "string",
            "description": "The link Workspace Admins can use to view the Workspace History item.",
            "example": "https://app.harvey.ai/assistant/assist/123456789"
          }
        }
      },
      "V2UsageHistoryResponse": {
        "type": "object",
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/V2UsageHistory"
            },
            "description": "Array of usage history events."
          }
        }
      },
      "V2UsageHistory": {
        "type": "object",
        "properties": {
          "access_point": {
            "type": "string",
            "description": "The access point from which the event was triggered.",
            "example": "WEB"
          },
          "action": {
            "type": "string",
            "description": "The type of action performed.",
            "example": "CREATE"
          },
          "cm_id": {
            "type": "string",
            "description": "Client matter number associated with the event, if any.",
            "example": "1234.56"
          },
          "file_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Array of file IDs associated with the event. Only included when the include_file_ids query parameter is set to true.",
            "example": ["019d35f0-4cf5-7296-aef5-45991d83a77b", "019d35f0-4cf1-7f4f-a09b-885f9066638e"]
          },
          "files_metadata": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryFileMetadata"
            },
            "description": "Per-file metadata for the entries in file_ids: whether each file was attached by the user or generated by Harvey, and (for user-attached files) where it came from. Only included when the include_file_ids query parameter is set to true.",
            "example": [
              { "id": "019d35f0-4cf5-7296-aef5-45991d83a77b", "role": "user_attached", "source": "file_upload" },
              { "id": "019d35f0-4cf1-7f4f-a09b-885f9066638e", "role": "generated" }
            ]
          },
          "parent_thread_id": {
            "type": "integer",
            "description": "Parent Thread ID indicates the original started thread, and can appear more than once (e.g., if someone asks a follow-up in a thread three times, it will appear those three times).",
            "example": 2374992
          },
          "playbook_name": {
            "type": "string",
            "description": "Name of the playbook used, if any.",
            "example": ""
          },
          "playbook_id": {
            "type": "string",
            "description": "Stable identifier for the playbook used, if any. Persists across playbook renames so consumers can group activity by playbook over time.",
            "example": ""
          },
          "product_surface_area": {
            "type": "string",
            "description": "The Harvey product area(s) where the event occurred.",
            "example": "ASSISTANT"
          },
          "review_table_name": {
            "type": "string",
            "description": "Name of the Vault review table, if applicable.",
            "example": "Supply Agreement Details and Key Terms"
          },
          "review_table_id": {
            "type": "string",
            "description": "Stable identifier for the Vault review table, if applicable. Persists across review table renames so consumers can group activity by review table over time.",
            "example": "019c85a7-a7c9-784f-bc59-0ddd5654274d"
          },
          "source": {
            "type": "string",
            "description": "Source(s) of the documents or data used in the event.",
            "example": "Files"
          },
          "space_name": {
            "type": "string",
            "description": "Name of the space associated with the event, if any.",
            "example": ""
          },
          "space_id": {
            "type": "string",
            "description": "Stable identifier for the space associated with the event, if any. Persists across space renames so consumers can group activity by space over time.",
            "example": ""
          },
          "subsurface": {
            "type": "string",
            "description": "The specific subsurface(s) or feature(s) within the product surface area.",
            "example": "ASSISTANT_THREAD, ASSISTANT_THREAD_FOLLOWUP"
          },
          "utc_time": {
            "type": "string",
            "description": "Timestamp of the event in UTC.",
            "example": "2026-02-22 14:01:23"
          },
          "unique_usage_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the usage event.",
            "example": "019c85a7-a7c9-784f-bc59-0ddd5654274d"
          },
          "user": {
            "type": "string",
            "description": "Email of the user who triggered the event.",
            "example": "user@example.com"
          },
          "vault_project_name": {
            "type": "string",
            "description": "Name of the Vault project, if applicable.",
            "example": "48CommercialContracts"
          },
          "vault_project_id": {
            "type": "string",
            "description": "Stable identifier(s) for the Vault project(s), comma-joined in the same order as vault_project_name so consumers can zip the two columns 1:1. Persists across project renames.",
            "example": "019c85a7-a7c9-784f-bc59-0ddd5654274d"
          },
          "workflow_name": {
            "type": "string",
            "description": "Name of the workflow used, if any.",
            "example": ""
          },
          "workflow_id": {
            "type": "string",
            "description": "Stable identifier for the workflow used, if any. Persists across workflow renames so consumers can group activity by workflow over time.",
            "example": ""
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Additional context specific to the product surface area and subsurface of the event. The keys and values vary depending on the event type. For example, a VAULT / REVIEW_TABLE event will include `num_columns` and `num_files`.",
            "example": { "num_columns": 5, "num_files": 48 }
          }
        }
      },
      "V2QueryHistoryResponse": {
        "type": "object",
        "properties": {
          "events": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/V2QueryHistory"
            },
            "description": "Array of query history events."
          }
        }
      },
      "V2QueryHistory": {
        "type": "object",
        "properties": {
          "access_point": {
            "type": "string",
            "description": "The access point from which the event was triggered.",
            "example": "WEB"
          },
          "action": {
            "type": "string",
            "description": "The type of action performed.",
            "example": "CREATE"
          },
          "cm_id": {
            "type": "string",
            "description": "Client matter number associated with the event, if any.",
            "example": "1234.56"
          },
          "feedback_comments": {
            "type": "string",
            "description": "Feedback comments left by the user, if any.",
            "example": ""
          },
          "feedback_sentiments": {
            "type": "string",
            "description": "The sentiment of the feedback given, if any.",
            "example": ""
          },
          "file_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Array of file IDs associated with the event. Only included when the include_file_ids query parameter is set to true.",
            "example": ["019d35f0-4cf5-7296-aef5-45991d83a77b", "019d35f0-4cf1-7f4f-a09b-885f9066638e"]
          },
          "files_metadata": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/HistoryFileMetadata"
            },
            "description": "Per-file metadata for the entries in file_ids: whether each file was attached by the user or generated by Harvey, and (for user-attached files) where it came from. Only included when the include_file_ids query parameter is set to true.",
            "example": [
              { "id": "019d35f0-4cf5-7296-aef5-45991d83a77b", "role": "user_attached", "source": "file_upload" },
              { "id": "019d35f0-4cf1-7f4f-a09b-885f9066638e", "role": "generated" }
            ]
          },
          "link": {
            "type": "string",
            "description": "URL that Workspace Admins can use to view the event in Harvey.",
            "example": "https://app.harvey.ai/assistant/assist/2374992"
          },
          "parent_thread_id": {
            "type": "integer",
            "description": "Parent Thread ID indicates the original started thread, and can appear more than once (e.g., if someone asks a follow-up in a thread three times, it will appear those three times).",
            "example": 2374992
          },
          "playbook_name": {
            "type": "string",
            "description": "Name of the playbook used, if any.",
            "example": ""
          },
          "playbook_id": {
            "type": "string",
            "description": "Stable identifier for the playbook used, if any. Persists across playbook renames so consumers can group activity by playbook over time.",
            "example": ""
          },
          "product_surface_area": {
            "type": "string",
            "description": "The Harvey product area where the event occurred.",
            "example": "ASSISTANT"
          },
          "query": {
            "type": "string",
            "description": "The query or prompt submitted by the user.",
            "example": "In 3 sentences, can you explain how indemnity and limitation of liability clauses typically work in commercial contracts?"
          },
          "response": {
            "type": "string",
            "description": "The AI-generated response to the query. May be \"NA\" for certain event types such as Vault review table runs.",
            "example": "Indemnity clauses in commercial contracts require one party to compensate the other for certain losses or damages arising from specified events, such as breaches or third-party claims."
          },
          "review_table_name": {
            "type": "string",
            "description": "Name of the Vault review table, if applicable.",
            "example": "Supply Agreement Details and Key Terms"
          },
          "review_table_id": {
            "type": "string",
            "description": "Stable identifier for the Vault review table, if applicable. Persists across review table renames so consumers can group activity by review table over time.",
            "example": "019c85a7-a7c9-784f-bc59-0ddd5654274d"
          },
          "source": {
            "type": "string",
            "description": "Source of the documents or data used in the event.",
            "example": "Files"
          },
          "space_name": {
            "type": "string",
            "description": "Name of the space associated with the event, if any.",
            "example": ""
          },
          "space_id": {
            "type": "string",
            "description": "Stable identifier for the space associated with the event, if any. Persists across space renames so consumers can group activity by space over time.",
            "example": ""
          },
          "subsurface": {
            "type": "string",
            "description": "The specific subsurface or feature within the product surface area.",
            "example": "ASSISTANT_THREAD, ASSISTANT_THREAD_FOLLOWUP"
          },
          "utc_time": {
            "type": "string",
            "description": "Timestamp of the event in UTC.",
            "example": "2026-02-22 14:01:23"
          },
          "unique_usage_id": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the usage event.",
            "example": "019c85a7-a7c9-784f-bc59-0ddd5654274d"
          },
          "user": {
            "type": "string",
            "description": "Email of the user who triggered the event.",
            "example": "user@example.com"
          },
          "vault_project_name": {
            "type": "string",
            "description": "Name of the Vault project, if applicable.",
            "example": "48CommercialContracts"
          },
          "vault_project_id": {
            "type": "string",
            "description": "Stable identifier(s) for the Vault project(s), comma-joined in the same order as vault_project_name so consumers can zip the two columns 1:1. Persists across project renames.",
            "example": "019c85a7-a7c9-784f-bc59-0ddd5654274d"
          },
          "workflow_name": {
            "type": "string",
            "description": "Name of the workflow used, if any.",
            "example": ""
          },
          "workflow_id": {
            "type": "string",
            "description": "Stable identifier for the workflow used, if any. Persists across workflow renames so consumers can group activity by workflow over time.",
            "example": ""
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Additional context specific to the product surface area and subsurface of the event. The keys and values vary depending on the event type. For example, a VAULT / REVIEW_TABLE event will include `num_columns` and `num_files`.",
            "example": { "num_columns": 5, "num_files": 48 }
          }
        }
      },
      "HistoryFileRole": {
        "type": "string",
        "enum": ["user_attached", "generated"],
        "description": "Whether a file was attached by the user (user_attached) or generated by Harvey (generated)."
      },
      "HistoryFileSource": {
        "type": "string",
        "enum": [
          "file_upload",
          "vault",
          "sharepoint",
          "google_drive",
          "imanage",
          "imanage_onprem",
          "box",
          "netdocs_extension",
          "netdocs_ndconnect",
          "epona",
          "ironclad",
          "gmail",
          "ansarada"
        ],
        "description": "How a user-attached file was provided (direct upload, Vault, or a document-management integration). Only present on files with role user_attached."
      },
      "HistoryFileMetadata": {
        "type": "object",
        "required": ["id", "role"],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "File UUID. Matches an entry in file_ids.",
            "example": "019d35f0-4cf5-7296-aef5-45991d83a77b"
          },
          "role": {
            "$ref": "#/components/schemas/HistoryFileRole"
          },
          "source": {
            "allOf": [{ "$ref": "#/components/schemas/HistoryFileSource" }],
            "description": "How a user-attached file was provided. Present when role is user_attached; omitted for generated files (the source is Harvey)."
          }
        }
      },
      "FileDownloadRequest": {
        "type": "object",
        "required": ["file_ids"],
        "properties": {
          "file_ids": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uuid"
            },
            "description": "Array of file IDs to download. File IDs are returned in the Get Query History endpoint response."
          }
        }
      },
      "FileDownloadResponse": {
        "type": "object",
        "properties": {
          "files": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/FileDownloadItem"
            },
            "description": "Array of files with time-limited download URLs."
          }
        }
      },
      "FileDownloadItem": {
        "type": "object",
        "properties": {
          "download_url": {
            "type": "string",
            "format": "uri",
            "description": "Time-limited pre-signed URL to download the file."
          },
          "file_id": {
            "type": "string",
            "format": "uuid",
            "description": "The unique identifier of the file."
          },
          "filename": {
            "type": "string",
            "description": "Original filename of the file."
          }
        }
      }
    }
  }
}
