---
type: api
title: Copy agent policy by ID
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v8/operation/operation-agent-policy-copy
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v8/operation/operation-agent-policy-copy
products:
  - Kibana
---

# Copy agent policy by ID

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

## Paths

- `POST` `/api/fleet/agent_policies/{agentPolicyId}/copy`
- `POST` `/s/{space_id}/api/fleet/agent_policies/{agentPolicyId}/copy`

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

## Description

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

## Request Body

`application/json`

- `description` (string) — optional
- `name` (string) — required

## Responses

#### `200`

OK

`application/json`

- `item` ({})
  - `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 settings 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)
#### `400`

Generic Error

`application/json`

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

#### Console

```console
POST /api/fleet/agent_policies/{agentPolicyId}/copy
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/fleet/agent_policies/{agentPolicyId}/copy" \
  -H "kbn-xsrf: true"
```

