Delete roles API

Delete roles API

New API reference

For the most up-to-date API details, refer to Security APIs.

Removes roles in the native realm.

Request

DELETE /_security/role/<name>

Prerequisites

  • To use this API, you must have at least the manage_security cluster privilege.

Description

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.

Path parameters

name

(string) The name of the role.

Examples

The following example deletes a my_admin_role role:

  1. resp = client.security.delete_role(
  2. name="my_admin_role",
  3. )
  4. print(resp)
  1. const response = await client.security.deleteRole({
  2. name: "my_admin_role",
  3. });
  4. console.log(response);
  1. DELETE /_security/role/my_admin_role

If the role is successfully deleted, the request returns {"found": true}. Otherwise, found is set to false.

  1. {
  2. "found" : true
  3. }