Type to search.

Find roles with a query

  • POST also GET /_security/_query/role
Auth

Get roles in a paginated manner. The role management APIs are generally the preferred way to manage roles, rather than using file-based role management. The query roles API does not retrieve roles that are defined in roles files, nor built-in ones. You can optionally filter the results with a query. Also, the results can be paginated and sorted.

Required privileges

Cluster privileges read_security

Request body

from number · default: 0

The starting document offset. It must not be negative. By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.

size number · default: 10

The number of hits to return. It must not be negative. By default, you cannot page through more than 10,000 hits using the from and size parameters. To page through more hits, use the search_after parameter.

search_after union[]

The search after definition.

Response

application/json
total number required

The total number of roles found.

count number required

The number of roles returned in the response.

roles object[] required

A list of roles that match the query. The returned role format is an extension of the role definition format. It adds the transient_metadata.enabled and the _sort fields. transient_metadata.enabled is set to false in case the role is automatically disabled, for example when the role grants privileges that are not allowed by the installed license. _sort is present when the search query sorts on some field. It contains the array of values that have been used for sorting.

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 manage manage_api_key manage_behavioral_analytics manage_enrich manage_esql manage_index_templates manage_inference manage_ingest_pipelines manage_logstash_pipelines manage_ml
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
_sort union[]
name string required

Name of the role.