---
type: api
title: Update a package policy
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/operation/operation-put-fleet-package-policies-packagepolicyid
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/operation/operation-put-fleet-package-policies-packagepolicyid
products:
  - Kibana
---

# Update a package policy

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

## Paths

- `PUT` `/api/fleet/package_policies/{packagePolicyId}`
- `PUT` `/s/{space_id}/api/fleet/package_policies/{packagePolicyId}`

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

- `packagePolicyId` (string)
  The ID of the package policy

## Description

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

Update a package policy by ID.

## Query String Parameters

- `format` (enum)
  Format for the response: simplified or legacy
  Values: `simplified`, `legacy`

## Request Body

`application/json`

Any of:
- **Kibana_HTTP_APIs_update_package_policy_request**
  - `additional_datastreams_permissions` ([] string · max: 1000) — optional — nullable
    Additional data stream permissions that will be added to the agent policy.
  - `cloud_connector_id` (string) — optional — nullable
    ID of the cloud connector associated with this package policy.
  - `cloud_connector_name` (string · min: 1 · max: 255) — optional — nullable
    Transient field for cloud connector name during creation.
  - `condition` (string · max: 10000) — optional — nullable
    Agent condition expression to evaluate whether to apply this integration to its inputs.
  - `description` (string) — optional
    Package policy description
  - `enabled` (boolean) — optional
  - `force` (boolean) — optional
  - `global_data_tags` ([] object · max: 100) — optional — nullable
    - `name` (string) — required
      The name of the custom field. Cannot contain spaces.
    - `value` (number | string) — required
      The value of the custom field.
  - `inputs` ([] object · max: 1000) — optional
    - `condition` (string · max: 10000) — optional — nullable
      Agent condition expression to evaluate whether to apply this input.
    - `config` (map string to object) — optional
      Package variable (see integration documentation for more information)
      Map values (object)
      - `frozen` (boolean) — optional
      - `type` (string) — optional
      - `value` (object) — required
    - `deprecated` ({}) — optional
      - `description` (string · max: 4096) — required
      - `replaced_by` (map string to string) — optional
      - `since` (string · max: 50) — optional
    - `enabled` (boolean) — required
    - `id` (string) — optional
    - `keep_enabled` (boolean) — optional
    - `migrate_from` (string) — optional
    - `name` (string) — optional
    - `policy_template` (string) — optional
    - `streams` ([] object · max: 1000) — optional
      - `compiled_stream` (object) — required
      - `condition` (string · max: 10000) — optional — nullable
        Agent condition expression to evaluate whether to apply this stream.
      - `config` (map string to object) — optional
        Package variable (see integration documentation for more information)
        Map values (object)
        - `frozen` (boolean) — optional
        - `type` (string) — optional
        - `value` (object) — required
      - `data_stream` (object) — required
        - `dataset` (string) — required
        - `elasticsearch` (object) — optional
          - `dynamic_dataset` (boolean) — optional
          - `dynamic_namespace` (boolean) — optional
          - `privileges` (object) — optional
            - `indices` ([] string · max: 100) — optional
        - `type` (string) — optional
      - `deprecated` ({}) — optional
        - `description` (string · max: 4096) — required
        - `replaced_by` (map string to string) — optional
        - `since` (string · max: 50) — optional
      - `enabled` (boolean) — required
      - `id` (string) — optional
      - `keep_enabled` (boolean) — optional
      - `migrate_from` (string) — optional
      - `release` (enum) — optional
        Values: `ga`, `beta`, `experimental`
      - `var_group_selections` (map string to string) — optional
        Variable group selections. Maps var_group name to the selected option name within that group.
      - `vars` (map string to object) — optional
        Package variable (see integration documentation for more information)
        Map values (object)
        - `frozen` (boolean) — optional
        - `type` (string) — optional
        - `value` (object) — required
    - `type` (string) — required
    - `var_group_selections` (map string to string) — optional
      Variable group selections. Maps var_group name to the selected option name within that group.
    - `vars` (map string to object) — optional
      Package variable (see integration documentation for more information)
      Map values (object)
      - `frozen` (boolean) — optional
      - `type` (string) — optional
      - `value` (object) — required
  - `is_managed` (boolean) — optional
  - `name` (string) — optional
  - `namespace` (string · max: 100) — optional
    The package policy namespace. Leave blank to inherit the agent policy's namespace.
  - `output_id` (string) — optional — nullable
  - `overrides` (object) — optional — nullable
    Override settings that are defined in the package policy. The override option should be used only in unusual circumstances and not as a routine procedure.
    - `inputs` (map string to object) — optional
  - `package` ({}) — optional
    - `experimental_data_stream_features` ([] object · max: 100) — optional
      - `data_stream` (string · max: 1024) — required
      - `features` (object) — required
        - `doc_value_only_numeric` (boolean) — optional
        - `doc_value_only_other` (boolean) — optional
        - `synthetic_source` (boolean) — optional
        - `tsdb` (boolean) — optional
    - `fips_compatible` (boolean) — optional
    - `name` (string · max: 255) — required
      Package name
    - `requires_root` (boolean) — optional
    - `title` (string · max: 255) — optional
    - `version` (string · max: 50) — required
      Package version
  - `package_agent_version_condition` (string) — optional
  - `policy_id` (string) — optional — nullable — deprecated
    ID of the agent policy which the package policy will be added to.
  - `policy_ids` ([] string · max: 1000) — optional
  - `spaceIds` ([] string · max: 100) — optional
  - `supports_agentless` (boolean) — optional — nullable
    Indicates whether the package policy belongs to an agentless agent policy.
  - `supports_cloud_connector` (boolean) — optional — nullable
    Indicates whether the package policy supports cloud connectors.
  - `var_group_selections` (map string to string) — optional
    Variable group selections. Maps var_group name to the selected option name within that group.
  - `vars` (map string to object) — optional
    Package variable (see integration documentation for more information)
    Map values (object)
    - `frozen` (boolean) — optional
    - `type` (string) — optional
    - `value` (object) — required
  - `version` (string) — optional
- **Kibana_HTTP_APIs_simplified_create_package_policy_request**
  - `additional_datastreams_permissions` ([] string · max: 100) — optional — nullable
    Additional data stream permissions that will be added to the agent policy.
  - `condition` (string · max: 10000) — optional — nullable
    Agent condition expression to evaluate whether to apply this integration to its inputs.
  - `create_dataset_templates` (boolean) — optional
    When true, install dedicated index templates for streams with a custom data_stream.dataset. Defaults to true for input packages, false for integration packages.
  - `description` (string · max: 2048) — optional
    Policy description.
  - `force` (boolean) — optional
    Force package policy creation even if the package is not verified, or if the agent policy is managed.
  - `id` (string · max: 255) — optional
    Policy unique identifier.
  - `inputs` (map string to object) — optional
    Package policy inputs. Refer to the integration documentation to know which inputs are available.
    Map values (object)
    - `condition` (string · max: 10000) — optional — nullable
      Agent condition expression to evaluate whether to apply this input.
    - `deprecated` ({}) — optional
      - `description` (string · max: 4096) — required
      - `replaced_by` (map string to string) — optional
      - `since` (string · max: 50) — optional
    - `enabled` (boolean) — optional
      Enable or disable that input. Defaults to `true` (enabled).
    - `streams` (map string to object) — optional
      Input streams. Refer to the integration documentation to know which streams are available.
      Map values (object)
      - `condition` (string · max: 10000) — optional — nullable
        Agent condition expression to evaluate whether to apply this stream.
      - `deprecated` ({}) — optional
        - `description` (string · max: 4096) — required
        - `replaced_by` (map string to string) — optional
        - `since` (string · max: 50) — optional
      - `enabled` (boolean) — optional
        Enable or disable that stream. Defaults to `true` (enabled).
      - `var_group_selections` (map string to string) — optional
        Variable group selections. Maps var_group name to the selected option name within that group.
      - `vars` (map string to anyOf) — optional
        Input/stream level variable. Refer to the integration documentation for more information.
    - `vars` (map string to anyOf) — optional
      Input/stream level variable. Refer to the integration documentation for more information.
  - `name` (string · max: 255) — required
    Unique name for the policy.
  - `namespace` (string · max: 100) — optional
    Policy namespace. When not specified, it inherits the agent policy namespace.
  - `output_id` (string · max: 255) — optional — nullable
  - `package` ({}) — required
    Same fields as `package` in `Kibana_HTTP_APIs_update_package_policy_request`
  - `policy_id` (string · max: 255) — optional — nullable — deprecated
    Deprecated. Use policy_ids instead.
  - `policy_ids` ([] string · max: 1000) — optional
    IDs of the agent policies that the package policy will be added to.
  - `supports_agentless` (boolean) — optional — nullable — deprecated
    Indicates whether the package policy belongs to an agentless agent policy. Deprecated in favor of the Fleet managed integrations API.
  - `var_group_selections` (map string to string) — optional
    Variable group selections. Maps var_group name to the selected option name within that group.
  - `vars` (map string to anyOf) — optional
    Input/stream level variable. Refer to the integration documentation for more information.

## Responses

#### `200`

Successful response

`application/json`

- `item` ({})
  - `additional_datastreams_permissions` ([] string · max: 1000) — nullable
    Additional data stream permissions that will be added to the agent policy.
  - `agents` (number)
  - `cloud_connector_id` (string) — nullable
    ID of the cloud connector associated with this package policy.
  - `cloud_connector_name` (string · min: 1 · max: 255) — nullable
    Transient field for cloud connector name during creation.
  - `condition` (string · max: 10000) — nullable
    Agent condition expression to evaluate whether to apply this integration to its inputs.
  - `created_at` (string)
  - `created_by` (string)
  - `description` (string)
    Package policy description
  - `elasticsearch` (object)
    - `privileges` (object)
      - `cluster` ([] string · max: 100)
  - `enabled` (boolean)
  - `global_data_tags` ([] object · max: 100) — nullable
    - `name` (string)
      The name of the custom field. Cannot contain spaces.
    - `value` (number | string)
      The value of the custom field.
  - `id` (string)
    Package policy unique identifier.
  - `inputs` (union anyOf)
    Package policy inputs.
    - **[]object**
      - `compiled_input` (object)
      - `condition` (string · max: 10000) — nullable
        Agent condition expression to evaluate whether to apply this input.
      - `config` (map string to object)
        Package variable (see integration documentation for more information)
        Map values (object)
        - `frozen` (boolean)
        - `type` (string)
        - `value` (object)
      - `deprecated` ({})
        - `description` (string · max: 4096)
        - `replaced_by` (map string to string)
        - `since` (string · max: 50)
      - `enabled` (boolean)
      - `id` (string)
      - `keep_enabled` (boolean)
      - `migrate_from` (string)
      - `name` (string)
      - `policy_template` (string)
      - `streams` ([] object · max: 1000)
        - `compiled_stream` (object)
        - `condition` (string · max: 10000) — nullable
          Agent condition expression to evaluate whether to apply this stream.
        - `config` (map string to object)
          Package variable (see integration documentation for more information)
          Map values (object)
          - `frozen` (boolean)
          - `type` (string)
          - `value` (object)
        - `data_stream` (object)
          - `dataset` (string)
          - `elasticsearch` (object)
            - `dynamic_dataset` (boolean)
            - `dynamic_namespace` (boolean)
            - `privileges` (object)
              - `indices` ([] string · max: 100)
          - `type` (string)
        - `deprecated` ({})
          - `description` (string · max: 4096)
          - `replaced_by` (map string to string)
          - `since` (string · max: 50)
        - `enabled` (boolean)
        - `id` (string)
        - `keep_enabled` (boolean)
        - `migrate_from` (string)
        - `release` (enum)
          Values: `ga`, `beta`, `experimental`
        - `var_group_selections` (map string to string)
          Variable group selections. Maps var_group name to the selected option name within that group.
        - `vars` (map string to object)
          Package variable (see integration documentation for more information)
          Map values (object)
          - `frozen` (boolean)
          - `type` (string)
          - `value` (object)
      - `type` (string)
      - `var_group_selections` (map string to string)
        Variable group selections. Maps var_group name to the selected option name within that group.
      - `vars` (map string to object)
        Package variable (see integration documentation for more information)
        Map values (object)
        - `frozen` (boolean)
        - `type` (string)
        - `value` (object)
    - **string to object**
      Package policy inputs. Refer to the integration documentation to know which inputs are available.
      - `<string>` (object)
        - `condition` (string · max: 10000) — nullable
          Agent condition expression to evaluate whether to apply this input.
        - `deprecated` ({})
          - `description` (string · max: 4096)
          - `replaced_by` (map string to string)
          - `since` (string · max: 50)
        - `enabled` (boolean)
          Enable or disable that input. Defaults to `true` (enabled).
        - `streams` (map string to object)
          Input streams. Refer to the integration documentation to know which streams are available.
          Map values (object)
          - `condition` (string · max: 10000) — nullable
            Agent condition expression to evaluate whether to apply this stream.
          - `deprecated` ({})
            - `description` (string · max: 4096)
            - `replaced_by` (map string to string)
            - `since` (string · max: 50)
          - `enabled` (boolean)
            Enable or disable that stream. Defaults to `true` (enabled).
          - `var_group_selections` (map string to string)
            Variable group selections. Maps var_group name to the selected option name within that group.
          - `vars` (map string to anyOf)
            Input/stream level variable. Refer to the integration documentation for more information.
        - `vars` (map string to anyOf)
          Input/stream level variable. Refer to the integration documentation for more information.
  - `is_managed` (boolean)
  - `name` (string)
    Unique name for the package policy.
  - `namespace` (string · max: 100)
    The package policy namespace. Leave blank to inherit the agent policy's namespace.
  - `output_id` (string) — nullable
  - `overrides` (object) — nullable
    Override settings that are defined in the package policy. The override option should be used only in unusual circumstances and not as a routine procedure.
    - `inputs` (map string to object)
  - `package` ({})
    Same fields as `package` in `Kibana_HTTP_APIs_update_package_policy_request`
  - `package_agent_version_condition` (string)
  - `policy_id` (string) — nullable — deprecated
    ID of the agent policy which the package policy will be added to.
  - `policy_ids` ([] string · max: 1000)
  - `revision` (number)
    Package policy revision.
  - `secret_references` ([] object · max: 1000)
    - `id` (string)
  - `spaceIds` ([] string · max: 100)
  - `supports_agentless` (boolean) — nullable
    Indicates whether the package policy belongs to an agentless agent policy.
  - `supports_cloud_connector` (boolean) — nullable
    Indicates whether the package policy supports cloud connectors.
  - `updated_at` (string)
  - `updated_by` (string)
  - `var_group_selections` (map string to string)
    Variable group selections. Maps var_group name to the selected option name within that group.
  - `vars` (union anyOf)
    Package level variable.
    - **string to object**
      Package variable (see integration documentation for more information)
      - `<string>` (object)
        - `frozen` (boolean)
        - `type` (string)
        - `value` (object)
    - **string to anyOf**
      Input/stream level variable. Refer to the integration documentation for more information.
  - `version` (string)
    Package policy ES version.
#### `400`

Bad Request

`application/json`

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

Forbidden

`application/json`

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

#### Console

```console
PUT /api/fleet/package_policies/{packagePolicyId}
{
  "enabled": true,
  "inputs": {},
  "name": "nginx-1-updated",
  "namespace": "default",
  "package": {
    "name": "nginx",
    "version": "1.20.0"
  },
  "policy_ids": [
    "agent-policy-id-1"
  ]
}
```

#### curl

```curl
curl -X PUT "https://{kibana_url}/api/fleet/package_policies/{packagePolicyId}" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{
  "enabled": true,
  "inputs": {},
  "name": "nginx-1-updated",
  "namespace": "default",
  "package": {
    "name": "nginx",
    "version": "1.20.0"
  },
  "policy_ids": [
    "agent-policy-id-1"
  ]
}'
```

## Response Examples

#### Put package policy

The updated package policy

```json
{
  "item": {
    "created_at": "2024-01-15T10:00:00.000Z",
    "enabled": true,
    "id": "package-policy-id-1",
    "inputs": [],
    "name": "nginx-1-updated",
    "namespace": "default",
    "package": {
      "name": "nginx",
      "title": "Nginx",
      "version": "1.20.0"
    },
    "policy_ids": [
      "agent-policy-id-1"
    ],
    "updated_at": "2024-01-15T11:00:00.000Z"
  }
}
```

#### Generic error response

Example of a generic error response

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

#### Forbidden

The update is not authorized for this package

```json
{
  "error": "Forbidden",
  "message": "An error message describing what went wrong",
  "statusCode": 403
}
```

