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

# Test-case execution history (batch)

> Returns per-test-case execution history for the requested test cases, plus echoed query metadata.



## OpenAPI

````yaml /api-reference/openapi.generated.json post /api/v2/analytics/test-case-history/batch
openapi: 3.1.0
info:
  title: Empirical API
  version: 1.0.0
  description: Programmatic access to Empirical test runs, snoozes, and more.
  contact:
    name: Empirical
    url: https://empirical.run
servers:
  - url: https://api.empirical.run
security:
  - Bearer: []
tags:
  - name: Analytics
    description: Aggregated test-run, test-count and test-case analytics for a project.
  - name: Analytics (Deprecated)
    description: >-
      Legacy analytics endpoints retained for backwards compatibility; prefer
      the v2 equivalents.
  - name: Environments
    description: >-
      Named deployment targets (slug + Playwright project filters) a project's
      tests run against.
  - name: Snoozes
    description: Temporarily suppress known test failures for specific Playwright tests.
  - name: Telemetry
    description: Product telemetry derived from analytics events, scoped to a project.
  - name: Test Cases
    description: >-
      Browse the Playwright test cases synced from a project's repository and
      manage their tags.
paths:
  /api/v2/analytics/test-case-history/batch:
    post:
      tags:
        - Analytics
      summary: Test-case execution history (batch)
      description: >-
        Returns per-test-case execution history for the requested test cases,
        plus echoed query metadata.
      operationId: getTestCaseHistoryBatch
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TestCaseHistoryBatchRequest'
      responses:
        '200':
          description: History grouped by test case.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestCaseHistoryBatchResponse'
        '400':
          description: Unknown body field(s) supplied.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestCaseHistoryUnknownFieldsError'
        '500':
          description: Analytics backend error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyticsErrorResponse'
components:
  schemas:
    TestCaseHistoryBatchRequest:
      type: object
      properties:
        test_case_ids:
          type: array
          items:
            type: string
          minItems: 1
          description: Test case IDs to fetch history for (non-empty).
        project_id:
          type: integer
          minimum: 1
          description: Project ID (ignored; the project comes from auth scope).
        days:
          type: integer
          minimum: 1
          maximum: 90
          description: >-
            Number of days of history (1-90, default 30). Ignored when
            `start_date` and `end_date` are set.
        start_date:
          type: string
          description: Start of a custom date range (ISO 8601).
        end_date:
          type: string
          description: End of a custom date range (ISO 8601).
        environment_id:
          type: string
          description: Filter by environment ID.
        limit_per_test_case:
          type: integer
          minimum: 1
          maximum: 1000
          description: Maximum history entries returned per test case (1-1000, default 50).
      required:
        - test_case_ids
      additionalProperties:
        nullable: true
    TestCaseHistoryBatchResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            history_by_test_case_id:
              type: object
              additionalProperties:
                type: array
                items:
                  $ref: '#/components/schemas/TestCaseHistoryEntry'
              description: >-
                Map of `test_case_id` to its history entries (most recent
                first).
          required:
            - history_by_test_case_id
          description: Response payload.
        meta:
          type: object
          properties:
            project_id:
              type: string
              description: Project ID the history was scoped to.
            days:
              type: integer
              nullable: true
              description: Resolved look-back window in days, or null.
            start_date:
              type: string
              nullable: true
              description: Resolved custom range start, or null.
            end_date:
              type: string
              nullable: true
              description: Resolved custom range end, or null.
            environment_id:
              type: string
              nullable: true
              description: Resolved environment filter, or null.
            limit_per_test_case:
              type: integer
              description: Resolved per-test-case history limit.
            truncated_test_case_ids:
              type: array
              items:
                type: string
              description: Test case IDs whose history hit the limit and may be truncated.
          required:
            - project_id
            - days
            - start_date
            - end_date
            - environment_id
            - limit_per_test_case
            - truncated_test_case_ids
          description: Echoed query parameters and truncation metadata.
      required:
        - data
        - meta
    TestCaseHistoryUnknownFieldsError:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
        unknown_fields:
          type: array
          items:
            type: string
          description: Field names that are not allowed.
        allowed_fields:
          type: array
          items:
            type: string
          description: Field names that are allowed.
      required:
        - error
        - unknown_fields
        - allowed_fields
    AnalyticsErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
      required:
        - error
    TestCaseHistoryEntry:
      type: object
      properties:
        timestamp:
          type: string
          description: ISO 8601 timestamp of the history entry.
        status:
          type: string
          description: 'Test status for this entry: `pass`, `fail`, `flaky`, or `skip`.'
        test_run_id:
          type: string
          description: ID of the test run this entry belongs to.
        environment_id:
          type: string
          description: ID of the environment the test ran in.
        executed_at:
          type: string
          description: ISO 8601 timestamp of when the test executed.
        duration_total:
          type: number
          description: Total duration in milliseconds.
        retries:
          type: number
          description: Number of retries for this test execution.
      required:
        - timestamp
        - status
        - test_run_id
        - environment_id
        - executed_at
        - duration_total
        - retries
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````