---
type: api
title: Delete roles
description: Delete roles in the native realm.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-security-delete-role
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-security-delete-role
products:
  - Elasticsearch
---

# Delete roles

Availability:

## Paths

- `DELETE` `/_security/role/{name}`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#bearerauth)

#### Path Parameters

- `name` (string Name)
  The name of the role.

## Description

Delete roles in the native realm.
The role management APIs are generally the preferred way to manage roles, rather than using file-based role management.
The delete roles API cannot remove roles that are defined in roles files.

## Required authorization

* Cluster privileges: `manage_security`

## Query String Parameters

- `refresh` (enum Refresh)
  If `true` (the default) then refresh the affected shards to make this operation visible to search, if `wait_for` then wait for a refresh to make this operation visible to search, if `false` then do nothing with refreshes.
  Values: `true`, `false`, `wait_for`

## Response

`application/json`

- `found` (boolean)
  If the role is successfully deleted, `found` is `true`.
Otherwise, `found` is `false`.
## Code Examples

#### Console

```console
DELETE /_security/role/my_admin_role
```

#### JavaScript

```javascript
const response = await client.security.deleteRole({
  name: "my_admin_role",
});
```

#### Python

```python
resp = client.security.delete_role(
    name="my_admin_role",
)
```

#### curl

```curl
curl -X DELETE "$ELASTICSEARCH_URL/_security/role/my_admin_role" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.security().deleteRole(d -> d
    .name("my_admin_role")
);
```

#### C#

```c#
var response = await client.Security.DeleteRoleAsync(name: "my_admin_role");
```

#### PHP

```php
$resp = $client->security()->deleteRole([
    "name" => "my_admin_role",
]);
```

#### Ruby

```ruby
response = client.security.delete_role(
  name: "my_admin_role"
)
```

## Response Examples

#### Security delete role response example1

A successful response from `DELETE /_security/role/my_admin_role`. If the role is successfully deleted, `found` is set to `true`.

```json
{
  "found" : true
}
```

