---
title: Re-order retention filters
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: Docs > API Reference > APM Retention Filters
---

# Re-order retention filters{% #re-order-retention-filters %}
Copy pageCopied
{% tab title="v2" %}

| Datadog site      | API endpoint                                                                          |
| ----------------- | ------------------------------------------------------------------------------------- |
| ap1.datadoghq.com | PUT https://api.ap1.datadoghq.com/api/v2/apm/config/retention-filters-execution-order |
| ap2.datadoghq.com | PUT https://api.ap2.datadoghq.com/api/v2/apm/config/retention-filters-execution-order |
| app.datadoghq.eu  | PUT https://api.datadoghq.eu/api/v2/apm/config/retention-filters-execution-order      |
| app.ddog-gov.com  | PUT https://api.ddog-gov.com/api/v2/apm/config/retention-filters-execution-order      |
| us2.ddog-gov.com  | PUT https://api.us2.ddog-gov.com/api/v2/apm/config/retention-filters-execution-order  |
| app.datadoghq.com | PUT https://api.datadoghq.com/api/v2/apm/config/retention-filters-execution-order     |
| us3.datadoghq.com | PUT https://api.us3.datadoghq.com/api/v2/apm/config/retention-filters-execution-order |
| us5.datadoghq.com | PUT https://api.us5.datadoghq.com/api/v2/apm/config/retention-filters-execution-order |

### Overview

Re-order the execution order of retention filters. This endpoint requires the `apm_retention_filter_write` permission.

### Request

#### Body Data (required)

The list of retention filters in the new order.

{% tab title="Model" %}

| Parent field | Field                  | Type     | Description                                                           |
| ------------ | ---------------------- | -------- | --------------------------------------------------------------------- |
|              | data [*required*] | [object] | A list of retention filters objects.                                  |
| data         | id [*required*]   | string   | The ID of the retention filter.                                       |
| data         | type [*required*] | enum     | The type of the resource. Allowed enum values: `apm_retention_filter` |

{% /tab %}

{% tab title="Example" %}

```json
{
  "data": [
    {
      "id": "jdZrilSJQLqzb6Cu7aub9Q",
      "type": "apm_retention_filter"
    },
    {
      "id": "7RBOb7dLSYWI01yc3pIH8w",
      "type": "apm_retention_filter"
    }
  ]
}
```

{% /tab %}

### Response

{% tab title="200" %}
OK
{% /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="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 PUT "https://api.datadoghq.com/api/v2/apm/config/retention-filters-execution-order" \
-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": [
    {
      "id": "7RBOb7dLSYWI01yc3pIH8w",
      "type": "apm_retention_filter"
    }
  ]
}
EOF 
                        
##### 

```go
// Re-order retention filters returns "OK" response

package main

import (
	"context"
	"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.ReorderRetentionFiltersRequest{
		Data: []datadogV2.RetentionFilterWithoutAttributes{
			{
				Id:   "jdZrilSJQLqzb6Cu7aub9Q",
				Type: datadogV2.APMRETENTIONFILTERTYPE_apm_retention_filter,
			},
			{
				Id:   "7RBOb7dLSYWI01yc3pIH8w",
				Type: datadogV2.APMRETENTIONFILTERTYPE_apm_retention_filter,
			},
		},
	}
	ctx := datadog.NewDefaultContext(context.Background())
	configuration := datadog.NewConfiguration()
	apiClient := datadog.NewAPIClient(configuration)
	api := datadogV2.NewAPMRetentionFiltersApi(apiClient)
	r, err := api.ReorderApmRetentionFilters(ctx, body)

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

#### 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="<API-KEY>" DD_APP_KEY="<APP-KEY>" go run "main.go"
##### 

```java
// Re-order retention filters returns "OK" response

import com.datadog.api.client.ApiClient;
import com.datadog.api.client.ApiException;
import com.datadog.api.client.v2.api.ApmRetentionFiltersApi;
import com.datadog.api.client.v2.model.ApmRetentionFilterType;
import com.datadog.api.client.v2.model.ReorderRetentionFiltersRequest;
import com.datadog.api.client.v2.model.RetentionFilterWithoutAttributes;
import java.util.Arrays;

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

    ReorderRetentionFiltersRequest body =
        new ReorderRetentionFiltersRequest()
            .data(
                Arrays.asList(
                    new RetentionFilterWithoutAttributes()
                        .id("jdZrilSJQLqzb6Cu7aub9Q")
                        .type(ApmRetentionFilterType.apm_retention_filter),
                    new RetentionFilterWithoutAttributes()
                        .id("7RBOb7dLSYWI01yc3pIH8w")
                        .type(ApmRetentionFilterType.apm_retention_filter)));

    try {
      apiInstance.reorderApmRetentionFilters(body);
    } catch (ApiException e) {
      System.err.println(
          "Exception when calling ApmRetentionFiltersApi#reorderApmRetentionFilters");
      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="<API-KEY>" DD_APP_KEY="<APP-KEY>" java "Example.java"
##### 

```python
"""
Re-order retention filters returns "OK" response
"""

from datadog_api_client import ApiClient, Configuration
from datadog_api_client.v2.api.apm_retention_filters_api import APMRetentionFiltersApi
from datadog_api_client.v2.model.apm_retention_filter_type import ApmRetentionFilterType
from datadog_api_client.v2.model.reorder_retention_filters_request import ReorderRetentionFiltersRequest
from datadog_api_client.v2.model.retention_filter_without_attributes import RetentionFilterWithoutAttributes

body = ReorderRetentionFiltersRequest(
    data=[
        RetentionFilterWithoutAttributes(
            id="jdZrilSJQLqzb6Cu7aub9Q",
            type=ApmRetentionFilterType.apm_retention_filter,
        ),
        RetentionFilterWithoutAttributes(
            id="7RBOb7dLSYWI01yc3pIH8w",
            type=ApmRetentionFilterType.apm_retention_filter,
        ),
    ],
)

configuration = Configuration()
with ApiClient(configuration) as api_client:
    api_instance = APMRetentionFiltersApi(api_client)
    api_instance.reorder_apm_retention_filters(body=body)
```

#### 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="<API-KEY>" DD_APP_KEY="<APP-KEY>" python3 "example.py"
##### 

```ruby
# Re-order retention filters returns "OK" response

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

body = DatadogAPIClient::V2::ReorderRetentionFiltersRequest.new({
  data: [
    DatadogAPIClient::V2::RetentionFilterWithoutAttributes.new({
      id: "jdZrilSJQLqzb6Cu7aub9Q",
      type: DatadogAPIClient::V2::ApmRetentionFilterType::APM_RETENTION_FILTER,
    }),
    DatadogAPIClient::V2::RetentionFilterWithoutAttributes.new({
      id: "7RBOb7dLSYWI01yc3pIH8w",
      type: DatadogAPIClient::V2::ApmRetentionFilterType::APM_RETENTION_FILTER,
    }),
  ],
})
p api_instance.reorder_apm_retention_filters(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="<API-KEY>" DD_APP_KEY="<APP-KEY>" rb "example.rb"
##### 

```rust
// Re-order retention filters returns "OK" response
use datadog_api_client::datadog;
use datadog_api_client::datadogV2::api_apm_retention_filters::APMRetentionFiltersAPI;
use datadog_api_client::datadogV2::model::ApmRetentionFilterType;
use datadog_api_client::datadogV2::model::ReorderRetentionFiltersRequest;
use datadog_api_client::datadogV2::model::RetentionFilterWithoutAttributes;

#[tokio::main]
async fn main() {
    let body = ReorderRetentionFiltersRequest::new(vec![
        RetentionFilterWithoutAttributes::new(
            "jdZrilSJQLqzb6Cu7aub9Q".to_string(),
            ApmRetentionFilterType::apm_retention_filter,
        ),
        RetentionFilterWithoutAttributes::new(
            "7RBOb7dLSYWI01yc3pIH8w".to_string(),
            ApmRetentionFilterType::apm_retention_filter,
        ),
    ]);
    let configuration = datadog::Configuration::new();
    let api = APMRetentionFiltersAPI::with_config(configuration);
    let resp = api.reorder_apm_retention_filters(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="<API-KEY>" DD_APP_KEY="<APP-KEY>" cargo run
##### 

```typescript
/**
 * Re-order retention filters returns "OK" response
 */

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

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

const params: v2.APMRetentionFiltersApiReorderApmRetentionFiltersRequest = {
  body: {
    data: [
      {
        id: "jdZrilSJQLqzb6Cu7aub9Q",
        type: "apm_retention_filter",
      },
      {
        id: "7RBOb7dLSYWI01yc3pIH8w",
        type: "apm_retention_filter",
      },
    ],
  },
};

apiInstance
  .reorderApmRetentionFilters(params)
  .then((data: any) => {
    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="<API-KEY>" DD_APP_KEY="<APP-KEY>" tsc "example.ts"
{% /tab %}
