---
title: Get Test Optimization service settings
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Test Optimization
---

# Get Test Optimization service settings{% #get-test-optimization-service-settings %}

{% tab title="v2" %}

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

### Overview

Retrieve Test Optimization settings for a specific service identified by repository, service name, and environment. This endpoint requires the `test_optimization_read` permission.

OAuth apps require the `test_optimization_read` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#test-optimization) to access this endpoint.



### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                           | Type   | Description                                                                                                                                                                                      |
| ------------ | ------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|              | data [*required*]          | object | Data object for get service settings request.                                                                                                                                                    |
| data         | attributes [*required*]    | object | Attributes for requesting Test Optimization service settings.                                                                                                                                    |
| attributes   | env                             | string | The environment name. If omitted, defaults to `none`.                                                                                                                                            |
| attributes   | repository_id [*required*] | string | The repository identifier.                                                                                                                                                                       |
| attributes   | service_name [*required*]  | string | The service name.                                                                                                                                                                                |
| data         | type [*required*]          | enum   | JSON:API type for get service settings request. The value must always be `test_optimization_get_service_settings_request`. Allowed enum values: `test_optimization_get_service_settings_request` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "env": "prod",
      "repository_id": "github.com/datadog/shopist",
      "service_name": "shopist"
    },
    "type": "test_optimization_get_service_settings_request"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="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   | code_coverage_enabled         | boolean | Whether Code Coverage is enabled for this service.                                                                                                                    |
| attributes   | early_flake_detection_enabled | boolean | Whether Early Flake Detection is enabled for this service.                                                                                                            |
| attributes   | env                           | string  | The environment name.                                                                                                                                                 |
| attributes   | failed_test_replay_enabled    | boolean | Whether Failed Test Replay is enabled for this service.                                                                                                               |
| attributes   | pr_comments_enabled           | boolean | Whether PR Comments are enabled for this service.                                                                                                                     |
| 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.                                                                                                             |
| 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 title="Example" %}

```json
{
  "data": {
    "attributes": {
      "auto_test_retries_enabled": false,
      "code_coverage_enabled": false,
      "early_flake_detection_enabled": false,
      "env": "prod",
      "failed_test_replay_enabled": false,
      "pr_comments_enabled": true,
      "repository_id": "github.com/datadog/shopist",
      "service_name": "shopist",
      "test_impact_analysis_enabled": false
    },
    "id": "github.com/datadog/shopist::shopist::prod",
    "type": "test_optimization_service_settings"
  }
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
Bad Request
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="403" %}
Not Authorized
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="404" %}
Not Found
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="429" %}
Too many requests
{% tab title="Model" %}
API error response.

| Field                    | Type     | Description       |
| ------------------------ | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |

{% /tab %}

{% tab title="Example" %}

```json
{
  "errors": [
    "Bad Request"
  ]
}
```

{% /tab %}

{% /tab %}

### Code Example

##### 
                  \## default
# 
 \# Curl command curl -X POST "https://api.datadoghq.com/api/v2/ci/test-optimization/settings/service" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "DD-API-KEY: ${DD_API_KEY}" \
-H "DD-APPLICATION-KEY: ${DD_APP_KEY}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "env": "prod",
      "repository_id": "github.com/datadog/test-service",
      "service_name": "test-service"
    },
    "type": "test_optimization_get_service_settings_request"
  }
}
EOF 
                
##### 

```python
"""
Get Test Optimization service settings returns "OK" response
"""

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_get_service_settings_request import (
    TestOptimizationGetServiceSettingsRequest,
)
from datadog_api_client.v2.model.test_optimization_get_service_settings_request_attributes import (
    TestOptimizationGetServiceSettingsRequestAttributes,
)
from datadog_api_client.v2.model.test_optimization_get_service_settings_request_data import (
    TestOptimizationGetServiceSettingsRequestData,
)
from datadog_api_client.v2.model.test_optimization_get_service_settings_request_data_type import (
    TestOptimizationGetServiceSettingsRequestDataType,
)

body = TestOptimizationGetServiceSettingsRequest(
    data=TestOptimizationGetServiceSettingsRequestData(
        attributes=TestOptimizationGetServiceSettingsRequestAttributes(
            env="prod",
            repository_id="github.com/datadog/shopist",
            service_name="shopist",
        ),
        type=TestOptimizationGetServiceSettingsRequestDataType.TEST_OPTIMIZATION_GET_SERVICE_SETTINGS_REQUEST,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = TestOptimizationApi(api_client)
    response = api_instance.get_test_optimization_service_settings(body=body)

    print(response)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=python) and then save the example to `example.py` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
##### 

```ruby
# Get Test Optimization service settings returns "OK" response

require "datadog_api_client"
api_instance = DatadogAPIClient::V2::TestOptimizationAPI.new

body = DatadogAPIClient::V2::TestOptimizationGetServiceSettingsRequest.new({
  data: DatadogAPIClient::V2::TestOptimizationGetServiceSettingsRequestData.new({
    attributes: DatadogAPIClient::V2::TestOptimizationGetServiceSettingsRequestAttributes.new({
      env: "prod",
      repository_id: "github.com/datadog/shopist",
      service_name: "shopist",
    }),
    type: DatadogAPIClient::V2::TestOptimizationGetServiceSettingsRequestDataType::TEST_OPTIMIZATION_GET_SERVICE_SETTINGS_REQUEST,
  }),
})
p api_instance.get_test_optimization_service_settings(body)
```

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=ruby) and then save the example to `example.rb` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
##### 

```go
// Get 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.TestOptimizationGetServiceSettingsRequest{
		Data: datadogV2.TestOptimizationGetServiceSettingsRequestData{
			Attributes: datadogV2.TestOptimizationGetServiceSettingsRequestAttributes{
				Env:          datadog.PtrString("prod"),
				RepositoryId: "github.com/datadog/shopist",
				ServiceName:  "shopist",
			},
			Type: datadogV2.TESTOPTIMIZATIONGETSERVICESETTINGSREQUESTDATATYPE_TEST_OPTIMIZATION_GET_SERVICE_SETTINGS_REQUEST,
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewTestOptimizationApi(apiClient)
	resp, r, err := api.GetTestOptimizationServiceSettings(ctx, body)

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

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

#### Instructions

First [install the library and its dependencies](https://docs.datadoghq.com/api/latest.md?code-lang=go) and then save the example to `main.go` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
##### 

```java
// Get 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.TestOptimizationGetServiceSettingsRequest;
import com.datadog.api.client.v2.model.TestOptimizationGetServiceSettingsRequestAttributes;
import com.datadog.api.client.v2.model.TestOptimizationGetServiceSettingsRequestData;
import com.datadog.api.client.v2.model.TestOptimizationGetServiceSettingsRequestDataType;
import com.datadog.api.client.v2.model.TestOptimizationServiceSettingsResponse;

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

    TestOptimizationGetServiceSettingsRequest body =
        new TestOptimizationGetServiceSettingsRequest()
            .data(
                new TestOptimizationGetServiceSettingsRequestData()
                    .attributes(
                        new TestOptimizationGetServiceSettingsRequestAttributes()
                            .env("prod")
                            .repositoryId("github.com/datadog/shopist")
                            .serviceName("shopist"))
                    .type(
                        TestOptimizationGetServiceSettingsRequestDataType
                            .TEST_OPTIMIZATION_GET_SERVICE_SETTINGS_REQUEST));

    try {
      TestOptimizationServiceSettingsResponse result =
          apiInstance.getTestOptimizationServiceSettings(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println(
          "Exception when calling TestOptimizationApi#getTestOptimizationServiceSettings");
      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://docs.datadoghq.com/api/latest.md?code-lang=java) and then save the example to `Example.java` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
##### 

```rust
// Get 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::TestOptimizationGetServiceSettingsRequest;
use datadog_api_client::datadogV2::model::TestOptimizationGetServiceSettingsRequestAttributes;
use datadog_api_client::datadogV2::model::TestOptimizationGetServiceSettingsRequestData;
use datadog_api_client::datadogV2::model::TestOptimizationGetServiceSettingsRequestDataType;

#[tokio::main]
async fn main() {
    let body =
        TestOptimizationGetServiceSettingsRequest::new(
            TestOptimizationGetServiceSettingsRequestData::new(
                TestOptimizationGetServiceSettingsRequestAttributes::new(
                    "github.com/datadog/shopist".to_string(),
                    "shopist".to_string(),
                ).env("prod".to_string()),
                TestOptimizationGetServiceSettingsRequestDataType::TEST_OPTIMIZATION_GET_SERVICE_SETTINGS_REQUEST,
            ),
        );
    let configuration = datadog::Configuration::new();
    let api = TestOptimizationAPI::with_config(configuration);
    let resp = api.get_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://docs.datadoghq.com/api/latest.md?code-lang=rust) and then save the example to `src/main.rs` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
##### 

```typescript
/**
 * Get Test Optimization service settings returns "OK" response
 */

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

const configuration = client.createConfiguration();
const apiInstance = new v2.TestOptimizationApi(configuration);

const params: v2.TestOptimizationApiGetTestOptimizationServiceSettingsRequest =
  {
    body: {
      data: {
        attributes: {
          env: "prod",
          repositoryId: "github.com/datadog/shopist",
          serviceName: "shopist",
        },
        type: "test_optimization_get_service_settings_request",
      },
    },
  };

apiInstance
  .getTestOptimizationServiceSettings(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://docs.datadoghq.com/api/latest.md?code-lang=typescript) and then save the example to `example.ts` and run following commands:
    DD_SITE="datadoghq.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"
{% /tab %}
