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

# Get an enrollment API key

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

## Paths

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

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

#### Path Parameters

- `keyId` (string)
  The ID of the enrollment API key

## Description

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

Get an enrollment API key by ID.<br/><br/>[Required authorization] Route required privileges: fleet-agents-all OR fleet-setup.

## Responses

#### `200`

Successful response

`application/json`

- `item` ({})
  - `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.
#### `400`

Bad Request

`application/json`

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

Not Found

## Code Examples

#### Console

```console
GET /api/fleet/enrollment_api_keys/{keyId}
```

#### curl

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

## Response Examples

#### Get enrollment api key

An enrollment API key

```json
{
  "item": {
    "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"
  }
}
```

#### Generic error response

Example of a generic error response

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

#### Not found

No enrollment API key was found with the given ID

```json
{
  "error": "Not Found",
  "message": "EnrollmentAPIKey key-id-1 not found",
  "statusCode": 404
}
```

