---
type: api
title: Unenroll an agent
description: Unenroll a specific agent, optionally revoking its enrollment API key.<br/><br/>[Required authorization] Route required privileges: fleet-agents-all.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-post-fleet-agents-agentid-unenroll
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-post-fleet-agents-agentid-unenroll
products:
  - Kibana
---

# Unenroll an agent

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

## Paths

- `POST` `/api/fleet/agents/{agentId}/unenroll`

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

#### Path Parameters

- `agentId` (string)
  The agent ID

## Description

Unenroll a specific agent, optionally revoking its enrollment API key.<br/><br/>[Required authorization] Route required privileges: fleet-agents-all.

## Request Body

`application/json`

- `force` (boolean) — optional
- `revoke` (boolean) — optional

## Responses

#### `200`

Successful response

#### `400`

Bad Request

## Code Examples

#### Console

```console
POST /api/fleet/agents/{agentId}/unenroll
{
  "revoke": false
}
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/fleet/agents/{agentId}/unenroll" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{
  "revoke": false
}'
```

## Response Examples

#### Post unenroll agent

Agent successfully unenrolled

```json
{}
```

#### Generic error response

Example of a generic error response

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

