---
type: api
title: Delete a filter
description: If an anomaly detection job references the filter, you cannot delete the
url: https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-ml-delete-filter
resource: https://www.elastic.co/docs/api/doc/elasticsearch/v9/operation/operation-ml-delete-filter
products:
  - Elasticsearch
---

# Delete a filter

Authentication: required

Availability: Generally available since 5.4

## Paths

- `DELETE` `/_ml/filters/{filter_id}`

#### Path parameters

- `filter_id` (string) — required
  A string that uniquely identifies a filter.

## Description

If an anomaly detection job references the filter, you cannot delete the
filter. You must update or delete the job before you can delete the filter.

## Required privileges

- Cluster privileges: `manage_ml`

## Response

`application/json`

- `acknowledged` (boolean)
  For a successful response, this value is always true. On failure, an exception is returned instead.
## Code examples

#### Console

```console
DELETE _ml/filters/safe_domains
```

#### JavaScript

```javascript
const response = await client.ml.deleteFilter({
  filter_id: "safe_domains",
});
```

#### Python

```python
resp = client.ml.delete_filter(
    filter_id="safe_domains",
)
```

#### curl

```curl
curl -X DELETE "$ELASTICSEARCH_URL/_ml/filters/safe_domains" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.ml().deleteFilter(d -> d
    .filterId("safe_domains")
);
```

#### C#

```c#
var response = await client.MachineLearning.DeleteFilterAsync(filterId: "safe_domains");
```

#### PHP

```php
$resp = $client->ml()->deleteFilter([
    "filter_id" => "safe_domains",
]);
```

#### Ruby

```ruby
response = client.ml.delete_filter(
  filter_id: "safe_domains"
)
```

## Response examples

#### Ml delete filter response example1

`application/json`

A successful response when deleting a filter.

```json
{
  "acknowledged": true
}
```

