---
type: api
title: Delete role mappings
description: Role mappings define which roles are assigned to each user.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-security-delete-role-mapping
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-security-delete-role-mapping
products:
  - Elasticsearch
---

# Delete role mappings

Availability: 5.5+

## Paths

- `DELETE` `/_security/role_mapping/{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 distinct name that identifies the role mapping.
The name is used solely as an identifier to facilitate interaction via the API; it does not affect the behavior of the mapping in any way.

## Description

Role mappings define which roles are assigned to each user.
The role mapping APIs are generally the preferred way to manage role mappings rather than using role mapping files.
The delete role mappings API cannot remove role mappings that are defined in role mapping files.

## Required authorization

* Cluster privileges: `manage_security`

[Read the reference documentation](https://www.elastic.co/guide/en/elasticsearch/reference/8.19/mapping-roles.html)

## 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 mapping is successfully deleted, `found` is `true`.
Otherwise, `found` is `false`.
## Code Examples

#### Console

```console
DELETE /_security/role_mapping/mapping1
```

#### JavaScript

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

#### Python

```python
resp = client.security.delete_role_mapping(
    name="mapping1",
)
```

#### curl

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

#### Java

```java
client.security().deleteRoleMapping(d -> d
    .name("mapping1")
);
```

#### C#

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

#### PHP

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

#### Ruby

```ruby
response = client.security.delete_role_mapping(
  name: "mapping1"
)
```

## Response Examples

#### Security delete role mapping response example1

A successful response from `DELETE /_security/role_mapping/mapping1`. If the mapping is successfully deleted, `found` is `true`.

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

