---
type: api
title: Migrate a single agent
description: Migrate a single agent 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-agentid-migrate
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/v0/operation/operation-post-fleet-agents-agentid-migrate
products:
  - Kibana
---

# Migrate a single agent

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

## Paths

- `POST` `/api/fleet/agents/{agentId}/migrate`

#### Path parameters

- `agentId` (string) — required
  The agent ID

## Description

Migrate a single agent 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`

- `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
  - `replace_token` (string) — optional
  - `staging` (string) — optional
  - `tags` (string[] · max items: 10) — optional
- `uri` (string · format: uri) — required

## Responses

#### `200`

Successful response

`application/json`

- `actionId` (string)
#### `400`

Bad Request

`application/json`

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

#### Console

```console
POST kbn:/api/fleet/agents/AGENT_ID/migrate
{
  "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/${AGENT_ID}/migrate" \
  -H "kbn-xsrf: true" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "enrollment_token": "enrollment-token-value",
    "settings": {
      "retry_max": 5
    },
    "uri": "https://fleet-server.example.com:8220"
  }'
```

## Response examples

#### Post migrate agent

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

