---
type: api
title: Update a snapshot
description: Updates certain properties of a snapshot.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ml-update-model-snapshot
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/operation/operation-ml-update-model-snapshot
products:
  - Elasticsearch
---

# Update a snapshot

Availability: 5.4+

## Paths

- `POST` `/_ml/anomaly_detectors/{job_id}/model_snapshots/{snapshot_id}/_update`

- [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

Updates certain properties of a snapshot.

## Required authorization

* Cluster privileges: `manage_ml`

## Request Body

`application/json`

- `description` (string) — optional
  A description of the model snapshot.
- `retain` (boolean · default: false) — optional
  If `true`, this snapshot will not be deleted during automatic cleanup of
snapshots older than `model_snapshot_retention_days`. However, this
snapshot will be deleted when the job is deleted.

## Response

`application/json`

- `acknowledged` (boolean)
- `model` ({} ModelSnapshot)
  - `description` (string)
    An optional description of the job.
  - `job_id` (string Id)
    A numerical character string that uniquely identifies the job that the snapshot was created for.
  - `latest_record_time_stamp` (number)
    The timestamp of the latest processed record.
  - `latest_result_time_stamp` (number)
    The timestamp of the latest bucket result.
  - `min_version` (string)
    The minimum version required to be able to restore the model snapshot.
  - `model_size_stats` ({} ModelSizeStats)
    Summary information describing the model.
    - `bucket_allocation_failures_count` (number)
    - `job_id` (string Id)
    - `log_time` (DateTime)
    - `memory_status` (enum MemoryStatus)
      Values: `ok`, `soft_limit`, `hard_limit`
    - `model_bytes` (number | string ByteSize)
    - `model_bytes_exceeded` (number | string ByteSize)
    - `model_bytes_memory_limit` (number | string ByteSize)
    - `output_memory_allocator_bytes` (number | string ByteSize)
    - `peak_model_bytes` (number | string ByteSize)
    - `assignment_memory_basis` (string)
    - `result_type` (string)
    - `total_by_field_count` (number)
    - `total_over_field_count` (number)
    - `total_partition_field_count` (number)
    - `categorization_status` (enum CategorizationStatus)
      Values: `ok`, `warn`
    - `categorized_doc_count` (number)
    - `dead_category_count` (number)
    - `failed_category_count` (number)
    - `frequent_category_count` (number)
    - `rare_category_count` (number)
    - `total_category_count` (number)
    - `timestamp` (number)
  - `retain` (boolean)
    If true, this snapshot will not be deleted during automatic cleanup of snapshots older than model_snapshot_retention_days. However, this snapshot will be deleted when the job is deleted. The default value is false.
  - `snapshot_doc_count` (number)
    For internal use only.
  - `snapshot_id` (string Id)
    A numerical character string that uniquely identifies the model snapshot.
  - `timestamp` (number)
    The creation timestamp for the snapshot.
## Code Examples

#### Console

```console
POST
_ml/anomaly_detectors/it_ops_new_logs/model_snapshots/1491852978/_update
{
  "description": "Snapshot 1",
  "retain": true
}
```

#### JavaScript

```javascript
const response = await client.ml.updateModelSnapshot({
  job_id: "it_ops_new_logs",
  snapshot_id: 1491852978,
  description: "Snapshot 1",
  retain: true,
});
```

#### Python

```python
resp = client.ml.update_model_snapshot(
    job_id="it_ops_new_logs",
    snapshot_id="1491852978",
    description="Snapshot 1",
    retain=True,
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_ml/anomaly_detectors/it_ops_new_logs/model_snapshots/1491852978/_update" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "description": "Snapshot 1",
    "retain": true
  }'
```

#### Java

```java
client.ml().updateModelSnapshot(u -> u
    .description("Snapshot 1")
    .jobId("it_ops_new_logs")
    .retain(true)
    .snapshotId("1491852978")
);
```

#### C#

```c#
var response = await client.MachineLearning
    .UpdateModelSnapshotAsync(jobId: "it_ops_new_logs", snapshotId: "1491852978", d1 => d1
        .Description("Snapshot 1")
        .Retain(true)
    );
```

#### PHP

```php
$resp = $client->ml()->updateModelSnapshot([
    "job_id" => "it_ops_new_logs",
    "snapshot_id" => "1491852978",
    "body" => [
        "description" => "Snapshot 1",
        "retain" => true,
    ],
]);
```

#### Ruby

```ruby
response = client.ml.update_model_snapshot(
  job_id: "it_ops_new_logs",
  snapshot_id: "1491852978",
  body: {
    "description": "Snapshot 1",
    "retain": true
  }
)
```

