---
type: api
title: Delete a model snapshot
description: You cannot delete the active model snapshot. To delete that snapshot, first
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ml-delete-model-snapshot
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ml-delete-model-snapshot
products:
  - Elasticsearch
---

# Delete a model snapshot

Availability: 5.4+

## Paths

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

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

#### Path Parameters

- `job_id` (string Id)
  Identifier for the anomaly detection job.
- `snapshot_id` (string Id)
  Identifier for the model snapshot.

## Description

You cannot delete the active model snapshot. To delete that snapshot, first
revert to a different one. To identify the active model snapshot, refer to
the `model_snapshot_id` in the results from the get jobs API.

## Required authorization

* Cluster privileges: `manage_ml`

## 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/farequote/model_snapshots/1491948163
```

#### JavaScript

```javascript
const response = await client.ml.deleteModelSnapshot({
  job_id: "farequote",
  snapshot_id: 1491948163,
});
```

#### Python

```python
resp = client.ml.delete_model_snapshot(
    job_id="farequote",
    snapshot_id="1491948163",
)
```

#### curl

```curl
curl -X DELETE "$ELASTICSEARCH_URL/_ml/anomaly_detectors/farequote/model_snapshots/1491948163" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.ml().deleteModelSnapshot(d -> d
    .jobId("farequote")
    .snapshotId("1491948163")
);
```

#### C#

```c#
var response = await client.MachineLearning.DeleteModelSnapshotAsync(jobId: "farequote", snapshotId: "1491948163");
```

#### PHP

```php
$resp = $client->ml()->deleteModelSnapshot([
    "job_id" => "farequote",
    "snapshot_id" => "1491948163",
]);
```

#### Ruby

```ruby
response = client.ml.delete_model_snapshot(
  job_id: "farequote",
  snapshot_id: "1491948163"
)
```

## Response Examples

#### Ml delete model snapshot response example1

A successful response when deleting an existing model snapshot.

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

