---
title: "Get what Fail First did on a repository"
method: GET
path: "/ci/{owner}/repositories/{repository}/test-selection/failure-first"
tags: ["test_insights"]
---

# Get what Fail First did on a repository

`GET /ci/{owner}/repositories/{repository}/test-selection/failure-first`

## Request

- Base URL: `https://api.mergify.com/v1`
- URL: `https://api.mergify.com/v1/ci/{owner}/repositories/{repository}/test-selection/failure-first`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer
- TypeScript: <https://skmtc.dev/mergify/apis/mergify-api/docs/ci/:owner/repositories/:repository/test-selection/failure-first/get.ts> (a function with typed inputs; its response is checked against the schema)

What Fail First did on the repository over the last 30 days. When a batch fails, the merge queue retests smaller splits of it, called bisection steps, to find the pull request that broke it. In each step, Fail First asks a job to run the tests that already failed before the others, and the job stops early when one of them fails again. The response counts the steps where a job was asked and those where it stopped early, and estimates the test time saved.

## Path parameters

- `repository` string, required: The name of the repository
- `owner` string, required: The owner of the repository

## Response `200`

Successful Response

- FailureFirstStatus: What Fail First did on a repository since `since`. A bisection step is one of the smaller splits of a failed batch that the merge queue retests to find the pull request that broke it.
  - `state` 'not_served' | 'active', required: `active`: since `since`, Mergify asked at least one job of a bisection step to run its failed tests first. It does not say the job did: a job on a Mergify plugin release that does not apply Fail First keeps its usual order. `not_served`: no job was asked. Possible reasons: the merge queue split no failed batch, the jobs of its steps had no failed tests known by name, no job uses the Mergify plugin for its test framework, or Fail First is not enabled for the organization. See https://docs.mergify.com/test-engine/fail-first for what a job needs, and contact Mergify Support if your jobs have it and a failed batch still gets `not_served`.
  - `since` string, date-time, required: The start of the period every figure covers.
  - `steps` integer, required: Bisection steps in which at least one job was asked to run first the tests it had already failed, in the failed batch or an earlier step. A job on a Mergify plugin release that does not apply Fail First counts too, though it runs its tests in their usual order.
  - `stopped_early_steps` integer, required: Of `steps`, those in which such a job stopped before running the rest of its tests. Any early stop counts, including one caused by the job's own failure limit (`-x`, `--bail`).
  - `estimated_test_time_saved_ms` integer, required: An estimate, in milliseconds, of the test time the jobs that stopped early did not spend. For each of them: the median test time of the same job (same pipeline, name and matrix leg) over the period's bisection steps where it ran all its tests, minus its own test time, and never below zero. A stop caused by the job's own failure limit counts too, so this can include time that limit would have saved anyway. It adds up test durations, so with parallel workers the time gained on the clock is smaller. A job with no such run to compare with adds nothing here and counts in `unmeasured_stopped_early_jobs` instead.
  - `unmeasured_stopped_early_jobs` integer, required: Early stops with no estimated saving, because the same job (same pipeline, name and matrix leg) never ran all its tests in a bisection step of the period. Each leg that stopped early counts once per step.

## Other responses

- `403`: Forbidden
- `404`: Not found
- `409`: Conflict
- `422`: Unprocessable entity

## Changes

- **2026-11-05** `be24f4fc4951`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/mergify/apis/mergify-api/changes/ci/:owner/repositories/:repository/test-selection/failure-first/get.md)

---

[API](https://skmtc.dev/mergify/apis/mergify-api.md) - [All operations](https://skmtc.dev/mergify/apis/mergify-api/llms.txt) - [OpenAPI document](https://skmtc.dev/mergify/apis/mergify-api/revisions/f13d731c7b53?raw)
