---
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/4641/api/doc/elasticsearch/v9/operation/operation-slm-execute-retention
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/v9/operation/operation-slm-execute-retention
products:
  - Elasticsearch
---

# Run a retention policy

Authentication: required

Availability: Generally available since 7.5

## Paths

- `POST` `/_slm/_execute_retention`

## 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 · default: 30s) — optional
  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 · default: 30s) — optional
  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
```

## Response examples

#### 200

`application/json`

Generated from the API spec. Values are representative. Unions use the first variant; deeply nested or large bodies may omit fields.

```json
{
  "acknowledged": false
}
```

