Clear roles cache API
Evicts roles from the native role cache.
Request
POST /_security/role/<roles>/_clear_cache
Prerequisites
- To use this API, you must have at least the
manage_securitycluster privilege.
Description
For more information about the native realm, see Realms and Native user authentication.
Path parameters
-
<roles> - (Required, string) Comma-separated list of roles to evict from the role cache. To evict all roles, use
*. Does not support other wildcard patterns.
Examples
The clear roles cache API evicts roles from the native role cache. For example, to clear the cache for my_admin_role:
resp = client.security.clear_cached_roles(
name="my_admin_role",
)
print(resp) const response = await client.security.clearCachedRoles({
name: "my_admin_role",
});
console.log(response); POST /_security/role/my_admin_role/_clear_cache
Specify multiple roles as a comma-separated list.
resp = client.security.clear_cached_roles(
name="my_admin_role,my_test_role",
)
print(resp) const response = await client.security.clearCachedRoles({
name: "my_admin_role,my_test_role",
});
console.log(response); POST /_security/role/my_admin_role,my_test_role/_clear_cache
To clear all roles from the cache, use *.
resp = client.security.clear_cached_roles(
name="*",
)
print(resp) const response = await client.security.clearCachedRoles({
name: "*",
});
console.log(response); POST /_security/role/*/_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-role-cache.html