---
title: Update Test Optimization service settings
description: Partially update Test Optimization settings for a specific service identified by repository, service name, and environment.
breadcrumbs: Documentación > API > Update Test Optimization service settings
---

> For the complete documentation index, see [llms.txt](https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/llms.txt).

# Update Test Optimization service settings

## v2 (latest)

| Datadog site      | API endpoint                                                                     |
| ----------------- | -------------------------------------------------------------------------------- |
| app.datadoghq.com | PATCH https://api.datadoghq.com/api/v2/ci/test-optimization/settings/service     |
| us3.datadoghq.com | PATCH https://api.us3.datadoghq.com/api/v2/ci/test-optimization/settings/service |
| us5.datadoghq.com | PATCH https://api.us5.datadoghq.com/api/v2/ci/test-optimization/settings/service |
| app.datadoghq.eu  | PATCH https://api.datadoghq.eu/api/v2/ci/test-optimization/settings/service      |
| ap1.datadoghq.com | PATCH https://api.ap1.datadoghq.com/api/v2/ci/test-optimization/settings/service |
| ap2.datadoghq.com | PATCH https://api.ap2.datadoghq.com/api/v2/ci/test-optimization/settings/service |
| uk1.datadoghq.com | PATCH https://api.uk1.datadoghq.com/api/v2/ci/test-optimization/settings/service |
| app.ddog-gov.com  | PATCH https://api.ddog-gov.com/api/v2/ci/test-optimization/settings/service      |
| us2.ddog-gov.com  | PATCH https://api.us2.ddog-gov.com/api/v2/ci/test-optimization/settings/service  |

### Overview

Partially update Test Optimization settings for a specific service identified by repository, service name, and environment.
Only provided fields are updated; setting a field to `null` is a no-op.
To reset a setting to inherit from the repository level, use the corresponding `<setting>_inherit` field.
The `pr_comments_enabled` field is ignored as it cannot be overridden at the service level.

This endpoint requires the `test_optimization_settings_write` permission.

OAuth apps require the `test_optimization_settings_write` authorization [scope](https://dnd37xeb23o8n.cloudfront.net/jen.gilbert/astro-base/es/api/latest/scopes.md#test-optimization) to access this endpoint.

### Request

#### Body Data (required)

{% tabs %}
{% tab label="Model" %}
| Parent field | Field                                 | Type    | Description                                                                                                                                                                                                                                                                             |
| ------------ | ------------------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]                     | object  | Data object for update service settings request.                                                                                                                                                                                                                                        |
| data         | attributes [*required*]               | object  | Attributes for updating Test Optimization service settings. All non-required fields are optional; only provided fields will be updated. Setting a field to `null` is a no-op. To reset a setting to inherit from the repository level, use the corresponding `<setting>_inherit` field. |
| attributes   | auto_test_retries_enabled             | boolean | Whether Auto Test Retries are enabled for this service. Setting to `null` is a no-op; use `auto_test_retries_enabled_inherit` to reset to repository-level inheritance.                                                                                                                 |
| attributes   | auto_test_retries_enabled_inherit     | boolean | When `true`, resets the Auto Test Retries setting to inherit from the repository level.                                                                                                                                                                                                 |
| attributes   | code_coverage_enabled                 | boolean | Whether Code Coverage is enabled for this service. Setting to `null` is a no-op; use `code_coverage_enabled_inherit` to reset to repository-level inheritance.                                                                                                                          |
| attributes   | code_coverage_enabled_inherit         | boolean | When `true`, resets the Code Coverage setting to inherit from the repository level.                                                                                                                                                                                                     |
| attributes   | early_flake_detection_enabled         | boolean | Whether Early Flake Detection is enabled for this service. Setting to `null` is a no-op; use `early_flake_detection_enabled_inherit` to reset to repository-level inheritance.                                                                                                          |
| attributes   | early_flake_detection_enabled_inherit | boolean | When `true`, resets the Early Flake Detection setting to inherit from the repository level.                                                                                                                                                                                             |
| attributes   | env                                   | string  | The environment name. If omitted, defaults to `none`.                                                                                                                                                                                                                                   |
| attributes   | failed_test_replay_enabled            | boolean | Whether Failed Test Replay is enabled for this service. Setting to `null` is a no-op; use `failed_test_replay_enabled_inherit` to reset to repository-level inheritance.                                                                                                                |
| attributes   | failed_test_replay_enabled_inherit    | boolean | When `true`, resets the Failed Test Replay setting to inherit from the repository level.                                                                                                                                                                                                |
| attributes   | pr_comments_enabled                   | boolean | This field is ignored. PR Comments cannot be overridden at the service level.                                                                                                                                                                                                           |
| attributes   | repository_id [*required*]            | string  | The repository identifier.                                                                                                                                                                                                                                                              |
| attributes   | service_name [*required*]             | string  | The service name.                                                                                                                                                                                                                                                                       |
| attributes   | test_impact_analysis_enabled          | boolean | Whether Test Impact Analysis is enabled for this service. Setting to `null` is a no-op; use `test_impact_analysis_enabled_inherit` to reset to repository-level inheritance.                                                                                                            |
| attributes   | test_impact_analysis_enabled_inherit  | boolean | When `true`, resets the Test Impact Analysis setting to inherit from the repository level.                                                                                                                                                                                              |
| data         | type [*required*]                     | enum    | JSON:API type for update service settings request. The value must always be `test_optimization_update_service_settings_request`. Allowed enum values: `test_optimization_update_service_settings_request`.                                                                              |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "auto_test_retries_enabled": false,
      "auto_test_retries_enabled_inherit": false,
      "code_coverage_enabled": false,
      "code_coverage_enabled_inherit": false,
      "early_flake_detection_enabled": false,
      "early_flake_detection_enabled_inherit": false,
      "env": "prod",
      "failed_test_replay_enabled": false,
      "failed_test_replay_enabled_inherit": false,
      "pr_comments_enabled": false,
      "repository_id": "github.com/datadog/shopist",
      "service_name": "shopist",
      "test_impact_analysis_enabled": true,
      "test_impact_analysis_enabled_inherit": true
    },
    "type": "test_optimization_update_service_settings_request"
  }
}
```
{% /tab %}
{% /tabs %}

### Response

{% tabs %}
{% tab label="200" %}
OK

{% tabs %}
{% tab label="Model" %}
Response object containing Test Optimization service settings.

| Parent field | Field                                       | Type    | Description                                                                                                                                                            |
| ------------ | ------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|              | data                                        | object  | Data object for Test Optimization service settings response.                                                                                                           |
| data         | attributes                                  | object  | Attributes for Test Optimization service settings.                                                                                                                     |
| attributes   | auto_test_retries_enabled                   | boolean | Whether Auto Test Retries are enabled for this service.                                                                                                                |
| attributes   | auto_test_retries_enabled_is_overridden     | boolean | Whether the Auto Test Retries setting is overridden at the service level.                                                                                              |
| attributes   | code_coverage_enabled                       | boolean | Whether Code Coverage is enabled for this service.                                                                                                                     |
| attributes   | code_coverage_enabled_is_overridden         | boolean | Whether the Code Coverage setting is overridden at the service level.                                                                                                  |
| attributes   | early_flake_detection_enabled               | boolean | Whether Early Flake Detection is enabled for this service.                                                                                                             |
| attributes   | early_flake_detection_enabled_is_overridden | boolean | Whether the Early Flake Detection setting is overridden at the service level.                                                                                          |
| attributes   | env                                         | string  | The environment name.                                                                                                                                                  |
| attributes   | failed_test_replay_enabled                  | boolean | Whether Failed Test Replay is enabled for this service.                                                                                                                |
| attributes   | failed_test_replay_enabled_is_overridden    | boolean | Whether the Failed Test Replay setting is overridden at the service level.                                                                                             |
| attributes   | pr_comments_enabled                         | boolean | Whether PR Comments are enabled. This value reflects the repository-level setting and cannot be overridden at the service level.                                       |
| attributes   | repository_id                               | string  | The repository identifier.                                                                                                                                             |
| attributes   | service_name                                | string  | The service name.                                                                                                                                                      |
| attributes   | test_impact_analysis_enabled                | boolean | Whether Test Impact Analysis is enabled for this service.                                                                                                              |
| attributes   | test_impact_analysis_enabled_is_overridden  | boolean | Whether the Test Impact Analysis setting is overridden at the service level.                                                                                           |
| data         | id                                          | string  | Unique identifier for the service settings.                                                                                                                            |
| data         | type                                        | enum    | JSON:API type for service settings response. The value must always be `test_optimization_service_settings`. Allowed enum values: `test_optimization_service_settings`. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "auto_test_retries_enabled": false,
      "auto_test_retries_enabled_is_overridden": false,
      "code_coverage_enabled": false,
      "code_coverage_enabled_is_overridden": false,
      "early_flake_detection_enabled": false,
      "early_flake_detection_enabled_is_overridden": false,
      "env": "prod",
      "failed_test_replay_enabled": false,
      "failed_test_replay_enabled_is_overridden": false,
      "pr_comments_enabled": false,
      "repository_id": "github.com/datadog/shopist",
      "service_name": "shopist",
      "test_impact_analysis_enabled": true,
      "test_impact_analysis_enabled_is_overridden": true
    },
    "id": "9b8a7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d",
    "type": "test_optimization_service_settings"
  }
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="400" %}
Bad Request

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="403" %}
Not Authorized

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="404" %}
Not Found

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="429" %}
Too many requests

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}
{% /tabs %}

### Code Example

{% tabs %}
{% tab label="Curl" %}
```bash
# Set your Datadog site and credentials
export DD_SITE="datadoghq.com" # Or us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com, ddog-gov.com, us2.ddog-gov.com
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PATCH "https://api.${DD_SITE}/api/v2/ci/test-optimization/settings/service" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "env": "prod",
      "repository_id": "github.com/datadog/test-service",
      "service_name": "test-service",
      "test_impact_analysis_enabled_inherit": true
    },
    "type": "test_optimization_update_service_settings_request"
  }
}
EOF
```
{% /tab %}

{% tab label="Go" %}
```go
// Update Test Optimization service settings returns "OK" response

package main

import (
	"context"
	"encoding/json"
	"fmt"
	"os"

	"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
	"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
)

func main() {
	body := datadogV2.TestOptimizationUpdateServiceSettingsRequest{
		Data: datadogV2.TestOptimizationUpdateServiceSettingsRequestData{
			Attributes: datadogV2.TestOptimizationUpdateServiceSettingsRequestAttributes{
				AutoTestRetriesEnabled:            datadog.PtrBool(false),
				AutoTestRetriesEnabledInherit:     datadog.PtrBool(false),
				CodeCoverageEnabled:               datadog.PtrBool(false),
				CodeCoverageEnabledInherit:        datadog.PtrBool(false),
				EarlyFlakeDetectionEnabled:        datadog.PtrBool(false),
				EarlyFlakeDetectionEnabledInherit: datadog.PtrBool(false),
				Env:                               datadog.PtrString("prod"),
				FailedTestReplayEnabled:           datadog.PtrBool(false),
				FailedTestReplayEnabledInherit:    datadog.PtrBool(false),
				PrCommentsEnabled:                 datadog.PtrBool(false),
				RepositoryId:                      "github.com/datadog/shopist",
				ServiceName:                       "shopist",
				TestImpactAnalysisEnabled:         datadog.PtrBool(true),
				TestImpactAnalysisEnabledInherit:  datadog.PtrBool(true),
			},
			Type: datadogV2.TESTOPTIMIZATIONUPDATESERVICESETTINGSREQUESTDATATYPE_TEST_OPTIMIZATION_UPDATE_SERVICE_SETTINGS_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	ctx = context.WithValue(ctx, datadog.ContextAccessToken, os.Getenv("DD_BEARER_TOKEN"))
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewTestOptimizationApi(apiClient)
	resp, r, err := api.UpdateTestOptimizationServiceSettings(ctx, body)

	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `TestOptimizationApi.UpdateTestOptimizationServiceSettings`: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `TestOptimizationApi.UpdateTestOptimizationServiceSettings`:\n%s\n", responseContent)
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" go run "main.go"
```
{% /tab %}

{% tab label="Java" %}
```java
// Update Test Optimization service settings returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.TestOptimizationApi;
import com.datadog.api.client.v2.model.TestOptimizationServiceSettingsResponse;
import com.datadog.api.client.v2.model.TestOptimizationUpdateServiceSettingsRequest;
import com.datadog.api.client.v2.model.TestOptimizationUpdateServiceSettingsRequestAttributes;
import com.datadog.api.client.v2.model.TestOptimizationUpdateServiceSettingsRequestData;
import com.datadog.api.client.v2.model.TestOptimizationUpdateServiceSettingsRequestDataType;

public class Example {
  public static void main(String[] args) {
    ApiClient defaultClient = ApiClient.getDefaultApiClient();
    defaultClient.setAccessToken(System.getenv("DD_BEARER_TOKEN"));
    TestOptimizationApi apiInstance = new TestOptimizationApi(defaultClient);

    TestOptimizationUpdateServiceSettingsRequest body =
        new TestOptimizationUpdateServiceSettingsRequest()
            .data(
                new TestOptimizationUpdateServiceSettingsRequestData()
                    .attributes(
                        new TestOptimizationUpdateServiceSettingsRequestAttributes()
                            .autoTestRetriesEnabled(false)
                            .autoTestRetriesEnabledInherit(false)
                            .codeCoverageEnabled(false)
                            .codeCoverageEnabledInherit(false)
                            .earlyFlakeDetectionEnabled(false)
                            .earlyFlakeDetectionEnabledInherit(false)
                            .env("prod")
                            .failedTestReplayEnabled(false)
                            .failedTestReplayEnabledInherit(false)
                            .prCommentsEnabled(false)
                            .repositoryId("github.com/datadog/shopist")
                            .serviceName("shopist")
                            .testImpactAnalysisEnabled(true)
                            .testImpactAnalysisEnabledInherit(true))
                    .type(
                        TestOptimizationUpdateServiceSettingsRequestDataType
                            .TEST_OPTIMIZATION_UPDATE_SERVICE_SETTINGS_REQUEST));

    try {
      TestOptimizationServiceSettingsResponse result =
          apiInstance.updateTestOptimizationServiceSettings(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println(
          "Exception when calling TestOptimizationApi#updateTestOptimizationServiceSettings");
      System.err.println("Status code: " + e.getCode());
      System.err.println("Reason: " + e.getResponseBody());
      System.err.println("Response headers: " + e.getResponseHeaders());
      e.printStackTrace();
    }
  }
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" java "Example.java"
```
{% /tab %}

{% tab label="Python" %}
```python
"""
Update Test Optimization service settings returns "OK" response
"""

from os import environ
from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.test_optimization_api import TestOptimizationApi
from datadog_api_client.v2.model.test_optimization_update_service_settings_request import (
    TestOptimizationUpdateServiceSettingsRequest,
)
from datadog_api_client.v2.model.test_optimization_update_service_settings_request_attributes import (
    TestOptimizationUpdateServiceSettingsRequestAttributes,
)
from datadog_api_client.v2.model.test_optimization_update_service_settings_request_data import (
    TestOptimizationUpdateServiceSettingsRequestData,
)
from datadog_api_client.v2.model.test_optimization_update_service_settings_request_data_type import (
    TestOptimizationUpdateServiceSettingsRequestDataType,
)

body = TestOptimizationUpdateServiceSettingsRequest(
    data=TestOptimizationUpdateServiceSettingsRequestData(
        attributes=TestOptimizationUpdateServiceSettingsRequestAttributes(
            auto_test_retries_enabled=False,
            auto_test_retries_enabled_inherit=False,
            code_coverage_enabled=False,
            code_coverage_enabled_inherit=False,
            early_flake_detection_enabled=False,
            early_flake_detection_enabled_inherit=False,
            env="prod",
            failed_test_replay_enabled=False,
            failed_test_replay_enabled_inherit=False,
            pr_comments_enabled=False,
            repository_id="github.com/datadog/shopist",
            service_name="shopist",
            test_impact_analysis_enabled=True,
            test_impact_analysis_enabled_inherit=True,
        ),
        type=TestOptimizationUpdateServiceSettingsRequestDataType.TEST_OPTIMIZATION_UPDATE_SERVICE_SETTINGS_REQUEST,
    ),
)

configuration = Configuration()
configuration.access_token = environ["DD_BEARER_TOKEN"]
with ApiClient(configuration) as api_client:
    api_instance = TestOptimizationApi(api_client)
    response = api_instance.update_test_optimization_service_settings(body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" python3 "example.py"
```
{% /tab %}

{% tab label="Ruby" %}
```ruby
# Update Test Optimization service settings returns "OK" response

require "datadog_api_client"
DatadogAPIClient.configure do |config|
  config.access_token = ENV["DD_BEARER_TOKEN"]
end
api_instance = DatadogAPIClient::V2::TestOptimizationAPI.new

body = DatadogAPIClient::V2::TestOptimizationUpdateServiceSettingsRequest.new({
  data: DatadogAPIClient::V2::TestOptimizationUpdateServiceSettingsRequestData.new({
    attributes: DatadogAPIClient::V2::TestOptimizationUpdateServiceSettingsRequestAttributes.new({
      auto_test_retries_enabled: false,
      auto_test_retries_enabled_inherit: false,
      code_coverage_enabled: false,
      code_coverage_enabled_inherit: false,
      early_flake_detection_enabled: false,
      early_flake_detection_enabled_inherit: false,
      env: "prod",
      failed_test_replay_enabled: false,
      failed_test_replay_enabled_inherit: false,
      pr_comments_enabled: false,
      repository_id: "github.com/datadog/shopist",
      service_name: "shopist",
      test_impact_analysis_enabled: true,
      test_impact_analysis_enabled_inherit: true,
    }),
    type: DatadogAPIClient::V2::TestOptimizationUpdateServiceSettingsRequestDataType::TEST_OPTIMIZATION_UPDATE_SERVICE_SETTINGS_REQUEST,
  }),
})
p api_instance.update_test_optimization_service_settings(body)
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" rb "example.rb"
```
{% /tab %}

{% tab label="Rust" %}
```rust
// Update Test Optimization service settings returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_test_optimization::TestOptimizationAPI;
use datadog_api_client::datadogV2::model::TestOptimizationUpdateServiceSettingsRequest;
use datadog_api_client::datadogV2::model::TestOptimizationUpdateServiceSettingsRequestAttributes;
use datadog_api_client::datadogV2::model::TestOptimizationUpdateServiceSettingsRequestData;
use datadog_api_client::datadogV2::model::TestOptimizationUpdateServiceSettingsRequestDataType;

#[tokio::main]
async fn main() {
    let body =
        TestOptimizationUpdateServiceSettingsRequest::new(
            TestOptimizationUpdateServiceSettingsRequestData::new(
                TestOptimizationUpdateServiceSettingsRequestAttributes::new(
                    "github.com/datadog/shopist".to_string(),
                    "shopist".to_string(),
                )
                    .auto_test_retries_enabled(false)
                    .auto_test_retries_enabled_inherit(false)
                    .code_coverage_enabled(false)
                    .code_coverage_enabled_inherit(false)
                    .early_flake_detection_enabled(false)
                    .early_flake_detection_enabled_inherit(false)
                    .env("prod".to_string())
                    .failed_test_replay_enabled(false)
                    .failed_test_replay_enabled_inherit(false)
                    .pr_comments_enabled(false)
                    .test_impact_analysis_enabled(true)
                    .test_impact_analysis_enabled_inherit(true),
                TestOptimizationUpdateServiceSettingsRequestDataType
                ::TEST_OPTIMIZATION_UPDATE_SERVICE_SETTINGS_REQUEST,
            ),
        );
    let configuration = datadog::Configuration::new();
    let api = TestOptimizationAPI::with_config(configuration);
    let resp = api.update_test_optimization_service_settings(body).await;
    if let Ok(value) = resp {
        println!("{:#?}", value);
    } else {
        println!("{:#?}", resp.unwrap_err());
    }
}
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
```
{% /tab %}

{% tab label="TypeScript" %}
```typescript
/**
 * Update Test Optimization service settings returns "OK" response
 */

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration({
  authMethods: {
    AuthZ: {
      accessToken: process.env.DD_BEARER_TOKEN as string,
    },
  },
});
const apiInstance = new v2.TestOptimizationApi(configuration);

const params: v2.TestOptimizationApiUpdateTestOptimizationServiceSettingsRequest =
  {
    body: {
      data: {
        attributes: {
          autoTestRetriesEnabled: false,
          autoTestRetriesEnabledInherit: false,
          codeCoverageEnabled: false,
          codeCoverageEnabledInherit: false,
          earlyFlakeDetectionEnabled: false,
          earlyFlakeDetectionEnabledInherit: false,
          env: "prod",
          failedTestReplayEnabled: false,
          failedTestReplayEnabledInherit: false,
          prCommentsEnabled: false,
          repositoryId: "github.com/datadog/shopist",
          serviceName: "shopist",
          testImpactAnalysisEnabled: true,
          testImpactAnalysisEnabledInherit: true,
        },
        type: "test_optimization_update_service_settings_request",
      },
    },
  };

apiInstance
  .updateTestOptimizationServiceSettings(params)
  .then((data: v2.TestOptimizationServiceSettingsResponse) => {
    console.log(
      "API called successfully. Returned data: " + JSON.stringify(data)
    );
  })
  .catch((error: any) => console.error(error));
```

#### Instructions

First [install the library and its dependencies](https://dnd37xeb23o8n.cloudfront.net/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:

```bash
DD_SITE="datadoghq.com" DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>" tsc "example.ts"
```
{% /tab %}
{% /tabs %}
