---
type: api
title: Clear the privileges cache
description: Evict privileges from the native application privilege cache.
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/v9/operation/operation-security-clear-cached-privileges
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/v9/operation/operation-security-clear-cached-privileges
products:
  - Elasticsearch
---

# Clear the privileges cache

Authentication: required

Availability: Generally available since 7.9

## Paths

- `POST` `/_security/privilege/{application}/_clear_cache`

#### Path parameters

- `application` (union string | string[]) — required
  A comma-separated list of applications.
To clear all applications, use an asterism (`*`).
It does not support other wildcard patterns.

## Description

Evict privileges from the native application privilege cache.
The cache is also automatically cleared for applications that have their privileges updated.

## Required authorization

- Cluster privileges: `manage_security`

## Response

`application/json`

- `_nodes` (object)
  - `failures` (object[])
    - `type` (string)
      The type of error
    - `reason` (union string) — nullable
      A human-readable explanation of the error, in English.
      One of: `string`
    - `stack_trace` (string)
      The server stack trace. Present only if the `error_trace=true` parameter was sent with the request.
    - `caused_by` (object) — recursive
      Same fields as `failures` in `_nodes`
    - `root_cause` (object[]) — recursive
      Same fields as `failures` in `_nodes`
    - `suppressed` (object[]) — recursive
      Same fields as `failures` in `_nodes`
  - `total` (number)
    Total number of nodes selected by the request.
  - `successful` (number)
    Number of nodes that responded successfully to the request.
  - `failed` (number)
    Number of nodes that rejected the request or failed to respond. If this value is not 0, a reason for the rejection or failure is included in the response.
- `cluster_name` (string)
- `nodes` (map string to object)
  Map values (object)
  - `name` (string)
## Code examples

#### Console

```console
POST /_security/privilege/myapp/_clear_cache
```

#### JavaScript

```javascript
const response = await client.security.clearCachedPrivileges({
  application: "myapp",
});
```

#### Python

```python
resp = client.security.clear_cached_privileges(
    application="myapp",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_security/privilege/myapp/_clear_cache" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.security().clearCachedPrivileges(c -> c
    .application("myapp")
);
```

#### C#

```c#
var response = await client.Security.ClearCachedPrivilegesAsync(application: new[] { "myapp" });
```

#### PHP

```php
$resp = $client->security()->clearCachedPrivileges([
    "application" => "myapp",
]);
```

#### Ruby

```ruby
response = client.security.clear_cached_privileges(
  application: "myapp"
)
```

## Response examples

#### 200

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "_nodes": {
    "failures": [
      {
        "type": "string",
        "reason": "string",
        "stack_trace": "string",
        "caused_by": {
          "type": "string",
          "reason": "string",
          "stack_trace": "string",
          "caused_by": {
            "type": "string",
            "stack_trace": "string"
          },
          "root_cause": [],
          "suppressed": []
        },
        "root_cause": [
          {
            "type": "string",
            "stack_trace": "string"
          }
        ],
        "suppressed": [
          {
            "type": "string",
            "stack_trace": "string"
          }
        ]
      }
    ],
    "total": 0,
    "successful": 0,
    "failed": 0
  },
  "cluster_name": "string",
  "nodes": {
    "key": {
      "name": "string"
    }
  }
}
```

