# Invalidated / Expired API Keys not being cleaned up

**URL:** https://discuss.elastic.co/t/invalidated-expired-api-keys-not-being-cleaned-up/353806
**Category:** Elasticsearch
**Created:** [February 21, 2024, 3:56pm UTC](https://discuss.elastic.co/t/invalidated-expired-api-keys-not-being-cleaned-up/353806 "2024-02-21T15:56:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Masok](https://avatars.discourse-cdn.com/v4/letter/m/b4bc9f/32.png) [@Masok](https://discuss.elastic.co/u/Masok)
#### Post date: [February 21, 2024, 3:56pm UTC](https://discuss.elastic.co/t/invalidated-expired-api-keys-not-being-cleaned-up/353806/1 "2024-02-21T15:56:57Z")

</div>

Hi

Our use case requires us to utilise short(ish) lived API Keys. After reading the documentation I was under the impression that expired / invalidated API Keys would be automatically deleted after a period of time (I think it is 7 days?). However when I looked into the .security index I discovered more the 30000 API Keys (some with quite complex role descriptors) dating back 7 months.

We are using the Elasticsearch Managed Service (8.11.1) hosted on AWS.

Can anyone shed some light on why the API Keys wouldn't be automatically cleaned up?

Thanks

---

<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: [March 20, 2024, 3:57pm UTC](https://discuss.elastic.co/t/invalidated-expired-api-keys-not-being-cleaned-up/353806/2 "2024-03-20T15:57:31Z")

</div>

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