---
type: api
title: Get enrollment API keys
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana-serverless/operation/operation-get-fleet-enrollment-api-keys
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana-serverless/operation/operation-get-fleet-enrollment-api-keys
products:
  - Kibana
---

# Get enrollment API keys

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

## Paths

- `GET` `/api/fleet/enrollment_api_keys`
- `GET` `/s/{space_id}/api/fleet/enrollment_api_keys`

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

## Description

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

List all enrollment API keys.<br/><br/>[Required authorization] Route required privileges: fleet-agents-all OR fleet-setup.

## Query String Parameters

- `page` (number · default: 1)
  Page number
- `perPage` (number · default: 20)
  Number of results per page
- `kuery` (string)
  A KQL query string to filter results

## Responses

#### `200`

Successful response

`application/json`

- `items` ([] object · max: 10000)
  - `active` (boolean)
    When false, the enrollment API key is revoked and cannot be used for enrolling Elastic Agents.
  - `api_key` (string)
    The enrollment API key (token) used for enrolling Elastic Agents.
  - `api_key_id` (string)
    The ID of the API key in the Security API.
  - `created_at` (string)
  - `expire_at` (string)
    The expiration date of the enrollment token as an ISO 8601 date string. Absent when the token never expires.
  - `hidden` (boolean)
  - `id` (string)
  - `name` (string)
    The name of the enrollment API key.
  - `policy_id` (string)
    The ID of the agent policy the Elastic Agent will be enrolled in.
- `list` ([] object · max: 10000) — deprecated
  - `active` (boolean)
    When false, the enrollment API key is revoked and cannot be used for enrolling Elastic Agents.
  - `api_key` (string)
    The enrollment API key (token) used for enrolling Elastic Agents.
  - `api_key_id` (string)
    The ID of the API key in the Security API.
  - `created_at` (string)
  - `expire_at` (string)
    The expiration date of the enrollment token as an ISO 8601 date string. Absent when the token never expires.
  - `hidden` (boolean)
  - `id` (string)
  - `name` (string)
    The name of the enrollment API key.
  - `policy_id` (string)
    The ID of the agent policy the Elastic Agent will be enrolled in.
- `page` (number)
- `perPage` (number)
- `total` (number)
#### `400`

Bad Request

`application/json`

- `attributes` (object)
- `error` (string)
- `errorType` (string)
- `message` (string)
- `statusCode` (number)
## Code Examples

#### Console

```console
GET /api/fleet/enrollment_api_keys
```

#### curl

```curl
curl -X GET "https://{kibana_url}/api/fleet/enrollment_api_keys"
```

## Response Examples

#### Get enrollment api keys

List of enrollment API keys

```json
{
  "items": [
    {
      "active": true,
      "api_key": "api-key-value-1",
      "api_key_id": "api-key-id-1",
      "created_at": "2024-01-01T00:00:00.000Z",
      "id": "key-id-1",
      "name": "Default policy enrollment key",
      "policy_id": "policy-id-1"
    }
  ],
  "list": [
    {
      "active": true,
      "api_key": "api-key-value-1",
      "api_key_id": "api-key-id-1",
      "created_at": "2024-01-01T00:00:00.000Z",
      "id": "key-id-1",
      "name": "Default policy enrollment key",
      "policy_id": "policy-id-1"
    }
  ],
  "page": 1,
  "perPage": 20,
  "total": 1
}
```

#### Generic error response

Example of a generic error response

```json
{
  "error": "Bad Request",
  "message": "An error message describing what went wrong",
  "statusCode": 400
}
```

