---
title: "Get Flaky Tests Management policies"
method: POST
path: "/api/v2/ci/test-optimization/settings/policies"
tags: ["Test Optimization"]
---

# Get Flaky Tests Management policies

`POST /api/v2/ci/test-optimization/settings/policies`

## Request

- Base URL: `https://api.datadoghq.com`
- URL: `https://api.datadoghq.com/api/v2/ci/test-optimization/settings/policies`
- 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_read`

Retrieve Flaky Tests Management repository-level policies for the given repository.

## Request body

- TestOptimizationFlakyTestsManagementPoliciesGetRequest: Request object for getting Flaky Tests Management policies.
  - `data` TestOptimizationFlakyTestsManagementPoliciesGetRequestData, required: Data object for get Flaky Tests Management policies request.
    - `attributes` TestOptimizationFlakyTestsManagementPoliciesGetRequestAttributes, required: Attributes for requesting Flaky Tests Management policies.
      - `repository_id` string, required: The repository identifier.
    - `type` 'test_optimization_get_flaky_tests_management_policies_request', required: JSON:API type for get Flaky Tests Management policies request. The value must always be `test_optimization_get_flaky_tests_management_policies_request`.

## Response `200`

OK

- TestOptimizationFlakyTestsManagementPoliciesResponse: Response object containing Flaky Tests Management policies for a repository.
  - `data` TestOptimizationFlakyTestsManagementPoliciesData: Data object for Flaky Tests Management policies response.
    - `attributes` TestOptimizationFlakyTestsManagementPoliciesAttributes: Attributes of the Flaky Tests Management policies for a repository.
      - `attempt_to_fix` TestOptimizationFlakyTestsManagementPoliciesAttemptToFix: Configuration for the attempt-to-fix Flaky Tests Management policy.
        - `retries` integer: Number of retries when attempting to fix a flaky test. Must be greater than 0.
      - `disabled` TestOptimizationFlakyTestsManagementPoliciesDisabled: Configuration for the disabled Flaky Tests Management policy.
        - `auto_disable_rule` TestOptimizationFlakyTestsManagementPoliciesAutoDisableRule: Automatic disable triggering rule based on a time window and test status.
          - `enabled` boolean: Whether this auto-disable rule is enabled.
          - `status` 'active' | 'quarantined': Test status that the disable policy applies to. Must be either `active` or `quarantined`.
          - `window_seconds` integer: Time window in seconds over which flakiness is evaluated. Must be greater than 0.
        - `branch_rule` TestOptimizationFlakyTestsManagementPoliciesBranchRule: Branch filtering rule for a Flaky Tests Management policy.
          - `branches` string[]: List of branches to which the policy applies.
          - `enabled` boolean: Whether this branch rule is enabled.
          - `excluded_branches` string[]: List of branches excluded from the policy.
          - `excluded_test_services` string[]: List of test services excluded from the policy.
        - `enabled` boolean: Whether the disabled policy is enabled.
        - `failure_rate_rule` TestOptimizationFlakyTestsManagementPoliciesDisabledFailureRateRule: Failure-rate-based rule for the disabled policy.
          - `branches` string[]: List of branches to which this rule applies.
          - `enabled` boolean: Whether this failure rate rule is enabled.
          - `min_runs` integer: Minimum number of runs required before the rule is evaluated. Must be greater than or equal to 0.
          - `status` 'active' | 'quarantined': Test status that the disable policy applies to. Must be either `active` or `quarantined`.
          - `threshold` number, double: Failure rate threshold (0.0–1.0) above which the rule triggers.
      - `quarantined` TestOptimizationFlakyTestsManagementPoliciesQuarantined: Configuration for the quarantined Flaky Tests Management policy.
        - `auto_quarantine_rule` TestOptimizationFlakyTestsManagementPoliciesAutoQuarantineRule: Automatic quarantine triggering rule based on a time window.
          - `enabled` boolean: Whether this auto-quarantine rule is enabled.
          - `window_seconds` integer: Time window in seconds over which flakiness is evaluated. Must be greater than 0.
        - `branch_rule` TestOptimizationFlakyTestsManagementPoliciesBranchRule: Branch filtering rule for a Flaky Tests Management policy.
          - `branches` string[]: List of branches to which the policy applies.
          - `enabled` boolean: Whether this branch rule is enabled.
          - `excluded_branches` string[]: List of branches excluded from the policy.
          - `excluded_test_services` string[]: List of test services excluded from the policy.
        - `enabled` boolean: Whether the quarantined policy is enabled.
        - `failure_rate_rule` TestOptimizationFlakyTestsManagementPoliciesQuarantinedFailureRateRule: Failure-rate-based rule for the quarantined policy.
          - `branches` string[]: List of branches to which this rule applies.
          - `enabled` boolean: Whether this failure rate rule is enabled.
          - `min_runs` integer: Minimum number of runs required before the rule is evaluated. Must be greater than or equal to 0.
          - `threshold` number, double: Failure rate threshold (0.0–1.0) above which the rule triggers.
      - `repository_id` string: The repository identifier.
    - `id` string: The repository identifier used as the resource ID.
    - `type` 'test_optimization_flaky_tests_management_policies': JSON:API type for Flaky Tests Management policies response. The value must always be `test_optimization_flaky_tests_management_policies`.

## Other responses

- `400`: Bad Request
- `403`: Not Authorized
- `404`: Not Found
- `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)
