---
type: api
title: Rotate an uninstall token
description: Rotate the uninstall token for an agent policy. Only applicable to policies with tamper protection enabled.<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-uninstall-tokens-agentpolicyid-rotate
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v0/operation/operation-post-fleet-uninstall-tokens-agentpolicyid-rotate
products:
  - Kibana
---

# Rotate an uninstall token

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

## Paths

- `POST` `/api/fleet/uninstall_tokens/{agentPolicyId}/rotate`

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

- `agentPolicyId` (string · max: 255)
  The ID of the agent policy whose uninstall token should be rotated

## Description

Rotate the uninstall token for an agent policy. Only applicable to policies with tamper protection enabled.<br/><br/>[Required authorization] Route required privileges: fleet-agents-all.

## Responses

#### `200`

Successful response

`application/json`

- `message` (string)
#### `400`

Bad Request

`application/json`

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

Not Found

`application/json`

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

#### Console

```console
POST /api/fleet/uninstall_tokens/{agentPolicyId}/rotate
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/fleet/uninstall_tokens/{agentPolicyId}/rotate" \
  -H "kbn-xsrf: true"
```

## Response Examples

#### Rotate uninstall token

Uninstall token rotated successfully for the given agent policy

```json
{
  "message": "Uninstall token rotated successfully."
}
```

#### Generic error response

Example of a generic error response

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

#### Not protected

Agent policy does not have tamper protection enabled

```json
{
  "error": "Bad Request",
  "message": "Agent policy [policy-id-1] does not have tamper protection enabled. Uninstall tokens can only be rotated for protected policies.",
  "statusCode": 400
}
```

#### Not found

No agent policy was found with the given ID

```json
{
  "error": "Not Found",
  "message": "Agent policy not found with id policy-id-1",
  "statusCode": 404
}
```

