---
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/4371/api/doc/elasticsearch/v9/operation/operation-ml-delete-job
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-ml-delete-job
products:
  - Elasticsearch
---

# Delete an anomaly detection job

Availability: 5.4+

## Paths

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

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

#### Path Parameters

- `job_id` (string Id)
  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`

## Query String Parameters

- `force` (boolean · default: false)
  Use to forcefully delete an opened job; this method is quicker than
closing and deleting the job.
- `delete_user_annotations` (boolean · default: false)
  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)
  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"
}
```

