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

# Get policy information


Availability: Generally available since 7.4

## Paths

- `GET` `/_slm/policy/{policy_id}`
- `GET` `/_slm/policy`

#### Path parameters

- `policy_id` (union string | string[]) — optional, leave it out to use `/_slm/policy`
  A comma-separated list of snapshot lifecycle policy identifiers.

## Description

Get snapshot lifecycle policy definitions and information about the latest snapshot attempts.

## Required authorization

- Cluster privileges: `manage_slm`

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

- `master_timeout` (string · default: 30s) — optional
  The period to wait for a connection to the master node.
If no response is received before the timeout expires, the request fails and returns an error.
- `timeout` (string · default: 30s) — optional
  The period to wait for a response.
If no response is received before the timeout expires, the request fails and returns an error.

## Response

`application/json`

- `<string>` (object)
  - `in_progress` (object)
    - `name` (string)
    - `start_time_millis` (number)
    - `state` (string)
    - `uuid` (string)
  - `last_failure` (object)
    - `snapshot_name` (string)
    - `time` (union)
  - `last_success` (object)
    - `snapshot_name` (string)
    - `time` (union)
  - `modified_date` (union)
    The last time the policy was modified.
  - `modified_date_millis` (number)
  - `next_execution` (union)
    The next time the policy will run.
  - `next_execution_millis` (number)
  - `policy` (object)
    - `config` (object)
      - `ignore_unavailable` (boolean · default: false)
        If false, the snapshot fails if any data stream or index in indices is missing or closed. If true, the snapshot ignores missing or closed data streams and indices.
      - `indices` (string)
        A comma-separated list of data streams and indices to include in the snapshot. Multi-index syntax is supported.
By default, a snapshot includes all data streams and indices in the cluster. If this argument is provided, the snapshot only includes the specified data streams and clusters.
      - `include_global_state` (boolean · default: true)
        If true, the current global state is included in the snapshot.
      - `feature_states` (string[])
        A list of feature states to be included in this snapshot. A list of features available for inclusion in the snapshot and their descriptions be can be retrieved using the get features API.
Each feature state includes one or more system indices containing data necessary for the function of that feature. Providing an empty array will include no feature states in the snapshot, regardless of the value of include_global_state. By default, all available feature states will be included in the snapshot if include_global_state is true, or no feature states if include_global_state is false.
      - `metadata` (object)
        Attaches arbitrary metadata to the snapshot, such as a record of who took the snapshot, why it was taken, or any other useful data. Metadata must be less than 1024 bytes.
      - `partial` (boolean · default: false)
        If false, the entire snapshot will fail if one or more indices included in the snapshot do not have all primary shards available.
    - `name` (string)
    - `repository` (string)
    - `retention` (object)
      - `expire_after` (string)
        Time period after which a snapshot is considered expired and eligible for deletion. SLM deletes expired snapshots based on the slm.retention_schedule.
      - `max_count` (number)
        Maximum number of snapshots to retain, even if the snapshots have not yet expired. If the number of snapshots in the repository exceeds this limit, the policy retains the most recent snapshots and deletes older snapshots.
      - `min_count` (number)
        Minimum number of snapshots to retain, even if the snapshots have expired.
    - `schedule` (string)
  - `version` (number)
    The version of the snapshot policy.
Only the latest version is stored and incremented when the policy is updated.
  - `stats` (object)
    - `retention_deletion_time` (string)
    - `retention_deletion_time_millis` (number)
    - `retention_failed` (number)
    - `retention_runs` (number)
    - `retention_timed_out` (number)
    - `policy` (string)
    - `total_snapshots_deleted` (number)
    - `total_snapshot_deletion_failures` (number)
    - `total_snapshots_failed` (number)
    - `total_snapshots_taken` (number)
## Code examples

#### Console

```console
GET _slm/policy/daily-snapshots?human
```

#### JavaScript

```javascript
const response = await client.slm.getLifecycle({
  policy_id: "daily-snapshots",
  human: "true",
});
```

#### Python

```python
resp = client.slm.get_lifecycle(
    policy_id="daily-snapshots",
    human=True,
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_slm/policy/daily-snapshots?human" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java

```

#### C#

```c#
var response = await client.SnapshotLifecycleManagement
    .GetLifecycleAsync(d1 => d1
        .PolicyId(new[] { "daily-snapshots" })
    );
```

#### PHP

```php
$resp = $client->slm()->getLifecycle([
    "policy_id" => "daily-snapshots",
    "human" => "true",
]);
```

#### Ruby

```ruby
response = client.slm.get_lifecycle(
  policy_id: "daily-snapshots",
  human: "true"
)
```

## Response examples

#### Get snapshot lifecycle response example1

A successful response from `GET _slm/policy/daily-snapshots?human`.

```json
{
  "daily-snapshots": {
    "version": 1,
    "modified_date": "2099-05-06T01:30:00.000Z",
    "modified_date_millis": 4081757400000,
    "policy" : {
      "schedule": "0 30 1 * * ?",
      "name": "<daily-snap-{now/d}>",
      "repository": "my_repository",
      "config": {
        "indices": ["data-*", "important"],
        "ignore_unavailable": false,
        "include_global_state": false
      },
      "retention": {
        "expire_after": "30d",
        "min_count": 5,
        "max_count": 50
      }
    },
    "stats": {
      "policy": "daily-snapshots",
      "snapshots_taken": 0,
      "snapshots_failed": 0,
      "snapshots_deleted": 0,
      "snapshot_deletion_failures": 0
    },
    "next_execution": "2099-05-07T01:30:00.000Z",
    "next_execution_millis": 4081843800000
  }
}
```

