---
type: api
title: "Upgrade a package policy"
description: "Upgrade a package policy to a newer package version. When some package policies are upgraded and the others are only blocked because some active agents don't satisfy the package's agent version condition, the response is a 200 with a result per package policy: check each item's success field. When any other upgrade fails, the response is the first such failure. When none succeeds and every failure is an agent version block, the response is the first block. [Required authorization] Route required privileges: fleet-agent-policies-all AND integrations-all."
url: https://www.elastic.co/elastic/docs-builder/docs/5066/api/kibana-serverless/operation/operation-post-fleet-package-policies-upgrade
resource: https://www.elastic.co/elastic/docs-builder/docs/5066/api/kibana-serverless/operation/operation-post-fleet-package-policies-upgrade
products:
  - Kibana
---

# Upgrade a package policy

Authentication: required

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

## Paths

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

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

Upgrade a package policy to a newer package version. When some package policies are upgraded and the others are only blocked because some active agents don't satisfy the package's agent version condition, the response is a 200 with a result per package policy: check each item's `success` field. When any other upgrade fails, the response is the first such failure. When none succeeds and every failure is an agent version block, the response is the first block.

## Required privileges

- Privileges: `fleet-agent-policies-all` and `integrations-all`

## Header parameters

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

## Request body

`application/json`

- `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.
- `acknowledge_breaking_changes` (boolean · default: false) — optional
  When true, acknowledge the breaking changes listed in the package changelog for the versions being upgraded. Without it, an upgrade whose version range includes breaking changes is rejected. The `force` flag does not bypass this check.
- `packagePolicyIds` (string[] · max items: 1000) — required

## Responses

#### `200`

Successful response

`application/json`

Type: `object[] · max items: 10000`

An array; each item has these fields:

- `body` (object)
  - `attributes` (object)
    Details of the error. `type` is `agent_version_incompatible` when the package policy was not upgraded because some active agents do not satisfy the package agent version condition.
  - `message` (string)
- `id` (string)
- `name` (string)
- `statusCode` (number)
- `success` (boolean)
#### `400`

Bad Request

`application/json`

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

#### Console

```console
POST kbn:/api/fleet/package_policies/upgrade
{
  "packagePolicyIds": [
    "package-policy-id-1"
  ]
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/fleet/package_policies/upgrade" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "packagePolicyIds": [
      "package-policy-id-1"
    ]
  }'
```

## Response examples

#### Post upgrade package policies

`application/json`

Results of the upgrade operation

```json
[
  {
    "id": "package-policy-id-1",
    "name": "nginx-1",
    "success": true
  }
]
```

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

