# /\_security/api\_key - disable / enable

**URL:** https://discuss.elastic.co/t/security-api-key-disable-enable/280755
**Category:** Elasticsearch
**Tags:** elastic-stack-security
**Created:** [August 9, 2021, 3:00am UTC](https://discuss.elastic.co/t/security-api-key-disable-enable/280755 "2021-08-09T03:00:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![byteandbit](https://avatars.discourse-cdn.com/v4/letter/b/f05b48/32.png) [@byteandbit](https://discuss.elastic.co/u/byteandbit)
#### Post date: [August 9, 2021, 3:00am UTC](https://discuss.elastic.co/t/security-api-key-disable-enable/280755/1 "2021-08-09T03:00:36Z")

</div>

Hey,

Just wondering if after creating API Key (/\_security/api\_key) there is a way to disable/enable it without invalidation?

---

<div class="post-metadata">

### Author: ![Yang\_Wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yang_wang/32/48857_2.png) [@Yang\_Wang](https://discuss.elastic.co/u/Yang_Wang)
#### Post date: [August 9, 2021, 4:06am UTC](https://discuss.elastic.co/t/security-api-key-disable-enable/280755/2 "2021-08-09T04:06:54Z")

</div>

The other option is to configure the API key to [expire](https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-create-api-key.html#security-api-create-api-key-request-body) after some fixed amount of time at creation time.

---

<div class="post-metadata">

### Author: ![byteandbit](https://avatars.discourse-cdn.com/v4/letter/b/f05b48/32.png) [@byteandbit](https://discuss.elastic.co/u/byteandbit)
#### Post date: [August 9, 2021, 4:40am UTC](https://discuss.elastic.co/t/security-api-key-disable-enable/280755/3 "2021-08-09T04:40:39Z")

</div>

But I need to have the same ID before and after. Also enable/disable to be controlled by an event and not the clock.

---

<div class="post-metadata">

### Author: ![Yang\_Wang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yang_wang/32/48857_2.png) [@Yang\_Wang](https://discuss.elastic.co/u/Yang_Wang)
#### Post date: [August 9, 2021, 5:14am UTC](https://discuss.elastic.co/t/security-api-key-disable-enable/280755/4 "2021-08-09T05:14:19Z")

</div>

> [@byteandbit](#):
>
> But I need to have the same ID before and after.

I don't quite understand what this means.

> Also enable/disable to be controlled by an event and not the clock.

If expiration is not time based, you must actively invalidate the API key. What kinda event are we talking about here? Is it external to elasticsearch?

---

<div class="post-metadata">

### Author: ![TimV](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/timv/32/13162_2.png) [@TimV](https://discuss.elastic.co/u/TimV)
#### Post date: [August 9, 2021, 5:22am UTC](https://discuss.elastic.co/t/security-api-key-disable-enable/280755/5 "2021-08-09T05:22:17Z")

</div>

No, it is not possible to disable and then re-enable an API Key.

Once it is invalidated it cannot be resurrected, and the only option is to create a new API Key.

---

<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: [September 6, 2021, 5:23am UTC](https://discuss.elastic.co/t/security-api-key-disable-enable/280755/6 "2021-09-06T05:23:00Z")

</div>

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