---
title: "Count test states"
method: GET
path: "/ci/{owner}/repositories/{repository}/test-states/count"
tags: ["test_insights"]
---

# Count test states

`GET /ci/{owner}/repositories/{repository}/test-states/count`

## Request

- Base URL: `https://api.mergify.com/v1`
- URL: `https://api.mergify.com/v1/ci/{owner}/repositories/{repository}/test-states/count`
- Auth: one of:
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer
  - HTTP bearer

Count the test states the list returns for the same filters, across every page.

Application key permission: `quarantines: read`.

## Path parameters

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

## Query parameters

- `state` TestStateValue[], nullable: The states to filter on.
- `state_exclude` TestStateValue[], nullable: The states to exclude.
- `test_id` string[], nullable: The test identifier to filter on
- `source` QuarantineSource[], nullable: The sources to filter on.
- `branch_name` string[], nullable: The branch name to filter on. Test states applying to every branch always match.
- `branch_name_exclude` string[], nullable: The branch name to exclude. Test states applying to every branch are kept.
- `pipeline_name` string[], nullable: The pipeline name to filter on. Test states applying to every pipeline always match.
- `pipeline_name_exclude` string[], nullable: The pipeline name to exclude. Test states applying to every pipeline are kept.
- `job_name` string[], nullable: The job name to filter on. Test states applying to every job always match.
- `job_name_exclude` string[], nullable: The job name to exclude. Test states applying to every job are kept.
- `test_name` string[], nullable: The test name to filter on
- `test_name_exclude` string[], nullable: The test name to exclude
- `health_status` HealthStatus[], nullable: The health status to filter on. Tests with no recent runs are left out.
- `health_status_exclude` HealthStatus[], nullable: The health status to exclude. Tests with no recent runs are kept.

## Headers

- `Mergify-Version` string, nullable: The API version the request is written against, a date (`YYYY-MM-DD`). Without it, the request is served 2026-11-16. A version this server does not serve is refused with a 400, the error code `API_VERSION_UNKNOWN` and the versions it serves in `served_versions`.

## Response `200`

Successful Response

- TestStatesCount
  - `count` integer, required: Number of test states matching the filters.

## Other responses

- `400`: `API_VERSION_UNKNOWN`: The `Mergify-Version` header names an API version this server does not serve. `served_versions` lists the versions it serves.
- `402`: `SUBSCRIPTION_FEATURE_REQUIRED`: The organization's subscription does not include the feature `feature` names; upgrading the subscription enables it. Here, `ci_insights_quarantine`: CI Insights Quarantine.
- `403`: Forbidden
- `404`: Not found
- `409`: Conflict
- `422`: Unprocessable entity

## Changes

- **2026-11-18** `fcb8448506b6`: 2 warning
  - added the new `GITHUB_TWO_FACTOR_AUTHENTICATION_NONCOMPLIANT` enum value to the `error_code` response property for the response status `400`
  - added the new `GITHUB_TWO_FACTOR_AUTHENTICATION_NONCOMPLIANT` enum value to the `error_code` response property for the response status `402`
- **2026-11-18** `1848125f504d`: 2 warning
  - added the new `STATISTICS_SCOPE_PERIOD_TOO_LARGE` enum value to the `error_code` response property for the response status `400`
  - added the new `STATISTICS_SCOPE_PERIOD_TOO_LARGE` enum value to the `error_code` response property for the response status `402`
- **2026-11-17** `d469719637b1`: 1 warning, 2 info
  - added the new `API_VERSION_UNKNOWN` enum value to the `error_code` response property for the response status `402`
  - added the new optional `header` request parameter `Mergify-Version`
  - added the non-success response with the status `400`
- **2026-11-17** `9c054789482b`: 3 warning
  - added the new `FLAKY_DETECTION_NOT_CONFIGURED` enum value to the `error_code` response property for the response status `402`
  - added the new `KNOWN_TESTS_BEING_COMPUTED` enum value to the `error_code` response property for the response status `402`
  - added the new `KNOWN_TESTS_NOT_SERVED` enum value to the `error_code` response property for the response status `402`
- …earlier changes not shown

[Operation history](https://skmtc.dev/mergify/apis/mergify-api/changes/ci/:owner/repositories/:repository/test-states/count/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/6771ce070211?raw)
