---
title: Bulk delete tests
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > Synthetics
---

# Bulk delete tests{% #bulk-delete-tests %}
Copy pageCopied
{% tab title="v2" %}

| Datadog site      | API endpoint                                                           |
| ----------------- | ---------------------------------------------------------------------- |
| ap1.datadoghq.com | POST https://api.ap1.datadoghq.com/api/v2/synthetics/tests/bulk-delete |
| ap2.datadoghq.com | POST https://api.ap2.datadoghq.com/api/v2/synthetics/tests/bulk-delete |
| app.datadoghq.eu  | POST https://api.datadoghq.eu/api/v2/synthetics/tests/bulk-delete      |
| app.ddog-gov.com  | POST https://api.ddog-gov.com/api/v2/synthetics/tests/bulk-delete      |
| us2.ddog-gov.com  | POST https://api.us2.ddog-gov.com/api/v2/synthetics/tests/bulk-delete  |
| app.datadoghq.com | POST https://api.datadoghq.com/api/v2/synthetics/tests/bulk-delete     |
| us3.datadoghq.com | POST https://api.us3.datadoghq.com/api/v2/synthetics/tests/bulk-delete |
| us5.datadoghq.com | POST https://api.us5.datadoghq.com/api/v2/synthetics/tests/bulk-delete |

### Overview

This endpoint requires the `synthetics_write` permission.

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



### Request

#### Body Data (required)



{% tab title="Model" %}

| Parent field | Field                        | Type     | Description                                                                                                           |
| ------------ | ---------------------------- | -------- | --------------------------------------------------------------------------------------------------------------------- |
|              | data [*required*]       | object   | Data object for a bulk delete Synthetic tests request.                                                                |
| data         | attributes [*required*] | object   | Attributes for a bulk delete Synthetic tests request.                                                                 |
| attributes   | force_delete_dependencies    | boolean  | Whether to force deletion of tests that have dependent resources.                                                     |
| attributes   | public_ids [*required*] | [string] | List of public IDs of the Synthetic tests to delete.                                                                  |
| data         | id                           | string   | An optional identifier for the delete request.                                                                        |
| data         | type                         | enum     | Type for the bulk delete Synthetic tests request, `delete_tests_request`. Allowed enum values: `delete_tests_request` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": {
    "attributes": {
      "force_delete_dependencies": false,
      "public_ids": [
        "abc-def-123"
      ]
    },
    "id": "string",
    "type": "delete_tests_request"
  }
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% tab title="Model" %}
Response containing the list of deleted Synthetic tests.

| Parent field | Field      | Type     | Description                                                                                            |
| ------------ | ---------- | -------- | ------------------------------------------------------------------------------------------------------ |
|              | data       | [object] | List of deleted Synthetic test data objects.                                                           |
| data         | attributes | object   | Attributes of a deleted Synthetic test, including deletion timestamp and public ID.                    |
| attributes   | deleted_at | string   | Deletion timestamp of the Synthetic test ID.                                                           |
| attributes   | public_id  | string   | The Synthetic test ID deleted.                                                                         |
| data         | id         | string   | The public ID of the deleted Synthetic test.                                                           |
| data         | type       | enum     | Type for the bulk delete Synthetic tests response, `delete_tests`. Allowed enum values: `delete_tests` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": [
    {
      "attributes": {
        "deleted_at": "string",
        "public_id": "string"
      },
      "id": "string",
      "type": "delete_tests"
    }
  ]
}
```

{% /tab %}

{% /tab %}

{% tab title="400" %}
API error response.
{% 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" %}
API error response.
{% 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/synthetics/tests/bulk-delete" \
-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": {
      "public_ids": [
        "abc-def-123",
        "xyz-uvw-456"
      ]
    },
    "type": "delete_tests_request"
  }
}
EOF 
                
##### 

```python
"""
Bulk delete tests returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.synthetics_api import SyntheticsApi
from datadog_api_client.v2.model.deleted_tests_request_delete import DeletedTestsRequestDelete
from datadog_api_client.v2.model.deleted_tests_request_delete_attributes import DeletedTestsRequestDeleteAttributes
from datadog_api_client.v2.model.deleted_tests_request_delete_request import DeletedTestsRequestDeleteRequest
from datadog_api_client.v2.model.deleted_tests_request_type import DeletedTestsRequestType

body = DeletedTestsRequestDeleteRequest(
    data=DeletedTestsRequestDelete(
        attributes=DeletedTestsRequestDeleteAttributes(
            public_ids=[
                "abc-def-123",
            ],
        ),
        type=DeletedTestsRequestType.DELETE_TESTS_REQUEST,
    ),
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = SyntheticsApi(api_client)
    response = api_instance.delete_synthetics_tests(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
# Bulk delete tests returns "OK" response

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

body = DatadogAPIClient::V2::DeletedTestsRequestDeleteRequest.new({
  data: DatadogAPIClient::V2::DeletedTestsRequestDelete.new({
    attributes: DatadogAPIClient::V2::DeletedTestsRequestDeleteAttributes.new({
      public_ids: [
        "abc-def-123",
      ],
    }),
    type: DatadogAPIClient::V2::DeletedTestsRequestType::DELETE_TESTS_REQUEST,
  }),
})
p api_instance.delete_synthetics_tests(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
// Bulk delete tests 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.DeletedTestsRequestDeleteRequest{
		Data: datadogV2.DeletedTestsRequestDelete{
			Attributes: datadogV2.DeletedTestsRequestDeleteAttributes{
				PublicIds: []string{
					"abc-def-123",
				},
			},
			Type: datadogV2.DELETEDTESTSREQUESTTYPE_DELETE_TESTS_REQUEST.Ptr(),
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewSyntheticsApi(apiClient)
	resp, r, err := api.DeleteSyntheticsTests(ctx, body)

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

	responseContent, _ := json.MarshalIndent(resp, "", "  ")
	fmt.Fprintf(os.Stdout, "Response from `SyntheticsApi.DeleteSyntheticsTests`:\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
// Bulk delete tests returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.SyntheticsApi;
import com.datadog.api.client.v2.model.DeletedTestsRequestDelete;
import com.datadog.api.client.v2.model.DeletedTestsRequestDeleteAttributes;
import com.datadog.api.client.v2.model.DeletedTestsRequestDeleteRequest;
import com.datadog.api.client.v2.model.DeletedTestsRequestType;
import com.datadog.api.client.v2.model.DeletedTestsResponse;
import java.util.Collections;

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

    DeletedTestsRequestDeleteRequest body =
        new DeletedTestsRequestDeleteRequest()
            .data(
                new DeletedTestsRequestDelete()
                    .attributes(
                        new DeletedTestsRequestDeleteAttributes()
                            .publicIds(Collections.singletonList("abc-def-123")))
                    .type(DeletedTestsRequestType.DELETE_TESTS_REQUEST));

    try {
      DeletedTestsResponse result = apiInstance.deleteSyntheticsTests(body);
      System.out.println(result);
    } catch (ApiException e) {
      System.err.println("Exception when calling SyntheticsApi#deleteSyntheticsTests");
      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
// Bulk delete tests returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_synthetics::SyntheticsAPI;
use datadog_api_client::datadogV2::model::DeletedTestsRequestDelete;
use datadog_api_client::datadogV2::model::DeletedTestsRequestDeleteAttributes;
use datadog_api_client::datadogV2::model::DeletedTestsRequestDeleteRequest;
use datadog_api_client::datadogV2::model::DeletedTestsRequestType;

#[tokio::main]
async fn main() {
    let body = DeletedTestsRequestDeleteRequest::new(
        DeletedTestsRequestDelete::new(DeletedTestsRequestDeleteAttributes::new(vec![
            "abc-def-123".to_string(),
        ]))
        .type_(DeletedTestsRequestType::DELETE_TESTS_REQUEST),
    );
    let configuration = datadog::Configuration::new();
    let api = SyntheticsAPI::with_config(configuration);
    let resp = api.delete_synthetics_tests(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
/**
 * Bulk delete tests returns "OK" response
 */

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

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

const params: v2.SyntheticsApiDeleteSyntheticsTestsRequest = {
  body: {
    data: {
      attributes: {
        publicIds: ["abc-def-123"],
      },
      type: "delete_tests_request",
    },
  },
};

apiInstance
  .deleteSyntheticsTests(params)
  .then((data: v2.DeletedTestsResponse) => {
    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 %}
