---
type: api
title: Stop datafeeds
description: A datafeed that is stopped ceases to retrieve data from Elasticsearch. A datafeed can be started and stopped
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-ml-stop-datafeed
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-ml-stop-datafeed
products:
  - Elasticsearch
---

# Stop datafeeds

Availability: 5.4+

## Paths

- `POST` `/_ml/datafeeds/{datafeed_id}/_stop`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#bearerauth)

#### Path Parameters

- `datafeed_id` (string Id)
  Identifier for the datafeed. You can stop multiple datafeeds in a single API request by using a comma-separated
list of datafeeds or a wildcard expression. You can close all datafeeds by using `_all` or by specifying `*` as
the identifier.

## Description

A datafeed that is stopped ceases to retrieve data from Elasticsearch. A datafeed can be started and stopped
multiple times throughout its lifecycle.

## Required authorization

* Cluster privileges: `manage_ml`

## Query String Parameters

- `allow_no_match` (boolean · default: true)
  Specifies what to do when the request:

* Contains wildcard expressions and there are no datafeeds that match.
* Contains the `_all` string or no identifiers and there are no matches.
* Contains wildcard expressions and there are only partial matches.

If `true`, the API returns an empty datafeeds array when there are no matches and the subset of results when
there are partial matches. If `false`, the API returns a 404 status code when there are no matches or only
partial matches.
- `force` (boolean · default: false)
  If `true`, the datafeed is stopped forcefully.
- `timeout` (string Duration · default: 20s)
  Specifies the amount of time to wait until a datafeed stops.

## Request Body

`application/json`

- `allow_no_match` (boolean · default: true) — optional
  Refer to the description for the `allow_no_match` query parameter.
- `force` (boolean · default: false) — optional
  Refer to the description for the `force` query parameter.
- `timeout` (string Duration · default: 20s) — optional
  Refer to the description for the `timeout` query parameter.

## Response

`application/json`

- `stopped` (boolean)
## Code Examples

#### Console

```console
POST _ml/datafeeds/datafeed-low_request_rate/_stop
{
  "timeout": "30s"
}
```

#### JavaScript

```javascript
const response = await client.ml.stopDatafeed({
  datafeed_id: "datafeed-low_request_rate",
  timeout: "30s",
});
```

#### Python

```python
resp = client.ml.stop_datafeed(
    datafeed_id="datafeed-low_request_rate",
    timeout="30s",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-low_request_rate/_stop" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "timeout": "30s"
  }'
```

#### Java

```java
client.ml().stopDatafeed(s -> s
    .datafeedId("datafeed-low_request_rate")
    .timeout(t -> t
        .time("30s")
    )
);
```

#### C#

```c#
var response = await client.MachineLearning
    .StopDatafeedAsync(datafeedId: "datafeed-low_request_rate", d1 => d1
        .Timeout("30s")
    );
```

#### PHP

```php
$resp = $client->ml()->stopDatafeed([
    "datafeed_id" => "datafeed-low_request_rate",
    "body" => [
        "timeout" => "30s",
    ],
]);
```

#### Ruby

```ruby
response = client.ml.stop_datafeed(
  datafeed_id: "datafeed-low_request_rate",
  body: {
    "timeout": "30s"
  }
)
```

