---
type: api
title: Create package policy
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v8/operation/operation-create-package-policy
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v8/operation/operation-create-package-policy
products:
  - Kibana
---

# Create package policy

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

## Paths

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

## Description

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

## Authentication

- Api key: `Authorization: <value>`
  These APIs use key-based authentication. You must create an API key and use the encoded value in the request header. For example: `Authorization: ApiKey base64AccessApiKey`
- Basic: `Authorization: Basic <credentials>`

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

You should use inputs as an object and not use the deprecated inputs array.

`application/json`

- `description` (string) — optional
  Package policy description
- `force` (boolean) — optional
  Force package policy creation even if package is not verified, or if the agent policy is managed.
- `id` (string) — optional
  Package policy unique identifier
- `inputs` (map string to object) — optional
  Package policy inputs (see integration documentation to know what inputs are available)
  Map values (object)
  - `enabled` (boolean) — optional
    enable or disable that input, (default to true)
  - `streams` (map string to object) — optional
    Input streams (see integration documentation to know what streams are available)
    Map values (object)
    - `enabled` (boolean) — optional
      enable or disable that stream, (default to true)
    - `vars` (object) — optional
      Stream level variable (see integration documentation for more information)
  - `vars` (object) — optional
    Input level variable (see integration documentation for more information)
- `name` (string) — required
  Package policy name (should be unique)
- `namespace` (string) — optional
  The package policy namespace. Leave blank to inherit the agent policy's namespace.
- `output_id` (string) — optional — nullable
  Output ID to send package data to
- `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` (object) — optional
- `package` (object) — required
  - `name` (string) — required
    Package name
  - `version` (string) — required
    Package version
- `policy_id` (string) — optional — nullable — deprecated
  Agent policy ID where that package policy will be added
- `policy_ids` (string[]) — optional
  Agent policy IDs where that package policy will be added
- `vars` (object) — optional
  Package root level variable (see integration documentation for more information)

## Responses

#### `200`

OK

`application/json`

- `item` (object)
  - `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[])
#### `400`

Generic Error

`application/json`

- `error` (string)
- `message` (string)
- `statusCode` (number)
#### `409`

Generic Error

`application/json`

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

#### Console

```console
POST kbn:/api/fleet/package_policies
{
  "name": "nginx-123",
  "package": {
    "name": "nginx",
    "version": "1.6.0"
  }
}
```

#### 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 '{
    "name": "nginx-123",
    "package": {
      "name": "nginx",
      "version": "1.6.0"
    }
  }'
```

