---
type: api
title: Get all roles
description: Retrieve all Kibana roles.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v9/operation/operation-get-security-role
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v9/operation/operation-get-security-role
products:
  - Kibana
---

# Get all roles

- Server: `https://{kibana_url}`

## Paths

- `GET` `/api/security/role`

## Description

Retrieve all Kibana roles.

## Authentication

- Api key: `Authorization: <value>`
  These APIs use key-based authentication. You must create an API key and use the encoded value in the request header. For example: `Authorization: ApiKey base64AccessApiKey`
- Basic: `Authorization: Basic <credentials>`

## Query string parameters

- `replaceDeprecatedPrivileges` (boolean) — optional
  If `true` and the response contains any privileges that are associated with deprecated features, they are omitted in favor of details about the appropriate replacement feature privileges.

## Response

Indicates a successful call.

`application/json`

Type: `object[]`

An array; each item has these fields:

- `_transform_error` (object[])
  - `reason` (string)
    The reason the role could not be fully transformed.
  - `state` (object[])
    - `application` (string)
    - `privileges` (string[])
    - `resources` (string[])
- `_unrecognized_applications` (string[])
- `description` (string)
  A description for the role.
- `elasticsearch` (object)
  The Elasticsearch cluster, index, and remote cluster security privileges for the role.
  - `cluster` (string[] · max items: 100)
  - `indices` (object[] · max items: 1000)
    - `allow_restricted_indices` (boolean)
      Restricted indices are a special category of indices that are used internally to store configuration data and should not be directly accessed. Only internal system roles should normally grant privileges over the restricted indices. Toggling this flag is very strongly discouraged because it could effectively grant unrestricted operations on critical data, making the entire system unstable or leaking sensitive information. If for administrative purposes you need to create a role with privileges covering restricted indices, however, you can set this property to true. In that case, the names field covers the restricted indices too.
    - `field_security` (map string to string)
      Map values (string[] · max items: 1000)
    - `names` (string[] · min items: 1 · max items: 100)
    - `privileges` (string[] · min items: 1 · max items: 100)
    - `query` (string)
      A search query that defines the documents the role members have read access to. A document within the specified data streams and indices must match this query in order for it to be accessible by the role members.
  - `remote_cluster` (object[] · max items: 100)
    - `clusters` (string[] · min items: 1 · max items: 100)
    - `privileges` (string[] · min items: 1 · max items: 100)
  - `remote_indices` (object[] · max items: 1000)
    - `allow_restricted_indices` (boolean)
      Restricted indices are a special category of indices that are used internally to store configuration data and should not be directly accessed. Only internal system roles should normally grant privileges over the restricted indices. Toggling this flag is very strongly discouraged because it could effectively grant unrestricted operations on critical data, making the entire system unstable or leaking sensitive information. If for administrative purposes you need to create a role with privileges covering restricted indices, however, you can set this property to true. In that case, the names field will cover the restricted indices too.
    - `clusters` (string[] · min items: 1 · max items: 100)
    - `field_security` (map string to string)
      Map values (string[] · max items: 1000)
    - `names` (string[] · min items: 1 · max items: 100)
    - `privileges` (string[] · min items: 1 · max items: 100)
    - `query` (string)
      A search query that defines the documents the role members have read access to. A document within the specified data streams and indices must match this query in order for it to be accessible by the role members.
  - `run_as` (string[] · max items: 100)
- `kibana` (object[])
  - `_reserved` (string[])
  - `base` (string[])
  - `feature` (map string to string)
  - `spaces` (string[])
- `metadata` (map string to object)
- `name` (string)
  The role name.
- `transient_metadata` (map string to object)
## Code examples

#### Console

```console
GET kbn:/api/security/role
```

#### curl

```curl
curl -X GET "${KIBANA_URL}/api/security/role" \
  -H "Authorization: ApiKey ${API_KEY}"
```

## Response examples

#### Get all roles

```json
[
  {
    "_unrecognized_applications": [],
    "description": "My custom Kibana role.",
    "elasticsearch": {
      "cluster": [
        "monitor"
      ],
      "indices": [
        {
          "names": [
            "logs-*"
          ],
          "privileges": [
            "read"
          ]
        }
      ],
      "run_as": []
    },
    "kibana": [
      {
        "base": [
          "read"
        ],
        "feature": {},
        "spaces": [
          "default"
        ]
      }
    ],
    "metadata": {},
    "name": "my_kibana_role",
    "transient_metadata": {
      "enabled": true
    }
  }
]
```

#### Get all role details

```json
[
  {
    "name": "my_kibana_role",
    "description": "My kibana role description",
    "metadata": {
      "version": 1
    },
    "transient_metadata": {
      "enabled": true
    },
    "elasticsearch": {
      "indices": [],
      "cluster": [],
      "run_as": []
    },
    "kibana": [
      {
        "base": [
          "all"
        ],
        "feature": {},
        "spaces": [
          "*"
        ]
      }
    ]
  },
  {
    "name": "my_admin_role",
    "description": "My admin role description",
    "metadata": {
      "version": 1
    },
    "transient_metadata": {
      "enabled": true
    },
    "elasticsearch": {
      "cluster": [
        "all"
      ],
      "indices": [
        {
          "names": [
            "index1",
            "index2"
          ],
          "privileges": [
            "all"
          ],
          "field_security": {
            "grant": [
              "title",
              "body"
            ]
          },
          "query": "{\\\u0022match\\\u0022: {\\\u0022title\\\u0022: \\\u0022foo\\\u0022}}"
        }
      ]
    },
    "kibana": []
  }
]
```

