---
type: api
title: Run a retention policy
description: Manually apply the retention policy to force immediate removal of snapshots that are expired according to the snapshot lifecycle policy retention rules.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-slm-execute-retention
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-slm-execute-retention
products:
  - Elasticsearch
---

# Run a retention policy

Availability: 7.5+

## Paths

- `POST` `/_slm/_execute_retention`

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

## Description

Manually apply the retention policy to force immediate removal of snapshots that are expired according to the snapshot lifecycle policy retention rules.
The retention policy is normally applied according to its schedule.

## Required authorization

* Cluster privileges: `manage_slm`

## Query String Parameters

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

## Response

`application/json`

- `acknowledged` (boolean)
  For a successful response, this value is always true. On failure, an exception is returned instead.
## Code Examples

#### Console

```console
POST _slm/_execute_retention
```

#### JavaScript

```javascript
const response = await client.slm.executeRetention();
```

#### Python

```python
resp = client.slm.execute_retention()
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_slm/_execute_retention" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.slm().executeRetention(e -> e);
```

#### C#

```c#
var response = await client.SnapshotLifecycleManagement.ExecuteRetentionAsync();
```

#### PHP

```php
$resp = $client->slm()->executeRetention();
```

#### Ruby

```ruby
response = client.slm.execute_retention
```

