Bulk create or update roles

  • POST /_security/role
Auth

The role management APIs are generally the preferred way to manage roles, rather than using file-based role management. The bulk create or update roles API cannot update roles that are defined in roles files.

Required privileges

Cluster privileges manage_security

Query parameters

refresh enum

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

Request body

roles map string to object required

A dictionary of role name to RoleDescriptor objects to add or update

<string> object
cluster union anyOf[]

A list of cluster privileges. These privileges define the cluster level actions that API keys are able to execute.

Values: all cancel_task create_snapshot cross_cluster_replication cross_cluster_search delegate_pki grant_api_key manage manage_api_key manage_autoscaling manage_behavioral_analytics manage_ccr
metadata object

Optional meta-data. Within the metadata object, keys that begin with _ are reserved for system usage.

run_as string[]

A list of users that the API keys can impersonate. NOTE: In Elastic Cloud Serverless, the run-as feature is disabled. For API compatibility, you can still specify an empty run_as field, but a non-empty list will be rejected.

description string

Optional description of the role descriptor

transient_metadata map string to object

Response

application/json
created string[]

Array of created roles

updated string[]

Array of updated roles

noop string[]

Array of role names without any changes