---
type: api
title: Get roles for an Elasticsearch project
description: Retrieve the custom roles defined for an Elasticsearch project.
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/cloud-serverless/operation/operation-getelasticsearchprojectroles
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/cloud-serverless/operation/operation-getelasticsearchprojectroles
products:
  - Elastic Cloud Serverless
---

# Get roles for an Elasticsearch project

Authentication: required

- Server: `https://api.elastic-cloud.com`

## Paths

- `GET` `/api/v1/serverless/projects/elasticsearch/{id}/roles`

#### Path parameters

- `id` (string · pattern: ^[a-z0-9]{32}$) — required
  The ID of the project

## Description

Retrieve the custom roles defined for an Elasticsearch project.

## Responses

#### `200`

The requested roles

`application/json`

- `<string>` (object)
  - `roles` (object[])
    - `name` (string)
      A role name for a particular project
    - `description` (string)
      A role description for a particular role
##### Response headers

- `ETag` (string)

#### `404`

Not Found

`application/json`

- `errors` (object[])
  - `message` (string)
    A human-readable message of the error.
  - `code` (string)
    An identifier for this type of error.
## Code examples

#### curl

```curl
curl -X GET "https://api.elastic-cloud.com/api/v1/serverless/projects/elasticsearch/${ID}/roles" \
  -H "Authorization: ApiKey ${API_KEY}"
```

## Response examples

#### 200

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "key": {
    "roles": [
      {
        "name": "string",
        "description": "string"
      }
    ]
  }
}
```

#### 404

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "errors": [
    {
      "message": "Explicative error message",
      "code": "code.error"
    }
  ]
}
```

