---
type: api
title: Get lifecycle policies
description: **All methods and paths for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/operation/operation-ilm-get-lifecycle
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/operation/operation-ilm-get-lifecycle
products:
  - Elasticsearch
---

# Get lifecycle policies

Authentication: required

Availability: Generally available since 6.6

## Paths

- `GET` `/_ilm/policy/{policy}`
- `GET` `/_ilm/policy`

#### Path parameters

- `policy` (string) — optional, leave it out to use `/_ilm/policy`
  Identifier for the policy.

## Required authorization

- Cluster privileges: `manage_ilm`, `read_ilm`

## Query string parameters

- `master_timeout` (string · default: 30s) — optional
  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
  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)
  - `modified_date` (union oneOf)
    One of: `string` or `number`
  - `policy` (object)
    - `phases` (object)
      - `cold` (object)
        - `actions` (object)
          - `allocate` (object)
            Phases allowed: warm, cold.
            - `number_of_replicas` (number)
            - `total_shards_per_node` (number)
            - `include` (map string to string)
            - `exclude` (map string to string)
            - `require` (map string to string)
          - `delete` (object)
            Phases allowed: delete.
            - `delete_searchable_snapshot` (boolean)
          - `downsample` (object)
            Phases allowed: hot, warm, cold.
            - `fixed_interval` (string)
            - `wait_timeout` (string)
          - `freeze` (object) — deprecated
            The freeze action is a noop in 8.x
          - `forcemerge` (object)
            Phases allowed: hot, warm.
            - `max_num_segments` (number)
            - `index_codec` (string)
          - `migrate` (object)
            Phases allowed: warm, cold.
            - `enabled` (boolean)
          - `readonly` (object)
            Phases allowed: hot, warm, cold.
          - `rollover` (object)
            Phases allowed: hot.
            - `max_size` (number | string) — deprecated
              The `max_size` condition has been deprecated in 9.3.0 and `max_primary_shard_size` should be used instead
            - `max_primary_shard_size` (number | string)
            - `max_age` (string)
            - `max_docs` (number)
            - `max_primary_shard_docs` (number)
            - `min_size` (number | string)
            - `min_primary_shard_size` (number | string)
            - `min_age` (string)
            - `min_docs` (number)
            - `min_primary_shard_docs` (number)
          - `set_priority` (object)
            Phases allowed: hot, warm, cold.
            - `priority` (number)
          - `searchable_snapshot` (object)
            Phases allowed: hot, cold, frozen.
            - `snapshot_repository` (string)
            - `force_merge_index` (boolean)
            - `total_shards_per_node` (number)
              The maximum number of shards, including primaries and replicas, that can be allocated to any single node for the mounted index.
Must be at least 1.
            - `replicate_for` (string)
              The period for which the mounted index keeps one replica before the replica is removed.
By default, the index is mounted without replicas.
Must be positive.
Only the first `searchable_snapshot` action in a policy may set this.
It must fit before the next phase starts: for example, if this phase has a `min_age` of 5d and the next phase has 12d, it can be at most 7d.
          - `shrink` (object)
            Phases allowed: hot, warm.
            - `number_of_shards` (number)
            - `max_primary_shard_size` (number | string)
            - `allow_write_after_shrink` (boolean)
          - `unfollow` (object)
            Phases allowed: hot, warm, cold, frozen.
          - `wait_for_snapshot` (object)
            Phases allowed: delete.
            - `policy` (string)
        - `min_age` (string)
      - `delete` (object)
        Same fields as `cold` in `phases`
      - `frozen` (object)
        Same fields as `cold` in `phases`
      - `hot` (object)
        Same fields as `cold` in `phases`
      - `warm` (object)
        Same fields as `cold` in `phases`
    - `_meta` (object)
      Arbitrary metadata that is not automatically generated or used by Elasticsearch.
  - `version` (number)
## Code examples

#### Console

```console
GET _ilm/policy/my_policy
```

#### JavaScript

```javascript
const response = await client.ilm.getLifecycle({
  name: "my_policy",
});
```

#### Python

```python
resp = client.ilm.get_lifecycle(
    name="my_policy",
)
```

#### curl

```curl
curl -X GET "$ELASTICSEARCH_URL/_ilm/policy/my_policy" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.ilm().getLifecycle(g -> g
    .name("my_policy")
);
```

#### C#

```c#
var response = await client.IndexLifecycleManagement
    .GetLifecycleAsync(d1 => d1
        .Name("my_policy")
    );
```

#### PHP

```php
$resp = $client->ilm()->getLifecycle([
    "policy" => "my_policy",
]);
```

#### Ruby

```ruby
response = client.ilm.get_lifecycle(
  policy: "my_policy"
)
```

## Response examples

#### Get lifecycle response example1

`application/json`

A successful response when retrieving a lifecycle policy.

```json
{
  "my_policy": {
    "version": 1,
    "modified_date": 82392349,
    "policy": {
      "phases": {
        "warm": {
          "min_age": "10d",
          "actions": {
            "forcemerge": {
              "max_num_segments": 1
            }
          }
        },
        "delete": {
          "min_age": "30d",
          "actions": {
            "delete": {
              "delete_searchable_snapshot": true
            }
          }
        }
      }
    },
    "in_use_by" : {
      "indices" : [],
      "data_streams" : [],
      "composable_templates" : []
    }
  }
}
```

