---
type: api
title: Update agent policy by ID
description: "Update agent policy by ID"
url: https://www.elastic.co/elastic/docs-builder/docs/5002/api/kibana/v8/operation/operation-update-agent-policy
resource: https://www.elastic.co/elastic/docs-builder/docs/5002/api/kibana/v8/operation/operation-update-agent-policy
products:
  - Kibana
---

# Update agent policy by ID

Authentication: required

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

## Paths

- `PUT` `/api/fleet/agent_policies/{agentPolicyId}`
- `PUT` `/s/{space_id}/api/fleet/agent_policies/{agentPolicyId}`

#### 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.
- `agentPolicyId` (string) — required

## Query string parameters

- `format` (enum) — optional
  Simplified or legacy format for package inputs
  Values: `simplified`, `legacy`

## Header parameters

- `kbn-xsrf` (string) — required
  Kibana's anti Cross-Site Request Forgery token. Can be any string value.

## Request body

`application/json`

- `agent_features` (object[]) — optional
  - `enabled` (boolean) — required
  - `name` (string) — required
- `data_output_id` (string) — optional — nullable
- `description` (string) — optional
- `download_source_id` (string) — optional — nullable
- `fleet_server_host_id` (string) — optional — nullable
- `force` (boolean) — optional
  Force agent policy creation even if packages are not verified.
- `global_data_tags` ((string to number | string)[]) — optional
- `inactivity_timeout` (integer) — optional
- `is_protected` (boolean) — optional
- `monitoring_enabled` (enum[]) — optional
  Values: `metrics`, `logs`
- `monitoring_output_id` (string) — optional — nullable
- `name` (string) — required
- `namespace` (string) — required
- `unenroll_timeout` (integer) — optional

## Responses

#### `200`

OK

`application/json`

- `item` (object)
  - `advanced_settings` (object) — nullable
    Advanced settings stored in the agent policy, e.g. agent_limits_go_max_procs
  - `agent_features` (object[])
    - `enabled` (boolean)
    - `name` (string)
  - `agents` (number)
  - `data_output_id` (string) — nullable
  - `description` (string)
  - `download_source_id` (string) — nullable
  - `fleet_server_host_id` (string) — nullable
  - `global_data_tags` ((string to number | string)[])
  - `id` (string)
  - `inactivity_timeout` (integer)
  - `is_protected` (boolean)
    Indicates whether the agent policy has tamper protection enabled. Default false.
  - `keep_monitoring_alive` (boolean) — nullable
    When set to true, monitoring will be enabled but logs/metrics collection will be disabled
  - `monitoring_diagnostics` (object)
    - `limit` (object)
      - `burst` (number)
      - `interval` (string)
    - `uploader` (object)
      - `init_dur` (string)
      - `max_dur` (string)
      - `max_retries` (number)
  - `monitoring_enabled` (enum[])
    Values: `metrics`, `logs`
  - `monitoring_http` (object)
    - `enabled` (boolean)
    - `host` (string)
    - `port` (number)
  - `monitoring_output_id` (string) — nullable
  - `monitoring_pprof_enabled` (boolean)
  - `name` (string)
  - `namespace` (string)
  - `overrides` (object) — nullable
    Override settings that are defined in the agent policy. Input, output permissions and OpenTelemetry collector settings (receivers, exporters, processors, connectors, extensions, service) cannot be overridden. The override option should be used only in unusual circumstances and not as a routine procedure.
  - `package_policies` (object[])
    This field is present only when retrieving a single agent policy, or when retrieving a list of agent policies with the ?full=true parameter
    - `id` (string)
    - `inputs` (union oneOf)
      One of: `object[]` or `object`
    - `revision` (number)
    - `description` (string)
    - `enabled` (boolean)
    - `name` (string)
    - `namespace` (string)
    - `output_id` (string)
    - `overrides` (object)
    - `package` (object)
      - `name` (string)
      - `requires_root` (boolean)
      - `title` (string)
      - `version` (string)
    - `policy_id` (string) — nullable — deprecated
    - `policy_ids` (string[])
  - `revision` (number)
  - `supports_agentless` (boolean)
    Indicates whether the agent policy supports agentless integrations. Only allowed in a serverless environment.
  - `unenroll_timeout` (integer)
  - `unprivileged_agents` (number)
  - `updated_by` (string)
  - `updated_on` (string · format: date-time)
#### `400`

Generic Error

`application/json`

- `error` (string)
- `message` (string)
- `statusCode` (number)
## Code examples

#### Console

```console
PUT kbn:/api/fleet/agent_policies/AGENT_POLICY_ID
{
  "name": "string",
  "namespace": "string"
}
```

#### curl

```curl
curl -X PUT "${KIBANA_URL}/api/fleet/agent_policies/${AGENT_POLICY_ID}" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "string",
    "namespace": "string"
  }'
```

## Response examples

#### 200

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "item": {
    "advanced_settings": {},
    "agent_features": [
      {
        "enabled": false,
        "name": "string"
      }
    ],
    "agents": 0,
    "data_output_id": "string",
    "description": "string",
    "download_source_id": "string",
    "fleet_server_host_id": "string",
    "global_data_tags": [
      {
        "key": "string"
      }
    ],
    "id": "string",
    "inactivity_timeout": 0,
    "is_protected": false,
    "keep_monitoring_alive": false,
    "monitoring_diagnostics": {
      "limit": {
        "burst": 0,
        "interval": "string"
      },
      "uploader": {
        "init_dur": "string",
        "max_dur": "string",
        "max_retries": 0
      }
    },
    "monitoring_enabled": [
      "metrics"
    ],
    "monitoring_http": {
      "enabled": false,
      "host": "string",
      "port": 0
    },
    "monitoring_output_id": "string",
    "monitoring_pprof_enabled": false,
    "name": "string",
    "namespace": "string",
    "overrides": {},
    "package_policies": [
      {
        "id": "string",
        "inputs": [],
        "revision": 0,
        "description": "string",
        "enabled": false,
        "name": "string",
        "namespace": "string",
        "output_id": "string",
        "overrides": {},
        "package": {
          "name": "string",
          "requires_root": false,
          "title": "string",
          "version": "string"
        },
        "policy_id": "string",
        "policy_ids": [
          "string"
        ]
      }
    ],
    "revision": 0,
    "supports_agentless": false,
    "unenroll_timeout": 0,
    "unprivileged_agents": 0,
    "updated_by": "string",
    "updated_on": "string"
  }
}
```

#### 400

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "error": "string",
  "message": "string",
  "statusCode": 0
}
```

