---
type: api
title: Get filters
description: You can get a single filter or all filters.
url: https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-filters
resource: https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-ml-get-filters
products:
  - Elasticsearch
---

# Get filters

Authentication: required

Availability: Generally available since 5.5

## Paths

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

#### Path parameters

- `filter_id` (union string | string[]) — optional, leave it out to use `/_ml/filters`
  A string that uniquely identifies a filter.

## Description

You can get a single filter or all filters.

## Required privileges

- Cluster privileges: `manage_ml`

## Query string parameters

- `from` (number · default: 0) — optional
  Skips the specified number of filters.
- `size` (number · default: 100) — optional
  Specifies the maximum number of filters to obtain.

## Response

`application/json`

- `count` (number)
- `filters` (object[])
  - `description` (string)
    A description of the filter.
  - `filter_id` (string)
    A string that uniquely identifies a filter.
  - `items` (string[])
    An array of strings which is the filter item list.
## Code examples

#### Console

```console
GET _ml/filters/safe_domains
```

#### JavaScript

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

#### Python

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

#### curl

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

#### Java

```java
client.ml().getFilters(g -> g
    .filterId("safe_domains")
);
```

#### C#

```c#
var response = await client.MachineLearning
    .GetFiltersAsync(d1 => d1
        .FilterId(new[] { "safe_domains" })
    );
```

#### PHP

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

#### Ruby

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

## Response examples

#### 200

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "count": 0,
  "filters": [
    {
      "description": "string",
      "filter_id": "string",
      "items": [
        "string"
      ]
    }
  ]
}
```

