---
type: api
title: "Delete agent configuration"
description: "Delete an existing agent configuration. You must have all privileges for the APM and User Experience feature in Kibana. When successful, the configuration is removed and, if Fleet is enabled, APM package policies are synchronized accordingly."
url: https://www.elastic.co/elastic/docs-builder/docs/4904/api/kibana-serverless/operation/operation-deleteagentconfiguration
resource: https://www.elastic.co/elastic/docs-builder/docs/4904/api/kibana-serverless/operation/operation-deleteagentconfiguration
products:
  - Kibana
---

# Delete agent configuration

Authentication: required

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

## Paths

- `DELETE` `/api/apm/settings/agent-configuration`
- `DELETE` `/s/{space_id}/api/apm/settings/agent-configuration`

#### Path parameters

- `space_id` (string) — optional
  An identifier for the space. If `space_id` is not provided in the URL, the default space is used. Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

## Description

Delete an existing agent configuration. You must have `all` privileges for the APM and User Experience feature in Kibana. When successful, the configuration is removed and, if Fleet is enabled, APM package policies are synchronized accordingly.

## Header parameters

- `elastic-api-version` (enum · default: 2023-10-31) — required
  The version of the API to use
  Values: `2023-10-31`
- `kbn-xsrf` (string) — required
  A required header to protect against CSRF attacks

## Request body

`application/json`

- `service` (object) — required
  Service
  - `environment` (string) — optional
    The environment of the service.
  - `name` (string) — optional
    The name of the service.

## Responses

#### `200`

Successful response

`application/json`

- `result` (string)
  Result
#### `400`

Bad Request response

`application/json`

- `error` (string)
  Error type
- `message` (string)
  Error message
- `statusCode` (number)
  Error status code
#### `401`

Unauthorized response

`application/json`

- `error` (string)
  Error type
- `message` (string)
  Error message
- `statusCode` (number)
  Error status code
#### `403`

Forbidden response

`application/json`

- `error` (string)
  Error type
- `message` (string)
  Error message
- `statusCode` (number)
  Error status code
#### `404`

Not found response

`application/json`

- `error` (string)
  Error type
- `message` (string)
  Error message
- `statusCode` (number)
  Error status code
## Code examples

#### Console

```console
DELETE kbn:/api/apm/settings/agent-configuration
{
  "service": {
    "environment": "production",
    "name": "frontend"
  }
}
```

#### curl

```curl
curl -X DELETE "${KIBANA_URL}/api/apm/settings/agent-configuration" \
  -H "elastic-api-version: 2023-10-31" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "service": {
      "environment": "production",
      "name": "frontend"
    }
  }'
```

## Response examples

#### Delete agent configuration response example1

`application/json`

An example of a successful response from `DELETE /api/apm/settings/agent-configuration`.

```json
{
  "result": "deleted"
}
```

#### Bad request

`application/json`

An example of a 400 Bad Request response, returned when the request payload or query parameters fail validation.

```json
{
  "error": "Bad Request",
  "message": "[request body]: expected value of type [string] but got [undefined]",
  "statusCode": 400
}
```

#### Unauthorized

`application/json`

An example of a 401 Unauthorized response, returned when the request is missing valid authentication credentials.

```json
{
  "error": "Unauthorized",
  "message": "[security_exception]: missing authentication credentials for REST request",
  "statusCode": 401
}
```

#### Forbidden

`application/json`

An example of a 403 Forbidden response, returned when the authenticated user lacks the required APM and User Experience privileges.

```json
{
  "error": "Forbidden",
  "message": "Insufficient privileges to perform this action. The APM and User Experience feature requires \u0060all\u0060 privileges.",
  "statusCode": 403
}
```

#### Not found

`application/json`

An example of a 404 Not Found response, returned when the requested resource does not exist or the feature is not available on the current deployment.

```json
{
  "error": "Not Found",
  "message": "Not Found",
  "statusCode": 404
}
```

