---
type: api
title: Create a package policy
description: Create a new package policy and assign it to an agent policy.
url: https://www.elastic.co/elastic/docs-builder/docs/4922/api/doc/kibana/operation/operation-post-fleet-package-policies
resource: https://www.elastic.co/elastic/docs-builder/docs/4922/api/doc/kibana/operation/operation-post-fleet-package-policies
products:
  - Kibana
---

# Create a package policy

Authentication: required

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

## Paths

- `POST` `/api/fleet/package_policies`
- `POST` `/s/{space_id}/api/fleet/package_policies`

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

Create a new package policy and assign it to an agent policy.

## Query string parameters

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

## Header parameters

- `kbn-xsrf` (string) — required
  A required header to protect against CSRF attacks

## Request body

`application/json`

Any of:
- **create_package_policy_request**
  - `acknowledge_agent_version_incompatibility` (boolean) — optional
    When true, create or upgrade the package policy even though some active agents on its agent policies don't satisfy the package's agent version condition. Without it, the request is rejected, because those agents would stop collecting the integration's data. The `force` flag does not bypass this check.
  - `additional_datastreams_permissions` (string[] · max items: 1000) — optional — nullable
    Additional data stream permissions that will be added to the agent policy.
  - `cloud_connector_id` (string · min length: 0) — optional — nullable
    ID of the cloud connector associated with this package policy.
  - `cloud_connector_name` (string · min length: 1 · max length: 255) — optional — nullable
    Transient field for cloud connector name during creation.
  - `condition` (string · max length: 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) — optional
    Package policy description
  - `enabled` (boolean) — optional
  - `force` (boolean) — optional
    Force package policy creation even if the package is not verified, or if the agent policy is managed.
  - `global_data_tags` (object[] · max items: 100) — optional — nullable
    - `name` (string · min length: 0) — required
      The name of the custom field. Cannot contain spaces.
    - `value` (number | string) — required
      The value of the custom field.
  - `id` (string · min length: 0) — optional
    Package policy unique identifier
  - `inputs` (object[] · max items: 1000) — required
    - `condition` (string · max length: 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` (object) — optional
      - `description` (string · max length: 4096) — required
      - `replaced_by` (map string to string) — optional
        Map values (string · max length: 1024)
      - `since` (string · max length: 50) — optional
    - `enabled` (boolean) — required
    - `id` (string · min length: 0) — optional
    - `keep_enabled` (boolean) — optional
    - `migrate_from` (string) — optional
    - `name` (string) — optional
    - `policy_template` (string) — optional
    - `streams` (object[] · max items: 1000) — optional
      - `compiled_stream` (object) — required
      - `condition` (string · max length: 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 items: 100) — optional
        - `type` (string) — optional
      - `deprecated` (object) — optional
        - `description` (string · max length: 4096) — required
        - `replaced_by` (map string to string) — optional
          Map values (string · max length: 1024)
        - `since` (string · max length: 50) — optional
      - `enabled` (boolean) — required
      - `id` (string · min length: 0) — 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.
        Map values (string · max length: 1024)
      - `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.
      Map values (string · max length: 1024)
    - `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 · min length: 0) — required
    Unique name for the package policy.
  - `namespace` (string · max length: 100) — optional
    The package policy namespace. Leave blank to inherit the agent policy's namespace.
  - `output_id` (string · min length: 0) — 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` (object) — optional
    - `experimental_data_stream_features` (object[] · max items: 100) — optional
      - `data_stream` (string · max length: 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 length: 255) — required
      Package name
    - `requires_root` (boolean) — optional
    - `title` (string · max length: 255) — optional
    - `version` (string · max length: 50) — required
      Package version
  - `package_agent_version_condition` (string) — optional
  - `policy_id` (string · min length: 0) — optional — nullable — deprecated
    ID of the agent policy which the package policy will be added to.
  - `policy_ids` (string[] · max items: 1000) — optional
  - `spaceIds` (string[] · max items: 100) — optional
  - `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.
  - `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.
    Map values (string · max length: 1024)
  - `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
- **simplified_create_package_policy_request**
  - `acknowledge_agent_version_incompatibility` (boolean) — optional
    When true, create or upgrade the package policy even though some active agents on its agent policies don't satisfy the package's agent version condition. Without it, the request is rejected, because those agents would stop collecting the integration's data. The `force` flag does not bypass this check.
  - `additional_datastreams_permissions` (string[] · max items: 100) — optional — nullable
    Additional data stream permissions that will be added to the agent policy.
  - `condition` (string · max length: 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 length: 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 length: 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 length: 10000) — optional — nullable
      Agent condition expression to evaluate whether to apply this input.
    - `deprecated` (object) — optional
      - `description` (string · max length: 4096) — required
      - `replaced_by` (map string to string) — optional
        Map values (string · max length: 1024)
      - `since` (string · max length: 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 length: 10000) — optional — nullable
        Agent condition expression to evaluate whether to apply this stream.
      - `deprecated` (object) — optional
        - `description` (string · max length: 4096) — required
        - `replaced_by` (map string to string) — optional
          Map values (string · max length: 1024)
        - `since` (string · max length: 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.
        Map values (string · max length: 1024)
      - `vars` (map string to anyOf) — optional
        Input/stream level variable. Refer to the integration documentation for more information.
        Map values (union anyOf · default: null)
        Any of:
        - **[]string**
        - **string**
        - **[]number**
        - **number**
        - **boolean**
        - **{ id, isSecretRef }**
          - `id` (string · max length: 255) — required
          - `isSecretRef` (boolean) — required
    - `vars` (map string to anyOf) — optional
      Input/stream level variable. Refer to the integration documentation for more information.
      Map values (union anyOf · default: null)
      Any of:
      - **[]string**
      - **string**
      - **[]number**
      - **number**
      - **boolean**
      - **{ id, isSecretRef }**
        - `id` (string · max length: 255) — required
        - `isSecretRef` (boolean) — required
  - `name` (string · max length: 255) — required
    Unique name for the policy.
  - `namespace` (string · max length: 100) — optional
    Policy namespace. When not specified, it inherits the agent policy namespace.
  - `output_id` (string · max length: 255) — optional — nullable
  - `package` (object) — required
    Same fields as `package` in `create_package_policy_request`
  - `policy_id` (string · max length: 255) — optional — nullable — deprecated
    Deprecated. Use policy_ids instead.
  - `policy_ids` (string[] · max items: 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.
    Map values (string · max length: 1024)
  - `vars` (map string to anyOf) — optional
    Input/stream level variable. Refer to the integration documentation for more information.
    Map values (union anyOf · default: null)
    Any of:
    - **[]string**
    - **string**
    - **[]number**
    - **number**
    - **boolean**
    - **{ id, isSecretRef }**
      - `id` (string · max length: 255) — required
      - `isSecretRef` (boolean) — required

## Responses

#### `200`

Successful response

`application/json`

- `item` (object)
  - `additional_datastreams_permissions` (string[] · max items: 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 length: 1 · max length: 255) — nullable
    Transient field for cloud connector name during creation.
  - `condition` (string · max length: 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 items: 100)
  - `enabled` (boolean)
  - `global_data_tags` (object[] · max items: 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.
    - **[]{ compiled_input, enabled, streams, … }**
      - `compiled_input` (object)
      - `condition` (string · max length: 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` (object)
        - `description` (string · max length: 4096)
        - `replaced_by` (map string to string)
          Map values (string · max length: 1024)
        - `since` (string · max length: 50)
      - `enabled` (boolean)
      - `id` (string)
      - `keep_enabled` (boolean)
      - `migrate_from` (string)
      - `name` (string)
      - `policy_template` (string)
      - `streams` (object[] · max items: 1000)
        - `compiled_stream` (object)
        - `condition` (string · max length: 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 items: 100)
          - `type` (string)
        - `deprecated` (object)
          - `description` (string · max length: 4096)
          - `replaced_by` (map string to string)
            Map values (string · max length: 1024)
          - `since` (string · max length: 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.
          Map values (string · max length: 1024)
        - `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.
        Map values (string · max length: 1024)
      - `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 length: 10000) — nullable
          Agent condition expression to evaluate whether to apply this input.
        - `deprecated` (object)
          - `description` (string · max length: 4096)
          - `replaced_by` (map string to string)
            Map values (string · max length: 1024)
          - `since` (string · max length: 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 length: 10000) — nullable
            Agent condition expression to evaluate whether to apply this stream.
          - `deprecated` (object)
            - `description` (string · max length: 4096)
            - `replaced_by` (map string to string)
              Map values (string · max length: 1024)
            - `since` (string · max length: 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.
            Map values (string · max length: 1024)
          - `vars` (map string to anyOf)
            Input/stream level variable. Refer to the integration documentation for more information.
            Map values (union anyOf · default: null)
            Any of:
            - **[]string**
            - **string**
            - **[]number**
            - **number**
            - **boolean**
            - **{ id, isSecretRef }**
              - `id` (string · max length: 255)
              - `isSecretRef` (boolean)
        - `vars` (map string to anyOf)
          Input/stream level variable. Refer to the integration documentation for more information.
          Map values (union anyOf · default: null)
          Any of:
          - **[]string**
          - **string**
          - **[]number**
          - **number**
          - **boolean**
          - **{ id, isSecretRef }**
            - `id` (string · max length: 255)
            - `isSecretRef` (boolean)
  - `is_managed` (boolean)
  - `name` (string)
    Unique name for the package policy.
  - `namespace` (string · max length: 100)
    The package policy namespace. Leave blank to inherit the agent policy's namespace.
  - `onboarding_deployment_id` (string · max length: 256) — nullable
    ID of the cloud onboarding instance that manages this package policy. Set by Fleet, read-only.
  - `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` (object)
    Same fields as `package` in `create_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 items: 1000)
  - `revision` (number)
    Package policy revision.
  - `secret_references` (object[] · max items: 1000)
    - `id` (string)
  - `spaceIds` (string[] · max items: 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.
    Map values (string · max length: 1024)
  - `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)
#### `409`

Conflict

`application/json`

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

#### Console

```console
POST kbn:/api/fleet/package_policies
{
  "inputs": {},
  "name": "nginx-1",
  "namespace": "default",
  "package": {
    "name": "nginx",
    "version": "1.20.0"
  },
  "policy_ids": [
    "agent-policy-id-1"
  ]
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/fleet/package_policies" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "inputs": {},
    "name": "nginx-1",
    "namespace": "default",
    "package": {
      "name": "nginx",
      "version": "1.20.0"
    },
    "policy_ids": [
      "agent-policy-id-1"
    ]
  }'
```

## Response examples

#### Post package policy

`application/json`

The created package policy

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

#### Generic error response

`application/json`

Example of a generic error response

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

#### Conflict

`application/json`

A package policy with the same name already exists

```json
{
  "error": "Conflict",
  "message": "An error message describing what went wrong",
  "statusCode": 409
}
```

