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

# List a test's runs

> Returns the individual runs recorded for a test, newest first, each with the branch, commit and CI job it came from.

`branches` takes shell-style globs, where `*` matches any run of characters and `?` exactly one (`main,release-?.*`); `pullRequestOnly=true` selects pull-request runs instead. They are alternatives, so sending both is a `400` rather than a silent intersection.

`startedAfter` and `startedBefore` bound when the run started, as your CI reported it.



## OpenAPI

````yaml /openapi-v2.json get /v2/tests/{testId}/test-runs
openapi: 3.1.0
info:
  title: Trunk API
  version: 2.0.0
  description: >-
    The Trunk public API. Every endpoint is scoped to a single organization and
    requires a credential.


    ## Authentication


    For automation, send an API key as `Authorization: Bearer <key>`. An
    organization admin creates one in the Trunk app under **Settings → Developer
    → API Keys**, and chooses the merge-queue permissions it holds. A key with
    no permissions can read merge queues but change nothing. Those permissions
    scope merge queue only: every key can use the Flaky Tests and Dynamic CI
    endpoints, including their writes, whatever permissions it holds.


    A short-lived first-party token in the `x-trunk-token` header is what the
    `trunk` CLI sends after `trunk auth login`.


    A GitHub Actions job can upload impacted targets with no Trunk secret: the
    `trunk-io/login` action exchanges the run's own GitHub credential (its OIDC
    token, or on a pull request from a fork its `GITHUB_TOKEN`) for a
    short-lived first-party token. That token is accepted only by `PUT
    /v2/impacted-targets`, for the run's own repository — and on a fork pull
    request, only for that pull request and its head sha.


    ## Errors


    Every 4xx and 5xx response is a `ErrorResponse`: `{ "error": { "code",
    "message" } }`. Switch on `code`, which is stable; `message` is prose and
    may change at any time.


    **An authorization denial on a read is reported as `404`, not `403`** —
    whether a resource exists must not leak across organizations, so a resource
    in another organization is indistinguishable from one that does not exist.
    `403 INSUFFICIENT_PERMISSIONS` means the credential is valid but is not
    permitted the action (or carries no organization).


    Every response carries an `X-Request-Id` header. Quote it in support
    requests.


    ## Rate limiting


    Requests are limited per organization (currently 100 requests/second).
    Exceeding it returns `429` with `RATE_LIMIT_EXCEEDED`; retry with backoff.
    Note that the limit is enforced at the edge, which does not yet wrap its
    `429` in the `ErrorResponse` envelope described above — treat any `429` as
    rate limiting regardless of body.


    ## Compatibility


    Within v2, Trunk may add: new endpoints, new **optional** response fields,
    new members to any enum (including new `code` values, new queue-entry
    states, and new providers), and new optional request parameters. **Clients
    must tolerate values and fields they do not recognize** rather than failing
    closed — a client that switches exhaustively over an enum will break when a
    member is added. Removals and semantic changes require a new major version.


    ## Provider support


    Merge queues, verification runs and checks are **GitHub-only** today;
    `Check.provider` has a single member for that reason. Impacted-target
    uploads additionally require a `github.com` repository named `owner/repo`.
    The `Provider` enum lists values the repository index can store, not
    surfaces that are fully supported.


    ## Not yet available


    A pull request's numeric **position** in its queue, and any wait estimate,
    are not exposed, and list responses are not ordered by queue position. `GET
    /v2/merge-queues/{id}/order` returns the order the engine will consider pull
    requests in, but an array index there is not a wait: use a pending entry's
    `directlyAhead` rather than counting. This API delivers no events of its own
    — poll it, or subscribe to [Merge Queue's
    webhooks](https://docs.trunk.io/merge-queue/webhooks). `Idempotency-Key` is
    not yet honored, so a mutation that times out must be reconciled by reading
    the resource back rather than blindly retried.
  contact:
    name: Trunk Support
    url: https://docs.trunk.io
servers:
  - url: https://api.trunk.io
    description: Production
security:
  - apiKey: []
  - trunkToken: []
tags:
  - name: mergeQueues
    x-group: Merge Queues
  - name: pullRequests
    x-group: Pull Requests
  - name: mergeQueueVerificationRuns
    x-group: Verification Runs
  - name: impactedTargets
    x-group: Impacted Targets
  - name: repositories
    x-group: Repositories
  - name: dynamicCi
    x-group: Dynamic CI
  - name: ciJobs
    x-group: CI Jobs
  - name: ciWorkflowRuns
    x-group: CI Workflow Runs
  - name: ciFailureClusters
    x-group: CI Failure Clusters
  - name: testCollections
    x-group: Test Collections
  - name: tests
    x-group: Tests
paths:
  /v2/tests/{testId}/test-runs:
    get:
      tags:
        - tests
      summary: List a test's runs
      description: >-
        Returns the individual runs recorded for a test, newest first, each with
        the branch, commit and CI job it came from.


        `branches` takes shell-style globs, where `*` matches any run of
        characters and `?` exactly one (`main,release-?.*`);
        `pullRequestOnly=true` selects pull-request runs instead. They are
        alternatives, so sending both is a `400` rather than a silent
        intersection.


        `startedAfter` and `startedBefore` bound when the run started, as your
        CI reported it.
      operationId: tests.listTestRuns
      parameters:
        - schema:
            type: string
            minLength: 1
            description: The test's globally unique id.
            example: bfeebcf4-0000-8000-8000-000000000001
          required: true
          description: The test's globally unique id.
          name: testId
          in: path
        - schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 25
            description: Page size, between 1 and 100.
            example: 25
          required: false
          description: Page size, between 1 and 100.
          name: limit
          in: query
        - schema:
            type: string
            description: >-
              Opaque cursor from a previous response's `nextCursor`. A cursor is
              bound to the operation and filter it was minted for.
            example: AQEKZm9vYmFy
          required: false
          description: >-
            Opaque cursor from a previous response's `nextCursor`. A cursor is
            bound to the operation and filter it was minted for.
          name: cursor
          in: query
        - schema:
            type: boolean
            default: false
            description: >-
              Set true to include `total` in the response. Costs an extra COUNT
              query, so it is off by default.
            example: false
          required: false
          description: >-
            Set true to include `total` in the response. Costs an extra COUNT
            query, so it is off by default.
          name: includeTotal
          in: query
        - schema:
            type: string
            enum:
              - success
              - failure
              - skipped
            description: Only runs that finished this way.
            example: failure
          required: false
          description: Only runs that finished this way.
          name: conclusion
          in: query
        - schema:
            type: string
            minLength: 1
            description: >-
              Comma-separated branch globs, e.g. `main,release-*`. `*` matches
              any run of characters, `?` exactly one. Cannot be combined with
              `pullRequestOnly`.
            example: main,release-*
          required: false
          description: >-
            Comma-separated branch globs, e.g. `main,release-*`. `*` matches any
            run of characters, `?` exactly one. Cannot be combined with
            `pullRequestOnly`.
          name: branches
          in: query
        - schema:
            type: boolean
            description: >-
              Only runs on pull-request branches. Cannot be combined with
              `branches`.
            example: true
          required: false
          description: >-
            Only runs on pull-request branches. Cannot be combined with
            `branches`.
          name: pullRequestOnly
          in: query
        - schema:
            type: string
            enum:
              - quarantined
              - notQuarantined
            description: Only runs recorded while the test was in this quarantine state.
            example: quarantined
          required: false
          description: Only runs recorded while the test was in this quarantine state.
          name: quarantineState
          in: query
        - schema:
            type: string
            format: date-time
            description: Only runs that started at or after this time.
            example: '2026-06-01T00:00:00.000Z'
          required: false
          description: Only runs that started at or after this time.
          name: startedAfter
          in: query
        - schema:
            type: string
            format: date-time
            description: Only runs that started strictly before this time.
            example: '2026-06-30T00:00:00.000Z'
          required: false
          description: Only runs that started strictly before this time.
          name: startedBefore
          in: query
      responses:
        '200':
          description: A page of test runs
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TestRunList'
        '400':
          description: '`VALIDATION_FAILED` | `INVALID_CURSOR`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: '`AUTHENTICATION_REQUIRED` | `INVALID_TOKEN`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: '`TEST_NOT_FOUND`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '429':
          description: '`RATE_LIMIT_EXCEEDED`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: '`INTERNAL_ERROR`'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    TestRunList:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/TestRun'
          maxItems: 100
        nextCursor:
          type:
            - string
            - 'null'
          description: >-
            Opaque cursor for the next page, or null on the last page. Pass it
            back verbatim as `cursor`; do not construct or inspect one.
          example: AQEKZm9vYmFy
        hasMore:
          type: boolean
          description: True when another page is available.
          example: true
        total:
          type: integer
          description: >-
            Total rows matching the filter. Present only when the request set
            `includeTotal=true`.
          example: 1247
      required:
        - data
        - nextCursor
        - hasMore
    ErrorResponse:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              $ref: '#/components/schemas/ErrorCode'
            message:
              type: string
              description: >-
                Human-readable description of what went wrong. Not stable — do
                not parse.
              example: No merge queue found with ID xK9mP2nQ
          required:
            - code
            - message
      required:
        - error
      description: >-
        The uniform error envelope. Every 4xx and 5xx response in this API has
        this shape.
    TestRun:
      type: object
      properties:
        id:
          type: string
          example: 1f9ddce9-b5f5-5676-8eef-770e11cf761f
        conclusion:
          $ref: '#/components/schemas/Conclusion'
        branch:
          type: string
          example: main
        isPullRequest:
          type: boolean
          description: True when the run happened on a pull-request branch.
          example: false
        sha:
          type: string
          example: 9c58bf40e5c1a2b3d4e5f60718293a4b5c6d7e8f
        quarantineState:
          $ref: '#/components/schemas/QuarantineState'
        statusAtRunTime:
          $ref: '#/components/schemas/TestStatus'
        startedAt:
          type: string
          format: date-time
          example: '2026-06-02T10:00:00.000Z'
        endedAt:
          type: string
          format: date-time
          example: '2026-06-02T10:00:03.500Z'
        pullRequest:
          anyOf:
            - $ref: '#/components/schemas/TestRunPullRequest'
            - type: 'null'
          description: Null for a run that was not on a pull request.
        buildUrl:
          type:
            - string
            - 'null'
          description: >-
            Link to the CI job run that reported this test run. Null for older
            runs: Trunk keeps uploads for less time than it keeps runs.
          example: https://github.com/acme/widgets/actions/runs/1
        workflow:
          type:
            - string
            - 'null'
          description: The CI workflow the run came from.
          example: CI
        jobName:
          type:
            - string
            - 'null'
          description: The name of the CI job within that workflow.
          example: unit
      required:
        - id
        - conclusion
        - branch
        - isPullRequest
        - sha
        - quarantineState
        - statusAtRunTime
        - startedAt
        - endedAt
        - pullRequest
        - buildUrl
        - workflow
        - jobName
    ErrorCode:
      type: string
      enum:
        - AUTHENTICATION_REQUIRED
        - INVALID_TOKEN
        - INSUFFICIENT_PERMISSIONS
        - INTERNAL_ERROR
        - VALIDATION_FAILED
        - NOT_FOUND
        - INVALID_CURSOR
        - MERGE_QUEUE_NOT_FOUND
        - PR_ALREADY_ENQUEUED
        - PR_NOT_ENQUEUEABLE
        - UPSTREAM_ERROR
        - VERIFICATION_RUN_NOT_FOUND
        - PR_NOT_FOUND
        - REPOSITORY_NOT_FOUND
        - IMPACTED_TARGETS_UNSUPPORTED
        - QUEUE_ALREADY_EXISTS
        - QUEUE_HAS_ACTIVE_ENTRIES
        - MODE_CHANGE_IN_PROGRESS
        - PR_NOT_IN_ACTIVE_STATE
        - MERGE_QUEUE_NOT_CREATABLE
        - PR_TESTS_NOT_RESTARTABLE
        - ALLOWED_BOT_SUBMITTERS_FROZEN
        - PROVIDER_URL_NOT_FOUND
        - CI_HOST_UNSUPPORTED
        - CI_SCOPE_NOT_FOUND
        - CI_JOB_NOT_FOUND
        - CI_FAILURE_CLUSTER_NOT_FOUND
        - TEST_COLLECTION_NOT_FOUND
        - TEST_NOT_FOUND
        - TICKETING_NOT_CONFIGURED
        - TICKETING_CREDENTIALS_INVALID
        - TICKET_NOT_FOUND
        - TICKET_LINK_CONFLICT
        - RATE_LIMIT_EXCEEDED
      description: >-
        Stable machine-readable error identifier. Switch on this, never on
        `message`. A shipped code's meaning never changes, but **new codes may
        be added within v2** — treat an unrecognized code as a generic failure
        of its HTTP status rather than failing closed.
      example: MERGE_QUEUE_NOT_FOUND
    Conclusion:
      type: string
      enum:
        - success
        - failure
        - skipped
      description: How a single test run finished.
      example: failure
    QuarantineState:
      type: string
      enum:
        - quarantined
        - notQuarantined
      description: >-
        Whether the test is currently quarantined, derived from its status, the
        collection's quarantine settings and any override.
      example: notQuarantined
    TestStatus:
      type: string
      enum:
        - healthy
        - flaky
        - broken
      description: >-
        A test's current composite status, reconciled across every active
        monitor.
      example: flaky
    TestRunPullRequest:
      type: object
      properties:
        number:
          type: integer
          example: 4901
        url:
          type: string
          description: The pull request's URL, when Trunk has it.
          example: https://github.com/acme/widgets/pull/4901
      required:
        - number
  securitySchemes:
    apiKey:
      type: http
      scheme: bearer
      description: >-
        An API key, sent as `Authorization: Bearer <key>`. An organization admin
        creates one in the Trunk app under **Settings → Developer → API Keys**
        and chooses the merge-queue permissions it holds; a key with none can
        read merge queues but change nothing. Those permissions scope merge
        queue only: every key can use the Flaky Tests and Dynamic CI endpoints,
        including their writes, whatever permissions it holds.
    trunkToken:
      type: apiKey
      in: header
      name: x-trunk-token
      description: >-
        A short-lived first-party token, sent in the `x-trunk-token` header. The
        `trunk` CLI sends one after `trunk auth login`, and the `trunk-io/login`
        action obtains one for a GitHub Actions run.


        **A token from a GitHub Actions run can only upload impacted targets**
        (`PUT /v2/impacted-targets`), for the repository the run belongs to;
        every other endpoint refuses it.

````