---
type: api
title: Migrate multiple agents
description: Bulk migrate agents to another cluster.<br/><br/>[Required authorization] Route required privileges: fleet-agents-all.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v0/operation/operation-post-fleet-agents-bulk-migrate
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v0/operation/operation-post-fleet-agents-bulk-migrate
products:
  - Kibana
---

# Migrate multiple agents

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

## Paths

- `POST` `/api/fleet/agents/bulk_migrate`

## Description

Bulk migrate agents to another cluster.

## Required authorization

- Privileges: `fleet-agents-all`

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

## 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
- `enrollment_token` (string) — required
- `settings` (object) — optional
  - `ca_sha256` (string) — optional
  - `certificate_authorities` (string) — optional
  - `elastic_agent_cert` (string) — optional
  - `elastic_agent_cert_key` (string) — optional
  - `elastic_agent_cert_key_passphrase` (string) — optional
  - `headers` (map string to string) — optional
  - `insecure` (boolean) — optional
  - `proxy_disabled` (boolean) — optional
  - `proxy_headers` (map string to string) — optional
  - `proxy_url` (string) — optional
  - `staging` (string) — optional
  - `tags` (string[] · max items: 10) — optional
- `uri` (string · format: uri) — 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_migrate
{
  "agents": [
    "agent-id-1",
    "agent-id-2"
  ],
  "enrollment_token": "enrollment-token-value",
  "settings": {
    "retry_max": 5
  },
  "uri": "https://fleet-server.example.com:8220"
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/fleet/agents/bulk_migrate" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "agents": [
      "agent-id-1",
      "agent-id-2"
    ],
    "enrollment_token": "enrollment-token-value",
    "settings": {
      "retry_max": 5
    },
    "uri": "https://fleet-server.example.com:8220"
  }'
```

## Response examples

#### Post bulk migrate agents

Bulk agent migration initiated

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

