Bulk delete tests

POST https://api.ap1.datadoghq.com/api/v2/synthetics/tests/bulk-deletehttps://api.ap2.datadoghq.com/api/v2/synthetics/tests/bulk-deletehttps://api.datadoghq.eu/api/v2/synthetics/tests/bulk-deletehttps://api.ddog-gov.com/api/v2/synthetics/tests/bulk-deletehttps://api.us2.ddog-gov.com/api/v2/synthetics/tests/bulk-deletehttps://api.datadoghq.com/api/v2/synthetics/tests/bulk-deletehttps://api.us3.datadoghq.com/api/v2/synthetics/tests/bulk-deletehttps://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 to access this endpoint.

Request

Body Data (required)

Expand All

Field

Type

Description

data [required]

object

Data object for a bulk delete Synthetic tests request.

attributes [required]

object

Attributes for a bulk delete Synthetic tests request.

force_delete_dependencies

boolean

Whether to force deletion of tests that have dependent resources.

public_ids [required]

[string]

List of public IDs of the Synthetic tests to delete.

id

string

An optional identifier for the delete request.

type

enum

Type for the bulk delete Synthetic tests request, delete_tests_request. Allowed enum values: delete_tests_request

default: delete_tests_request

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

Response

OK

Response containing the list of deleted Synthetic tests.

Expand All

Field

Type

Description

data

[object]

List of deleted Synthetic test data objects.

attributes

object

Attributes of a deleted Synthetic test, including deletion timestamp and public ID.

deleted_at

string

Deletion timestamp of the Synthetic test ID.

public_id

string

The Synthetic test ID deleted.

id

string

The public ID of the deleted Synthetic test.

type

enum

Type for the bulk delete Synthetic tests response, delete_tests. Allowed enum values: delete_tests

default: delete_tests

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

API error response.

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

API error response.

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Too many requests

API error response.

Expand All

Field

Type

Description

errors [required]

[string]

A list of errors.

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

Code Example

                  ## default
# 

# Curl command
curl -X POST "https://api.ap1.datadoghq.com"https://api.ap2.datadoghq.com"https://api.datadoghq.eu"https://api.ddog-gov.com"https://api.us2.ddog-gov.com"https://api.datadoghq.com"https://api.us3.datadoghq.com"https://api.us5.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
"""
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 and then save the example to example.py and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" python3 "example.py"
# 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 and then save the example to example.rb and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" rb "example.rb"
// 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 and then save the example to main.go and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" go run "main.go"
// 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 and then save the example to Example.java and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" java "Example.java"
// 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 and then save the example to src/main.rs and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" cargo run
/**
 * 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 and then save the example to example.ts and run following commands:

    
DD_SITE="datadoghq.comus3.datadoghq.comus5.datadoghq.comdatadoghq.euap1.datadoghq.comap2.datadoghq.comddog-gov.comus2.ddog-gov.com" DD_API_KEY="<DD_API_KEY>" DD_APP_KEY="<DD_APP_KEY>" tsc "example.ts"