---
title: "Update flaky test states"
method: PATCH
path: "/api/v2/test/flaky-test-management/tests"
tags: ["Test Optimization"]
---

# Update flaky test states

`PATCH /api/v2/test/flaky-test-management/tests`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/test/flaky-test-management/tests`
- Auth: one of:
  - API key in header `DD-API-KEY` and API key in header `DD-APPLICATION-KEY`
  - OAuth 2
    - Authorization code: `/oauth2/v1/authorize`
    - Token URL: `/oauth2/v1/token` scopes: `test_optimization_write`

Update the state of multiple flaky tests in Flaky Test Management.

## Request body

- UpdateFlakyTestsRequest: Request to update the state of multiple flaky tests.
  - `data` UpdateFlakyTestsRequestData, required: The JSON:API data for updating flaky test states.
    - `attributes` UpdateFlakyTestsRequestAttributes, required: Attributes for updating flaky test states.
      - `tests` UpdateFlakyTestsRequestTest[], required: List of flaky tests to update.
        - `id` string, required: The ID of the flaky test. This is the same ID returned by the Search flaky tests endpoint and is the value of the `@test.fingerprint_fqn` facet on test events. You can find it by searching on `@test.fingerprint_fqn` in the Test Optimization Explorer, or by filtering the Search flaky tests endpoint with the `fingerprint_fqn` key.
        - `new_state` 'active' | 'quarantined' | 'disabled' | 'fixed', required: The new state to set for the flaky test.
    - `type` 'update_flaky_test_state_request', required: The definition of `UpdateFlakyTestsRequestDataType` object.

## Response `200`

OK

- UpdateFlakyTestsResponse: Response object for updating flaky test states.
  - `data` UpdateFlakyTestsResponseData: Summary of the update operations. Tells whether a test succeeded or failed to be updated.
    - `attributes` UpdateFlakyTestsResponseAttributes: Attributes for the update flaky test state response.
      - `has_errors` boolean, required: `True` if any errors occurred during the update operations. `False` if all tests succeeded to be updated.
      - `results` UpdateFlakyTestsResponseResult[], required: Results of the update operation for each test.
        - `error` string: Error message if the update failed.
        - `id` string, required: The ID of the flaky test from the request. This is the value of the `@test.fingerprint_fqn` facet on test events, the same ID accepted by the update request and returned by the Search flaky tests endpoint.
        - `success` boolean, required: `True` if the update was successful, `False` if there were any errors.
    - `id` string: The ID of the response.
    - `type` 'update_flaky_test_state_response': The definition of `UpdateFlakyTestsResponseDataType` object.

## Other responses

- `400`: Bad Request
- `403`: Not Authorized
- `429`: Too many requests

---

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