Clear API key cache API
Evicts a subset of all entries from the API key cache. The cache is also automatically cleared on state changes of the security index.
Request
POST /_security/api_key/<ids>/_clear_cache
Prerequisites
- To use this API, you must have at least the
manage_securitycluster privilege.
Description
For more information about API keys, see Create API keys, Get API key information, and Invalidate API key.
Path parameters
-
<ids> - (Required, string) Comma-separated list of API key IDs to evict from the API key cache. To evict all API keys, use
*. Does not support other wildcard patterns.
Examples
The clear API key cache API evicts entries from the API key cache. For example, to clear the entry of API key with ID yVGMr3QByxdh1MSaicYx.
resp = client.security.clear_api_key_cache(
ids="yVGMr3QByxdh1MSaicYx",
)
print(resp) const response = await client.security.clearApiKeyCache({
ids: "yVGMr3QByxdh1MSaicYx",
});
console.log(response); POST /_security/api_key/yVGMr3QByxdh1MSaicYx/_clear_cache
Specify multiple API keys as a comma-separated list.
resp = client.security.clear_api_key_cache(
ids="yVGMr3QByxdh1MSaicYx,YoiMaqREw0YVpjn40iMg",
)
print(resp) const response = await client.security.clearApiKeyCache({
ids: "yVGMr3QByxdh1MSaicYx,YoiMaqREw0YVpjn40iMg",
});
console.log(response); POST /_security/api_key/yVGMr3QByxdh1MSaicYx,YoiMaqREw0YVpjn40iMg/_clear_cache
To clear all entries from the API key cache, use *.
resp = client.security.clear_api_key_cache(
ids="*",
)
print(resp) const response = await client.security.clearApiKeyCache({
ids: "*",
});
console.log(response); POST /_security/api_key/*/_clear_cache
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/security-api-clear-api-key-cache.html