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

# Get lifecycle policies


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`

## 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/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)

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

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" : []
    }
  }
}
```

