---
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/4493/api/doc/elasticsearch/operation/operation-security-delete-role-mapping
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/operation/operation-security-delete-role-mapping
products:
  - Elasticsearch
---

# Delete role mappings

Availability: Generally available since 5.5

## Paths

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

#### Path parameters

- `name` (string) — required
  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.

[About mapping users to roles](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/mapping-users-groups-to-roles)

## Required authorization

- Cluster privileges: `manage_security`

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)

## Query string parameters

- `refresh` (enum) — optional
  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
}
```

