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

# Delete an agent policy

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

## Paths

- `POST` `/api/fleet/agent_policies/delete`
- `POST` `/s/{space_id}/api/fleet/agent_policies/delete`

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

## Description

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

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

## Request Body

`application/json`

- `agentPolicyId` (string) — required
  The ID of the agent policy
- `force` (boolean) — optional
  bypass validation checks that can prevent agent policy deletion

## Responses

#### `200`

Successful response

`application/json`

- `id` (string)
- `name` (string)
#### `400`

Bad Request

`application/json`

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

#### Console

```console
POST /api/fleet/agent_policies/delete
{
  "agentPolicyId": "agent-policy-id-1"
}
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/fleet/agent_policies/delete" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{
  "agentPolicyId": "agent-policy-id-1"
}'
```

## Response Examples

#### Post delete agent policy

The agent policy was successfully deleted

```json
{
  "id": "agent-policy-id-1",
  "name": "My agent policy"
}
```

#### Generic error response

Example of a generic error response

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

