---
type: api
title: Reassign an agent
description: Reassign an agent to a different agent policy.<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-reassign
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-post-fleet-agents-agentid-reassign
products:
  - Kibana
---

# Reassign an agent

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

## Paths

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

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

Reassign an agent to a different agent policy.<br/><br/>[Required authorization] Route required privileges: fleet-agents-all.

## Request Body

`application/json`

- `policy_id` (string) — required

## Responses

#### `200`

Successful response

`application/json`

Type: `object`

#### `400`

Bad Request

`application/json`

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

#### Console

```console
POST /api/fleet/agents/{agentId}/reassign
{
  "policy_id": "agent-policy-id-2"
}
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/fleet/agents/{agentId}/reassign" \
  -H "kbn-xsrf: true" \
  -H "Content-Type: application/json" \
  -d '{
  "policy_id": "agent-policy-id-2"
}'
```

## Response Examples

#### Post reassign agent

Agent successfully reassigned

```json
{}
```

#### Generic error response

Example of a generic error response

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

