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

# Get all roles

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

## Paths

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

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v9/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v9/authentication#basicauth)

## Description

Retrieve all Kibana roles.

## Query String Parameters

- `replaceDeprecatedPrivileges` (boolean)
  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`

- `_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` ({})
  The Elasticsearch cluster, index, and remote cluster security privileges for the role.
  - `cluster` ([] string · max: 100)
  - `indices` ([] object · max: 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)
    - `names` ([] string · min: 1 · max: 100)
    - `privileges` ([] string · min: 1 · max: 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: 100)
    - `clusters` ([] string · min: 1 · max: 100)
    - `privileges` ([] string · min: 1 · max: 100)
  - `remote_indices` ([] object · max: 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: 1 · max: 100)
    - `field_security` (map string to string)
    - `names` ([] string · min: 1 · max: 100)
    - `privileges` ([] string · min: 1 · max: 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: 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 /api/security/role
```

#### curl

```curl
curl -X GET "https://{kibana_url}/api/security/role"
```

## 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": []
  }
]
```

