Bulk delete roles
Added in 8.15.0
The role management APIs are generally the preferred way to manage roles, rather than using file-based role management. The bulk delete roles API cannot delete roles that are defined in roles files.
Query parameters
-
refresh
string If
true
(the default) then refresh the affected shards to make this operation visible to search, ifwait_for
then wait for a refresh to make this operation visible to search, iffalse
then do nothing with refreshes.Values are
true
,false
, orwait_for
.
DELETE
/_security/role
curl \
--request DELETE 'http://api.example.com/_security/role' \
--header "Authorization: $API_KEY" \
--header "Content-Type: application/json" \
--data '"{\n \"names\": [\"my_admin_role\", \"my_user_role\"]\n}"'
Request example
Run DELETE /_security/role` to delete `my_admin_role` and `my_user_role` roles.
{
"names": ["my_admin_role", "my_user_role"]
}
Response examples (200)
A successful response
A successful response from `DELETE /_security/role`.
{
"deleted": [
"my_admin_role",
"my_user_role"
]
}
A partially successful response from `DELETE /_security/role`. If a role cannot be found, it appears in the `not_found` list in the response.
{
"deleted": [
"my_admin_role"
],
"not_found": [
"not_an_existing_role"
]
}
A partially successful response from `DELETE /_security/role`. If part of a request fails or is invalid, the response includes `errors`.
{
"deleted": [
"my_admin_role"
],
"errors": {
"count": 1,
"details": {
"superuser": {
"type": "illegal_argument_exception",
"reason": "role [superuser] is reserved and cannot be deleted"
}
}
}
}