2018-08-17 12:18:08 -04:00
[role="xpack"]
[[security-api-delete-role]]
=== Delete roles API
2018-12-20 13:23:28 -05:00
++++
<titleabbrev>Delete roles</titleabbrev>
++++
2018-08-17 12:18:08 -04:00
Removes roles in the native realm.
2019-08-02 13:56:05 -04:00
[[security-api-delete-role-request]]
==== {api-request-title}
2018-08-17 12:18:08 -04:00
2018-12-11 04:13:10 -05:00
`DELETE /_security/role/<name>`
2018-08-17 12:18:08 -04:00
2019-08-02 13:56:05 -04:00
[[security-api-delete-role-prereqs]]
==== {api-prereq-title}
* To use this API, you must have at least the `manage_security` cluster privilege.
[[security-api-delete-role-desc]]
==== {api-description-title}
2018-08-17 12:18:08 -04:00
2019-09-25 06:52:05 -04:00
The role management APIs are generally the preferred way to manage roles, rather than using
{stack-ov}/defining-roles.html#roles-management-file[file-based role management]. The delete roles API cannot remove roles that are defined in roles files.
2018-08-17 12:18:08 -04:00
2019-08-02 13:56:05 -04:00
[[security-api-delete-role-path-params]]
==== {api-path-parms-title}
2018-08-17 12:18:08 -04:00
`name`::
(string) The name of the role.
2019-08-02 13:56:05 -04:00
[[security-api-delete-role-example]]
==== {api-examples-title}
2018-08-17 12:18:08 -04:00
The following example deletes a `my_admin_role` role:
2019-09-05 14:12:39 -04:00
[source,console]
2018-08-17 12:18:08 -04:00
--------------------------------------------------
2018-12-11 04:13:10 -05:00
DELETE /_security/role/my_admin_role
2018-08-17 12:18:08 -04:00
--------------------------------------------------
// TEST[setup:admin_role]
If the role is successfully deleted, the request returns `{"found": true}`.
Otherwise, `found` is set to false.
2019-09-05 14:12:39 -04:00
[source,console-result]
2018-08-17 12:18:08 -04:00
--------------------------------------------------
{
"found" : true
}
--------------------------------------------------