# How to add deletion phase in policy (POST does not seem to work)

**URL:** https://discuss.elastic.co/t/how-to-add-deletion-phase-in-policy-post-does-not-seem-to-work/329409
**Category:** Elasticsearch
**Tags:** ilm-index-lifecycle-management
**Created:** [April 5, 2023, 9:55am UTC](https://discuss.elastic.co/t/how-to-add-deletion-phase-in-policy-post-does-not-seem-to-work/329409 "2023-04-05T09:55:27Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Mark\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_s/32/98686_2.png) [@Mark\_S](https://discuss.elastic.co/u/Mark_S)
#### Post date: [April 5, 2023, 9:55am UTC](https://discuss.elastic.co/t/how-to-add-deletion-phase-in-policy-post-does-not-seem-to-work/329409/1 "2023-04-05T09:55:27Z")

</div>

I am trying to add a deletion phase in an existing policy. The policy works fine, creating new indices every day.  
However, I cannot add a deletion phase. Since this is not possible from the UI, I tried with a POST :

But this does not seem to work... Why are the PUT and POST rejected - is it not possible to update it, only to create a new one that includes the delete phase?

Here is the policy:

```auto
{
  "myindexpolicy" : {
    "version" : 1,
    "modified_date" : "2023-02-17T12:05:04.639Z",
    "policy" : {
      "phases" : {
        "hot" : {
          "min_age" : "0ms",
          "actions" : {
            "set_priority" : {
              "priority" : 100
            },
            "rollover" : {
              "max_primary_shard_size" : "1gb",
              "max_age" : "1d"
            }
          }
        }
      }
    },
    "in_use_by" : {
      "indices" : [
        "myindexalias-000008",
        "myindexalias-000009",
        "myindexalias-000015",
        "myindexalias-000004",
        "myindexalias-000016",
        "myindexalias-000005",
        "myindexalias-000006",
        "myindexalias-000017",
        "myindexalias-000007",
        "myindexalias-000011",
        "myindexalias-000012",
        "myindexalias-000013",
        "myindexalias-000002",
        "myindexalias-000003",
        "myindexalias-000014",
        "myindexalias-000010"
      ],
      "data_streams" : [],
      "composable_templates" : [
        "mts_template"
      ]
    }
  }
}

```

And here is the POST (also tried PUT)

```auto
POST /_ilm/policy/myindexpolicy/_update
{
  "policy": {
    "phases": {
      "delete": {
        "min_age": "30d",
        "actions": {
          "delete": {}
        }
      }
    }
  }
}

```

Here is the error message:

```auto
{
  "error" : {
    "root_cause" : [
      {
        "type" : "x_content_parse_exception",
        "reason" : "[2:3] [UpdateRequest] unknown field [policy]"
      }
    ],
    "type" : "x_content_parse_exception",
    "reason" : "[2:3] [UpdateRequest] unknown field [policy]"
  },
  "status" : 400
}

```

PUT gives

```auto
 "error" : "Incorrect HTTP method for uri [/_ilm/policy/myindexpolicy/_update?pretty=true] and method [PUT], allowed: [POST]",
  "status" : 405

```

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [April 10, 2023, 3:39pm UTC](https://discuss.elastic.co/t/how-to-add-deletion-phase-in-policy-post-does-not-seem-to-work/329409/2 "2023-04-10T15:39:32Z")

</div>

@Mark_S

There is no `_update` directive for ILM API for create, [create and update are the same](https://www.elastic.co/guide/en/elasticsearch/reference/current/ilm-put-lifecycle.html) although it will version the ILM Polocy

You simply `PUT` a complete new policy, there is no partial update, there is no `POST` with `_update`

> [@Mark\_S](#):
>
> Since this is not possible from the UI,

You should be... it is easy to miss but you need to select the little Trashcan symbol on the right hand side

 ![Screenshot 2023-04-10 at 8.41.22 AM](https://us1.discourse-cdn.com/elastic/original/3X/a/7/a719c76b222b289b10035c0aeb26778b78caf687.png)

---

<div class="post-metadata">

### Author: ![Mark\_S](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_s/32/98686_2.png) [@Mark\_S](https://discuss.elastic.co/u/Mark_S)
#### Post date: [April 11, 2023, 6:53am UTC](https://discuss.elastic.co/t/how-to-add-deletion-phase-in-policy-post-does-not-seem-to-work/329409/3 "2023-04-11T06:53:07Z")

</div>

@stephenb : Thank you!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [May 9, 2023, 6:53am UTC](https://discuss.elastic.co/t/how-to-add-deletion-phase-in-policy-post-does-not-seem-to-work/329409/4 "2023-05-09T06:53:13Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
