---
type: api
title: Delete an anomaly detection job
description: All job configuration, model state and results are deleted.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-ml-delete-job
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-ml-delete-job
products:
  - Elasticsearch
---

# Delete an anomaly detection job

Availability: Generally available since 5.4

## Paths

- `DELETE` `/_ml/anomaly_detectors/{job_id}`

#### Path parameters

- `job_id` (string) — required
  Identifier for the anomaly detection job.

## Description

All job configuration, model state and results are deleted.
It is not currently possible to delete multiple jobs using wildcards or a
comma separated list. If you delete a job that has a datafeed, the request
first tries to delete the datafeed. This behavior is equivalent to calling
the delete datafeed API with the same timeout and force parameters as the
delete job request.

## 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/guide/en/elasticsearch/reference/current/token-authentication-services.html)

## Query string parameters

- `force` (boolean · default: false) — optional
  Use to forcefully delete an opened job; this method is quicker than
closing and deleting the job.
- `delete_user_annotations` (boolean · default: false) — optional
  Specifies whether annotations that have been added by the
user should be deleted along with any auto-generated annotations when the job is
reset.
- `wait_for_completion` (boolean · default: true) — optional
  Specifies whether the request should return immediately or wait until the
job deletion completes.

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

#### JavaScript

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

#### Python

```python
resp = client.ml.delete_job(
    job_id="total-requests",
)
```

#### curl

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

#### Java

```java
client.ml().deleteJob(d -> d
    .jobId("total-requests")
);
```

#### C#

```c#
var response = await client.MachineLearning.DeleteJobAsync(jobId: "total-requests");
```

#### PHP

```php
$resp = $client->ml()->deleteJob([
    "job_id" => "total-requests",
]);
```

#### Ruby

```ruby
response = client.ml.delete_job(
  job_id: "total-requests"
)
```

## Response examples

#### Delete job

A successful response when deleting an anomaly detection job.

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

#### Delete job asynchronously

A successful response when deleting an anomaly detection job asynchronously. When the `wait_for_completion` query parameter is set to `false`, the response contains an identifier for the job deletion task.

```json
{
  "task": "oTUltX4IQMOUUVeiohTt8A:39"
}
```

