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

# Get model snapshots info

Authentication: required

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`

## 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 oneOf) — optional
  Refer to the description for the `end` query parameter.
  One of: `string` or `number`
- `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 oneOf) — optional
  Refer to the description for the `start` query parameter.
  One of: `string` or `number`

## 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 oneOf)
      One of: `string` or `number`
    - `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"
  }
)
```

## Response examples

#### 200

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "count": 0,
  "model_snapshots": [
    {
      "description": "string",
      "job_id": "string",
      "latest_record_time_stamp": 0,
      "latest_result_time_stamp": 0,
      "min_version": "string",
      "model_size_stats": {
        "bucket_allocation_failures_count": 0,
        "job_id": "string",
        "log_time": "string",
        "memory_status": "ok",
        "model_bytes": "string",
        "model_bytes_exceeded": "string",
        "model_bytes_memory_limit": "string",
        "output_memory_allocator_bytes": "string",
        "peak_model_bytes": "string",
        "assignment_memory_basis": "string",
        "result_type": "string",
        "total_by_field_count": 0,
        "total_over_field_count": 0,
        "total_partition_field_count": 0,
        "categorization_status": "ok",
        "categorized_doc_count": 0,
        "dead_category_count": 0,
        "failed_category_count": 0,
        "frequent_category_count": 0,
        "rare_category_count": 0,
        "total_category_count": 0,
        "timestamp": 0
      },
      "retain": false,
      "snapshot_doc_count": 0,
      "snapshot_id": "string",
      "timestamp": 0
    }
  ]
}
```

