---
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/4371/api/doc/kibana/v9/operation/operation-delete-fleet-enrollment-api-keys-keyid
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v9/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}`

- [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)

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

Revoke or delete an enrollment API key by ID. Use `forceDelete=true` to remove the document.<br/><br/>[Required authorization] Route required privileges: fleet-agents-all.

## Query String Parameters

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

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

## Code Examples

#### Console

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

#### curl

```curl
curl -X DELETE "https://{kibana_url}/api/fleet/enrollment_api_keys/{keyId}" \
  -H "kbn-xsrf: true"
```

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

