---
type: api
title: Delete an agent
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/operation/operation-delete-fleet-agents-agentid
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/operation/operation-delete-fleet-agents-agentid
products:
  - Kibana
---

# Delete an agent

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

## Paths

- `DELETE` `/api/fleet/agents/{agentId}`
- `DELETE` `/s/{space_id}/api/fleet/agents/{agentId}`

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

- `agentId` (string)
  The agent ID

## Description

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

Delete an agent by ID.<br/><br/>[Required authorization] Route required privileges: fleet-agents-all.

## 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/agents/{agentId}
```

#### curl

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

## Response Examples

#### Delete agent

Agent successfully deleted

```json
{
  "id": "agent-id-1",
  "success": true
}
```

#### 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 agent was found with the given ID

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

