---
type: api
title: Delete a datafeed
description: ## Required authorization
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-ml-delete-datafeed
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v9/operation/operation-ml-delete-datafeed
products:
  - Elasticsearch
---

# Delete a datafeed

Availability: Generally available since 5.4

## Paths

- `DELETE` `/_ml/datafeeds/{datafeed_id}`

#### Path parameters

- `datafeed_id` (string) — required
  A numerical character string that uniquely identifies the datafeed. This
identifier can contain lowercase alphanumeric characters (a-z and 0-9),
hyphens, and underscores. It must start and end with alphanumeric
characters.

## Required authorization

- Cluster privileges: `manage_ml`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)

## Query string parameters

- `force` (boolean) — optional
  Use to forcefully delete a started datafeed; this method is quicker than
stopping and deleting the datafeed.

## 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/datafeeds/datafeed-total-requests
```

#### JavaScript

```javascript
const response = await client.ml.deleteDatafeed({
  datafeed_id: "datafeed-total-requests",
});
```

#### Python

```python
resp = client.ml.delete_datafeed(
    datafeed_id="datafeed-total-requests",
)
```

#### curl

```curl
curl -X DELETE "$ELASTICSEARCH_URL/_ml/datafeeds/datafeed-total-requests" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.ml().deleteDatafeed(d -> d
    .datafeedId("datafeed-total-requests")
);
```

#### C#

```c#
var response = await client.MachineLearning.DeleteDatafeedAsync(datafeedId: "datafeed-total-requests");
```

#### PHP

```php
$resp = $client->ml()->deleteDatafeed([
    "datafeed_id" => "datafeed-total-requests",
]);
```

#### Ruby

```ruby
response = client.ml.delete_datafeed(
  datafeed_id: "datafeed-total-requests"
)
```

## Response examples

#### Ml delete datafeed response example1

A successful response when deleting a datafeed.

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

