---
type: api
title: Bulk upgrade agents
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana-serverless/operation/operation-post-fleet-agents-bulk-upgrade
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana-serverless/operation/operation-post-fleet-agents-bulk-upgrade
products:
  - Kibana
---

# Bulk upgrade agents

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

## Paths

- `POST` `/api/fleet/agents/bulk_upgrade`
- `POST` `/s/{space_id}/api/fleet/agents/bulk_upgrade`

## Description

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

Upgrade multiple agents to a newer version, with optional rollout controls.

## Required authorization

- Privileges: `fleet-agents-all`

## Authentication

- Api key: `Authorization: <value>`
  You must create an API key and use the encoded value in the request header. To learn about creating keys, go to [API keys](https://www.elastic.co/docs/current/serverless/api-keys).

## Header parameters

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

## Request body

`application/json`

- `agents` (union string[] | string) — required
- `batchSize` (number) — optional
- `dryRun` (boolean) — optional
- `force` (boolean) — optional
- `includeInactive` (boolean · default: false) — optional
- `rollout_duration_seconds` (number · min: 600) — optional
- `skipRateLimitCheck` (boolean) — optional
- `source_uri` (string) — optional
- `start_time` (string) — optional
- `version` (string) — required

## Responses

#### `200`

Successful response

`application/json`

Any of:
- **{ actionId }**
  - `actionId` (string)
- **{ count }**
  - `count` (number)
#### `400`

Bad Request

`application/json`

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

#### Console

```console
POST kbn:/api/fleet/agents/bulk_upgrade
{
  "agents": [
    "agent-id-1",
    "agent-id-2"
  ],
  "rollout_duration_seconds": 3600,
  "version": "8.17.0"
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/fleet/agents/bulk_upgrade" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "agents": [
      "agent-id-1",
      "agent-id-2"
    ],
    "rollout_duration_seconds": 3600,
    "version": "8.17.0"
  }'
```

## Response examples

#### Post bulk upgrade agents

Bulk upgrade action result

```json
{
  "actionId": "action-id-1"
}
```

#### Generic error response

Example of a generic error response

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

