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

# Revoke or delete an enrollment API key

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

## Paths

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

#### Path parameters

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

## Description

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

Revoke or delete an enrollment API key by ID. Use `forceDelete=true` to remove the document.

## Required authorization

- Privileges: `fleet-agents-all`

## 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

- `forceDelete` (boolean · default: false) — optional
  When false (default), invalidate the API key and mark the token as inactive. When true, also delete the token document.
- `includeHidden` (boolean · default: false) — optional
  When true, allow deletion of hidden enrollment tokens (managed/agentless policies). Defaults to false.

## Header parameters

- `kbn-xsrf` (string) — required
  A required header to protect against CSRF attacks

## Responses

#### `200`

Successful response

`application/json`

- `action` (enum)
  Values: `deleted`
#### `400`

Bad Request

`application/json`

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

Not Found

`application/json`

## Code examples

#### Console

```console
DELETE kbn:/api/fleet/enrollment_api_keys/KEY_ID
```

#### curl

```curl
curl -X DELETE "${KIBANA_URL}/api/fleet/enrollment_api_keys/${KEY_ID}" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}"
```

## Response examples

#### Delete enrollment api key

The enrollment API key was successfully revoked

```json
{
  "action": "deleted"
}
```

#### 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
}
```

