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

# Get model snapshots info


Availability: 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`

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

#### Path Parameters

- `job_id` (string Id)
  Identifier for the anomaly detection job.
- `snapshot_id` (string Id) — 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.

## Description

## Required authorization

* Cluster privileges: `monitor_ml`

## Query String Parameters

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

## Request Body

`application/json`

- `desc` (boolean · default: false) — optional
  Refer to the description for the `desc` query parameter.
- `end` (DateTime) — optional
  Refer to the description for the `end` query parameter.
- `page` ({} Page) — 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 Field) — optional
  Refer to the description for the `sort` query parameter.
- `start` (DateTime) — optional
  Refer to the description for the `start` query parameter.

## Response

`application/json`

- `count` (number)
- `model_snapshots` ([] 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/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"
  }
)
```

