---
type: api
title: Get model snapshots info
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-ml-get-model-snapshots
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-ml-get-model-snapshots
products:
  - Elasticsearch
---

# Get model snapshots info


Availability: Generally available since 5.4

## Paths

- `POST` (also `GET`) `/_ml/anomaly_detectors/{job_id}/model_snapshots/{snapshot_id}`
- `POST` (also `GET`) `/_ml/anomaly_detectors/{job_id}/model_snapshots`

#### Path parameters

- `job_id` (string) — required
  Identifier for the anomaly detection job.
- `snapshot_id` (string) — optional, leave it out to use `/_ml/anomaly_detectors/{job_id}/model_snapshots`
  A numerical character string that uniquely identifies the model snapshot. You can get information for multiple
snapshots by using a comma-separated list or a wildcard expression. You can get all snapshots by using `_all`,
by specifying `*` as the snapshot ID, or by omitting the snapshot ID.

## Required authorization

- Cluster privileges: `monitor_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

- `desc` (boolean · default: false) — optional
  If true, the results are sorted in descending order.
- `end` (union oneOf) — optional
  Returns snapshots with timestamps earlier than this time.
  One of: `string` or `number`
- `from` (number · default: 0) — optional
  Skips the specified number of snapshots.
- `size` (number · default: 100) — optional
  Specifies the maximum number of snapshots to obtain.
- `sort` (string) — optional
  Specifies the sort field for the requested snapshots. By default, the
snapshots are sorted by their timestamp.
- `start` (union oneOf) — optional
  Returns snapshots with timestamps after this time.
  One of: `string` or `number`

## Request body

`application/json`

- `desc` (boolean · default: false) — optional
  Refer to the description for the `desc` query parameter.
- `end` (union) — optional
  Refer to the description for the `end` query parameter.
- `page` (object) — optional
  - `from` (number · default: 0) — optional
    Skips the specified number of items.
  - `size` (number · default: 10000) — optional
    Specifies the maximum number of items to obtain.
- `sort` (string) — optional
  Refer to the description for the `sort` query parameter.
- `start` (union) — optional
  Refer to the description for the `start` query parameter.

## Response

`application/json`

- `count` (number)
- `model_snapshots` (object[])
  - `description` (string)
    An optional description of the job.
  - `job_id` (string)
    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` (object)
    Summary information describing the model.
    - `bucket_allocation_failures_count` (number)
    - `job_id` (string)
    - `log_time` (union)
    - `memory_status` (enum)
      Values: `ok`, `soft_limit`, `hard_limit`
    - `model_bytes` (number | string)
    - `model_bytes_exceeded` (number | string)
    - `model_bytes_memory_limit` (number | string)
    - `output_memory_allocator_bytes` (number | string)
    - `peak_model_bytes` (number | string)
    - `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)
      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)
    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/high_sum_total_sales/model_snapshots
{
  "start": "1575402236000"
}
```

#### JavaScript

```javascript
const response = await client.ml.getModelSnapshots({
  job_id: "high_sum_total_sales",
  start: 1575402236000,
});
```

#### Python

```python
resp = client.ml.get_model_snapshots(
    job_id="high_sum_total_sales",
    start="1575402236000",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_ml/anomaly_detectors/high_sum_total_sales/model_snapshots" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "start": "1575402236000"
  }'
```

#### Java

```java
client.ml().getModelSnapshots(g -> g
    .jobId("high_sum_total_sales")
    .start(DateTime.of("1575402236000"))
);
```

#### C#

```c#
var response = await client.MachineLearning
    .GetModelSnapshotsAsync(new GetModelSnapshotsRequest()
    {
        JobId = "high_sum_total_sales",
        Start = DateTimeOffset.Parse("2019-12-03T19:43:56.0000000+00:00", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind)
    });
```

#### PHP

```php
$resp = $client->ml()->getModelSnapshots([
    "job_id" => "high_sum_total_sales",
    "body" => [
        "start" => "1575402236000",
    ],
]);
```

#### Ruby

```ruby
response = client.ml.get_model_snapshots(
  job_id: "high_sum_total_sales",
  body: {
    "start": "1575402236000"
  }
)
```

