> ## 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 analytics

> Returns aggregated test-case metrics for the scoped project (without per-test history).



## OpenAPI

````yaml /api-reference/openapi.generated.json get /api/v2/analytics/test-cases
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-cases:
    get:
      tags:
        - Analytics
      summary: Test-case analytics
      description: >-
        Returns aggregated test-case metrics for the scoped project (without
        per-test history).
      operationId: listTestCasesAnalyticsV2
      parameters:
        - schema:
            type: integer
            minimum: 1
            maximum: 90
            description: >-
              Number of days to include (1-90). Ignored when both `start_date`
              and `end_date` are provided.
          required: false
          description: >-
            Number of days to include (1-90). Ignored when both `start_date` and
            `end_date` are provided.
          name: days
          in: query
        - schema:
            type: string
            description: Start of a custom date range (ISO 8601).
          required: false
          description: Start of a custom date range (ISO 8601).
          name: start_date
          in: query
        - schema:
            type: string
            description: End of a custom date range (ISO 8601).
          required: false
          description: End of a custom date range (ISO 8601).
          name: end_date
          in: query
        - schema:
            type: string
            description: Filter to a single environment by ID.
          required: false
          description: Filter to a single environment by ID.
          name: environment_id
          in: query
        - schema:
            type: string
            description: Free-text search over test name and file path.
          required: false
          description: Free-text search over test name and file path.
          name: search
          in: query
        - schema:
            type: string
            description: Comma-separated list of tags to filter by.
          required: false
          description: Comma-separated list of tags to filter by.
          name: tags
          in: query
        - schema:
            type: string
            enum:
              - fail_rate
              - flaky_rate
              - last_run
            description: >-
              Field to order results by. One of `fail_rate`, `flaky_rate`,
              `last_run`. Defaults to `fail_rate`.
          required: false
          description: >-
            Field to order results by. One of `fail_rate`, `flaky_rate`,
            `last_run`. Defaults to `fail_rate`.
          name: order_by
          in: query
        - schema:
            type: string
            enum:
              - asc
              - desc
            description: Sort direction, `asc` or `desc`. Defaults to `desc`.
          required: false
          description: Sort direction, `asc` or `desc`. Defaults to `desc`.
          name: order
          in: query
        - schema:
            type: integer
            minimum: 1
            maximum: 500
            description: Maximum number of test cases to return (1-500).
          required: false
          description: Maximum number of test cases to return (1-500).
          name: limit
          in: query
        - schema:
            type: integer
            minimum: 1
            maximum: 100
            description: Maximum number of history entries to return per test case (1-100).
          required: false
          description: Maximum number of history entries to return per test case (1-100).
          name: limit_history
          in: query
        - schema:
            type: string
            description: Filter to a single test case by ID.
          required: false
          description: Filter to a single test case by ID.
          name: test_case_id
          in: query
        - schema:
            type: string
            enum:
              - 'true'
              - 'false'
            description: >-
              When `false`, include inactive test cases. Defaults to
              active-only.
          required: false
          description: When `false`, include inactive test cases. Defaults to active-only.
          name: is_active
          in: query
      responses:
        '200':
          description: Test cases with metrics.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyticsTestCasesV2Response'
        '400':
          description: Invalid request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Analytics backend error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AnalyticsErrorResponse'
components:
  schemas:
    AnalyticsTestCasesV2Response:
      type: object
      properties:
        data:
          type: object
          properties:
            test_cases:
              type: array
              items:
                $ref: '#/components/schemas/AnalyticsTestCaseV2'
            summary:
              $ref: '#/components/schemas/AnalyticsTestCasesSummary'
          required:
            - test_cases
            - summary
          description: Response payload.
      required:
        - data
    ErrorResponse:
      type: object
      properties:
        data:
          nullable: true
          description: Always null for error responses.
        error:
          type: object
          properties:
            message:
              type: string
              description: Human-readable error message.
          required:
            - message
          description: Error details.
      required:
        - data
        - error
    AnalyticsErrorResponse:
      type: object
      properties:
        error:
          type: string
          description: Human-readable error message.
      required:
        - error
    AnalyticsTestCaseV2:
      type: object
      properties:
        test_case_id:
          type: string
          description: Unique identifier for the test case.
        test_name:
          type: string
          description: Name of the test case.
        file_path:
          type: string
          description: File path of the test case.
        project_name:
          type: string
          description: Name of the project the test belongs to.
        tags:
          type: array
          items:
            type: string
          description: Array of tags associated with the test case.
        last_run_at:
          type: string
          description: ISO 8601 timestamp of the last time this test was run.
        metrics:
          type: object
          properties:
            total_runs:
              type: number
              description: Total number of runs for this test case.
            pass_count:
              type: number
              description: Number of times the test passed.
            fail_count:
              type: number
              description: Number of times the test failed.
            flaky_count:
              type: number
              description: Number of times the test was flaky.
            pass_rate:
              type: number
              description: Pass rate as a percentage (0-100).
            fail_rate:
              type: number
              description: Fail rate as a percentage (0-100).
            flaky_rate:
              type: number
              description: Flaky rate as a percentage (0-100).
          required:
            - total_runs
            - pass_count
            - fail_count
            - flaky_count
            - pass_rate
            - fail_rate
            - flaky_rate
          description: Aggregated metrics for this test case.
      required:
        - test_case_id
        - test_name
        - file_path
        - project_name
        - tags
        - last_run_at
        - metrics
    AnalyticsTestCasesSummary:
      type: object
      properties:
        total_test_cases:
          type: number
          description: Total number of test cases.
        test_cases_with_history:
          type: number
          description: Number of test cases that have execution history.
      required:
        - total_test_cases
        - test_cases_with_history
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````

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