---
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/4371/api/doc/kibana/v0/operation/operation-post-fleet-agents-agentid-migrate
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/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`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v0/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v0/authentication#basicauth)

#### Path Parameters

- `agentId` (string)
  The agent ID

## Description

Migrate a single agent to another cluster.<br/><br/>[Required authorization] Route required privileges: fleet-agents-all.

## 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: 10) — optional
- `uri` (string) — 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 /api/fleet/agents/{agentId}/migrate
{
  "enrollment_token": "enrollment-token-value",
  "settings": {
    "retry_max": 5
  },
  "uri": "https://fleet-server.example.com:8220"
}
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/fleet/agents/{agentId}/migrate" \
  -H "kbn-xsrf: true" \
  -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
}
```

