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

# List test runs

> Returns a paginated list of test runs for the scoped project, with optional filtering by id, branch, state, result, environment, and time window.

Test runs transition through these states:

| State | Description |
| - | - |
| `pending` | Run is queued behind other runs (concurrency limit reached) |
| `queued` | Run is queued and will start soon |
| `started` | Run is currently executing |
| `ended` | Run finished executing; inspect its result counts to determine whether tests passed |
| `error` | Run failed with an error |
| `cancelling` | Run is being cancelled |
| `cancelled` | Run was cancelled |

A failed run may carry one of these error codes:

| Error code | Description |
| - | - |
| `branch_missing` | Explicitly requested test branch does not exist |
| `provider_error` | Test-code provider failed during branch resolution |
| `merge_conflict` | Merge conflict detected when merging the test branch |
| `dispatch_failed` | Failed to dispatch the test run to workers |
| `report_not_generated` | Test report was not generated |
| `run_failed_with_error` | Test run failed with an error during execution |
| `worker_interrupted` | Test run worker was interrupted |
| `run_timed_out` | Test run exceeded the maximum duration |
| `merge_reports_failed` | Failed to merge sharded reports |
| `empty_selection` | The run's selection (tags or test case ids) matched no tests |
| `repo_checkout_failed` | The test repository could not be fetched from the git host |
| `unsupported_config` | The Playwright config uses globalSetup, globalTeardown, chained teardown projects, or a browser other than Chromium (Firefox, WebKit, Edge, Chrome beta/dev/canary) |
| `unsupported_playwright_version` | The repo's installed Playwright version is not supported, or could not be resolved |


## OpenAPI

````yaml /api-reference/openapi.generated.json get /api/test-runs
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/test-runs:
    get:
      tags:
        - Test Runs
      summary: List test runs
      description: >-
        Returns a paginated list of test runs for the scoped project, with
        optional filtering by id, branch, state, result, environment, and time
        window.
      operationId: listTestRuns
      parameters:
        - schema:
            type: integer
            minimum: 1
            description: Return only the test run with this exact ID.
          required: false
          description: Return only the test run with this exact ID.
          name: id
          in: query
        - schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
            description: Items per page (max 100). Defaults to 20.
          required: false
          description: Items per page (max 100). Defaults to 20.
          name: per_page
          in: query
        - schema:
            type: integer
            minimum: 1
            default: 1
            description: Page number (1-indexed). Defaults to 1.
          required: false
          description: Page number (1-indexed). Defaults to 1.
          name: page
          in: query
        - schema:
            type: string
            description: Filter to runs on this test repo branch.
          required: false
          description: Filter to runs on this test repo branch.
          name: branch
          in: query
        - schema:
            type: integer
            minimum: 1
            description: Restrict to runs created in the last N days.
          required: false
          description: Restrict to runs created in the last N days.
          name: interval_in_days
          in: query
        - schema:
            type: string
            format: date-time
            description: Restrict to runs created at or after this time.
          required: false
          description: Restrict to runs created at or after this time.
          name: created_after
          in: query
        - schema:
            type: string
            format: date-time
            description: Restrict to runs created before this time.
          required: false
          description: Restrict to runs created before this time.
          name: created_before
          in: query
        - schema:
            type: string
            description: >-
              Filter by run state (e.g. `queued`, `ended`); comma-separated for
              several.
          required: false
          description: >-
            Filter by run state (e.g. `queued`, `ended`); comma-separated for
            several.
          name: state
          in: query
        - schema:
            type: string
            enum:
              - passed
              - failed
            description: Filter by overall run result.
          required: false
          description: Filter by overall run result.
          name: result
          in: query
        - schema:
            type: integer
            minimum: 1
            description: >-
              Filter to one environment. Combined with environment_ids when both
              are provided.
          required: false
          description: >-
            Filter to one environment. Combined with environment_ids when both
            are provided.
          name: environment_id
          in: query
        - schema:
            type: string
            description: >-
              Comma-separated environment IDs to filter by. Combined with
              environment_id when both are provided.
          required: false
          description: >-
            Comma-separated environment IDs to filter by. Combined with
            environment_id when both are provided.
          name: environment_ids
          in: query
        - schema:
            type: string
            minLength: 1
            maxLength: 512
            description: >-
              Filter to runs created in this concurrency group (exact match on
              the run's `concurrency.group`).
          required: false
          description: >-
            Filter to runs created in this concurrency group (exact match on the
            run's `concurrency.group`).
          name: concurrency_group
          in: query
      responses:
        '200':
          description: Paginated list of test runs.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestRunsListResponse'
        '400':
          description: >-
            Invalid request, or the project could not be resolved from the
            request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Project not found or not accessible.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    TestRunsListResponse:
      type: object
      properties:
        data:
          type: object
          properties:
            project:
              type: object
              properties:
                id:
                  type: number
                  description: Project ID.
                name:
                  type: string
                  description: Project name.
                slug:
                  type: string
                  description: Project slug.
                repo_name:
                  type: string
                  description: Repository name for the project.
              required:
                - id
                - name
                - slug
                - repo_name
              description: The project the runs belong to.
            test_runs:
              type: object
              properties:
                items:
                  type: array
                  items:
                    $ref: '#/components/schemas/TestRunItem'
                  description: The page of test runs.
              required:
                - items
              description: Paginated test runs.
          required:
            - project
            - test_runs
        pagination:
          $ref: '#/components/schemas/Pagination'
      required:
        - data
        - pagination
    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
    TestRunItem:
      type: object
      properties:
        id:
          type: number
          description: Unique identifier.
        state:
          type: string
          nullable: true
          enum:
            - pending
            - queued
            - cancelling
            - cancelled
            - ended
            - started
            - finalizing
            - error
            - interrupted
          description: >-
            Current state of the test run. `pending`: waiting for an in-progress
            run in its concurrency group to finish. `queued`: dispatched to a
            runner, not started yet. `started`: tests are running. `finalizing`:
            every test has finished and results are being merged. `cancelling`:
            cancel requested, becomes `cancelled` once the run stops. `ended`:
            every shard completed; the counts say whether tests passed. `error`
            and `interrupted`: the run stopped without completing.
        total_count:
          type: number
          nullable: true
          description: Total number of test cases.
        success_count:
          type: number
          nullable: true
          description: Number of passed tests.
        failed_count:
          type: number
          nullable: true
          description: Number of failed tests.
        skipped_count:
          type: number
          nullable: true
          description: Number of skipped tests.
        flaky_count:
          type: number
          nullable: true
          description: Number of flaky tests.
        duration:
          type: number
          nullable: true
          description: Duration in milliseconds.
        test_run_branch:
          type: string
          description: Git branch being tested.
        environment_slug:
          type: string
          nullable: true
          description: Environment identifier.
        environment_name:
          type: string
          nullable: true
          description: Environment display name.
        build_url:
          type: string
          nullable: true
          description: >-
            URL of the deployment tested, i.e. the run's resolved `BUILD_URL`
            environment variable.
        build_branch:
          type: string
          nullable: true
          description: Git branch of the build.
        commit:
          type: string
          nullable: true
          description: Commit SHA.
        created_at:
          type: string
          nullable: true
          description: ISO 8601 timestamp.
        concurrency:
          type: object
          nullable: true
          properties:
            group:
              type: string
              description: >-
                Concurrency group the run was scoped to. Runs in the same group
                are limited to one in progress at a time.
            on_conflict:
              type: string
              enum:
                - cancel
                - wait
              description: >-
                What this run did when the group already had an active run:
                `cancel` cancelled it, `wait` held this run in `pending` until
                the group was free.
          required:
            - group
            - on_conflict
          description: >-
            Concurrency group and policy the run was created with, or null when
            no limit applied.
      required:
        - id
        - state
        - total_count
        - success_count
        - failed_count
        - skipped_count
        - flaky_count
        - duration
        - test_run_branch
        - environment_slug
        - environment_name
        - build_url
        - build_branch
        - commit
        - created_at
        - concurrency
    Pagination:
      type: object
      properties:
        page:
          type: integer
          description: Current page (1-indexed).
        per_page:
          type: integer
          description: Items per page.
        total:
          type: integer
          description: Total number of items.
        total_pages:
          type: integer
          description: Total number of pages.
      required:
        - page
        - per_page
        - total
        - total_pages
      description: Pagination metadata.
  securitySchemes:
    Bearer:
      type: http
      scheme: bearer

````

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