---
type: api
title: Upgrade a snapshot
description: Upgrade an anomaly detection model snapshot to the latest major version.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-ml-upgrade-job-snapshot
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-ml-upgrade-job-snapshot
products:
  - Elasticsearch
---

# Upgrade a snapshot

Availability: 5.4+

## Paths

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

- [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.
- `snapshot_id` (string Id)
  A numerical character string that uniquely identifies the model snapshot.

## Description

Upgrade an anomaly detection model snapshot to the latest major version.
Over time, older snapshot formats are deprecated and removed. Anomaly
detection jobs support only snapshots that are from the current or previous
major version.
This API provides a means to upgrade a snapshot to the current major version.
This aids in preparing the cluster for an upgrade to the next major version.
Only one snapshot per anomaly detection job can be upgraded at a time and the
upgraded snapshot cannot be the current snapshot of the anomaly detection
job.

## Required authorization

* Cluster privileges: `manage_ml`

## Query String Parameters

- `wait_for_completion` (boolean · default: false)
  When true, the API won’t respond until the upgrade is complete.
Otherwise, it responds as soon as the upgrade task is assigned to a node.
- `timeout` (string Duration · default: 30m)
  Controls the time to wait for the request to complete.

## Response

`application/json`

- `node` (string)
  The ID of the node that the upgrade task was started on if it is still running. In serverless this will be the "serverless".
- `completed` (boolean)
  When true, this means the task is complete. When false, it is still running.
## Code Examples

#### Console

```console
POST _ml/anomaly_detectors/low_request_rate/model_snapshots/1828371/_upgrade?timeout=45m&wait_for_completion=true
```

#### JavaScript

```javascript
const response = await client.ml.upgradeJobSnapshot({
  job_id: "low_request_rate",
  snapshot_id: 1828371,
  timeout: "45m",
  wait_for_completion: "true",
});
```

#### Python

```python
resp = client.ml.upgrade_job_snapshot(
    job_id="low_request_rate",
    snapshot_id="1828371",
    timeout="45m",
    wait_for_completion=True,
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_ml/anomaly_detectors/low_request_rate/model_snapshots/1828371/_upgrade?timeout=45m&wait_for_completion=true" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.ml().upgradeJobSnapshot(u -> u
    .jobId("low_request_rate")
    .snapshotId("1828371")
    .timeout(t -> t
        .time("45m")
    )
    .waitForCompletion(true)
);
```

#### C#

```c#
var response = await client.MachineLearning
    .UpgradeJobSnapshotAsync(jobId: "low_request_rate", snapshotId: "1828371", d1 => d1
        .Timeout("45m")
        .WaitForCompletion(true)
    );
```

#### PHP

```php
$resp = $client->ml()->upgradeJobSnapshot([
    "job_id" => "low_request_rate",
    "snapshot_id" => "1828371",
    "timeout" => "45m",
    "wait_for_completion" => "true",
]);
```

#### Ruby

```ruby
response = client.ml.upgrade_job_snapshot(
  job_id: "low_request_rate",
  snapshot_id: "1828371",
  timeout: "45m",
  wait_for_completion: "true"
)
```

