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

# Get Query History

> Fetches the query history and metadata for a specified time range, including sensitive information such as inputs to and outputs from the AI system.

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


### Permissions

Requires `Territory admin` or `Organization admin`, and `View history` permissions.


## OpenAPI

````yaml /history_export_api.json get /api/v1/history/query
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.
  version: 2.0.0
  contact:
    email: support@harvey.ai
servers:
  - url: https://api.harvey.ai
    description: Harvey API server
security: []
paths:
  /api/v1/history/query:
    get:
      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.


        > **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.
      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: []
components:
  schemas:
    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
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````