# Delete index pattern

**URL:** <https://discuss.elastic.co/t/delete-index-pattern/293987>\
**Category:** Kibana\
**Created:** [January 11, 2022, 8:20am UTC](https://discuss.elastic.co/t/delete-index-pattern/293987 "2022-01-11T08:20:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunny3794.ad](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@sunny3794.ad](https://discuss.elastic.co/u/sunny3794.ad)\
**Post date:** [January 11, 2022, 8:20am UTC](https://discuss.elastic.co/t/delete-index-pattern/293987/1 "2022-01-11T08:20:31Z")

</div>

I am trying to automate the deletion of index patterns whenever the index is deleted. For this I am using the requests module in Python to send the delete request to the Kibana API enpoint. However, the request fails when I try to use the index pattern name but succeeds when I use the \_id of the index pattern. Is there any way to use the index pattern name to delete the index patterns using the Kibana API?

---

<div class="post-metadata">

**Author:** ![flash1293](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/flash1293/32/41227_2.png) [@flash1293](https://discuss.elastic.co/u/flash1293)\
**Post date:** [January 11, 2022, 8:53am UTC](https://discuss.elastic.co/t/delete-index-pattern/293987/2 "2022-01-11T08:53:25Z")

</div>

You need the id to delete the index pattern, the name alone won't be enough. What you could do is to use the find api to look up the id: [Find objects API | Kibana Guide [7.16] | Elastic](https://www.elastic.co/guide/en/kibana/7.16/saved-objects-api-find.html) , then call delete with the id

If you are also creating the index patterns programatically, you could make the id and the pattern identical to save this step

---

<div class="post-metadata">

**Author:** ![sunny3794.ad](https://avatars.discourse-cdn.com/v4/letter/s/c89c15/32.png) [@sunny3794.ad](https://discuss.elastic.co/u/sunny3794.ad)\
**Post date:** [January 11, 2022, 8:57am UTC](https://discuss.elastic.co/t/delete-index-pattern/293987/3 "2022-01-11T08:57:33Z")

</div>

Thank you so much Joe. Yes, I am creating the index patterns programmatically so having the id be the same as the pattern name will help save a lot of work. Thanks a lot.

---

<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:** [February 8, 2022, 8:58am UTC](https://discuss.elastic.co/t/delete-index-pattern/293987/4 "2022-02-08T08:58:15Z")

</div>

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