---
type: api
title: Forget a follower
description: Remove the cross-cluster replication follower retention leases from the leader.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-ccr-forget-follower
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/operation/operation-ccr-forget-follower
products:
  - Elasticsearch
---

# Forget a follower

Availability: 6.7+

## Paths

- `POST` `/{index}/_ccr/forget_follower`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v9/authentication#bearerauth)

#### Path Parameters

- `index` (string IndexName)
  Name of the leader index for which specified follower retention leases should be removed

## Description

Remove the cross-cluster replication follower retention leases from the leader.

A following index takes out retention leases on its leader index.
These leases are used to increase the likelihood that the shards of the leader index retain the history of operations that the shards of the following index need to run replication.
When a follower index is converted to a regular index by the unfollow API (either by directly calling the API or by index lifecycle management tasks), these leases are removed.
However, removal of the leases can fail, for example when the remote cluster containing the leader index is unavailable.
While the leases will eventually expire on their own, their extended existence can cause the leader index to hold more history than necessary and prevent index lifecycle management from performing some operations on the leader index.
This API exists to enable manually removing the leases when the unfollow API is unable to do so.

NOTE: This API does not stop replication by a following index. If you use this API with a follower index that is still actively following, the following index will add back retention leases on the leader.
The only purpose of this API is to handle the case of failure to remove the following retention leases after the unfollow API is invoked.

[About cross-cluster replication](https://www.elastic.co/docs/deploy-manage/tools/cross-cluster-replication)

## Query String Parameters

- `timeout` (string Duration · default: 30s)
  Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

## Request Body

`application/json`

- `follower_cluster` (string) — optional
- `follower_index` (string IndexName) — optional
- `follower_index_uuid` (string) — optional
- `leader_remote_cluster` (string) — optional

## Response

`application/json`

- `_shards` ({} ShardStatistics)
  - `failed` (number uint)
    The number of shards the operation or search attempted to run on but failed.
  - `successful` (number uint)
    The number of shards the operation or search succeeded on.
  - `total` (number uint)
    The number of shards the operation or search will run on overall.
  - `failures` ([] ShardFailure)
    - `index` (string IndexName)
    - `node` (string)
    - `reason` ({} ErrorCause)
      - `type` (string)
        The type of error
      - `reason` (union string) — nullable
        A human-readable explanation of the error, in English.
        One of: `string`
      - `stack_trace` (string)
        The server stack trace. Present only if the `error_trace=true` parameter was sent with the request.
      - `caused_by` ({} ErrorCause) — recursive
        Same fields as `reason` in `failures`
      - `root_cause` ([] ErrorCause) — recursive
        Same fields as `reason` in `failures`
      - `suppressed` ([] ErrorCause) — recursive
        Same fields as `reason` in `failures`
    - `shard` (number)
    - `status` (string)
    - `primary` (boolean)
  - `skipped` (number uint)
## Code Examples

#### Console

```console
POST /<leader_index>/_ccr/forget_follower
{
  "follower_cluster" : "<follower_cluster>",
  "follower_index" : "<follower_index>",
  "follower_index_uuid" : "<follower_index_uuid>",
  "leader_remote_cluster" : "<leader_remote_cluster>"
}
```

#### JavaScript

```javascript
const response = await client.ccr.forgetFollower({
  index: "<leader_index>",
  follower_cluster: "<follower_cluster>",
  follower_index: "<follower_index>",
  follower_index_uuid: "<follower_index_uuid>",
  leader_remote_cluster: "<leader_remote_cluster>",
});
```

#### Python

```python
resp = client.ccr.forget_follower(
    index="<leader_index>",
    follower_cluster="<follower_cluster>",
    follower_index="<follower_index>",
    follower_index_uuid="<follower_index_uuid>",
    leader_remote_cluster="<leader_remote_cluster>",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/<leader_index>/_ccr/forget_follower" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "follower_cluster": "\u003Cfollower_cluster\u003E",
    "follower_index": "\u003Cfollower_index\u003E",
    "follower_index_uuid": "\u003Cfollower_index_uuid\u003E",
    "leader_remote_cluster": "\u003Cleader_remote_cluster\u003E"
  }'
```

#### Java

```java
client.ccr().forgetFollower(f -> f
    .followerCluster("<follower_cluster>")
    .followerIndex("<follower_index>")
    .followerIndexUuid("<follower_index_uuid>")
    .index("<leader_index>")
    .leaderRemoteCluster("<leader_remote_cluster>")
);
```

#### C#

```c#
var response = await client.CrossClusterReplication
    .ForgetFollowerAsync(index: "<leader_index>", d1 => d1
        .FollowerCluster("<follower_cluster>")
        .FollowerIndex("<follower_index>")
        .FollowerIndexUuid("<follower_index_uuid>")
        .LeaderRemoteCluster("<leader_remote_cluster>")
    );
```

#### PHP

```php
$resp = $client->ccr()->forgetFollower([
    "index" => "<leader_index>",
    "body" => [
        "follower_cluster" => "<follower_cluster>",
        "follower_index" => "<follower_index>",
        "follower_index_uuid" => "<follower_index_uuid>",
        "leader_remote_cluster" => "<leader_remote_cluster>",
    ],
]);
```

#### Ruby

```ruby
response = client.ccr.forget_follower(
  index: "<leader_index>",
  body: {
    "follower_cluster": "<follower_cluster>",
    "follower_index": "<follower_index>",
    "follower_index_uuid": "<follower_index_uuid>",
    "leader_remote_cluster": "<leader_remote_cluster>"
  }
)
```

## Response Examples

#### Forget follower index response example1

A successful response for removing the follower retention leases from the leader index.

```json
{
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0,
    "failures" : [ ]
  }
}
```

