> ## Documentation Index
> Fetch the complete documentation index at: https://empirical.run/docs/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: Test Runs
    description: Trigger, list, and inspect end-to-end test runs.
  - name: Test Cases
    description: >-
      Browse the Playwright test cases synced from a project's repository and
      manage their tags.
  - 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: KV
    description: >-
      Project-scoped key-value store shared by test runs, shards and agent
      sessions. Every entry expires; conditional writes make it safe for locks.
  - name: Analytics
    description: Aggregated test-run, test-count and test-case analytics for a project.
  - name: Allowed recipients
    description: >-
      Domains and addresses a project's inboxes may send email to, besides
      @empiricalrun.email addresses and people who emailed the inbox. Each one
      is verified in one of two ways. **Email from it**: send an email from the
      domain (any mailbox on it) or from the exact address to the verification
      address, with the verification code in the subject. It must pass DMARC.
      **Emailed code**, for addresses that can't send (e.g.
      `support@acme.zendesk.com`): we email the address a 6-digit code, and you
      enter it from wherever that address delivers. A domain covers exactly that
      domain, not its subdomains; add a subdomain such as `inbound.acme.com` on
      its own, and an email from `@acme.com` verifies it. Public mail providers
      (gmail.com, outlook.com and similar) can't be added as domains; add the
      exact address instead. An address also covers its plus-variants. Domains
      reserved for examples and tests (example.com, example.net, example.org,
      and anything under .test, .example, .invalid or .localhost) can't receive
      email, so codes are never emailed to them.
  - name: Badges
    description: Public README status badge images (SVG) for project environments.
  - name: Files
    description: >-
      Upload files of any type and get a link to use in tasks, sessions and
      messages. Agents should use the `upload_file` tool, which returns a
      project-wide `file@<id>` handle (`<id>` is the file `id` below).
  - name: Inboxes
    description: >-
      Test email addresses on @empiricalrun.email that a project claims. Only
      the claiming project can read an inbox, and only mail received after the
      claim. Typical flow: claim an address, sign up or log in to your app with
      it, then list the inbox's messages. Inboxes can also send mail, e.g. to
      test an app that processes inbound email: to @empiricalrun.email
      addresses, to anyone who emailed the inbox, and to the project's allowed
      recipients. Replies land back in the sending inbox.
  - name: Infra
    description: >-
      Infrastructure details customers configure against, such as static egress
      IPs.
  - name: Reporter Configuration
    description: Reporters a project can use in environment and run reporter configs.
  - name: Webhook Captures
    description: >-
      Throwaway URLs that record every request sent to them, for testing
      webhooks your app sends.
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).
        include_last_pass_per_env:
          type: boolean
          description: >-
            When true, also return the most recent passing run per environment
            for each requested test case.
      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).
            last_pass_by_test_case_id:
              type: object
              additionalProperties:
                type: array
                items:
                  type: object
                  properties:
                    environment_id:
                      type: string
                    test_run_id:
                      type: string
                    executed_at:
                      type: number
                  required:
                    - environment_id
                    - test_run_id
                    - executed_at
              description: >-
                Map of `test_case_id` to its most recent passing run in each
                environment. Present when requested.
          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

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.