---
type: api
title: Run a policy
description: Immediately create a snapshot according to the snapshot lifecycle policy without waiting for the scheduled time.
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/v8/operation/operation-slm-execute-lifecycle
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/v8/operation/operation-slm-execute-lifecycle
products:
  - Elasticsearch
---

# Run a policy

Authentication: required

Availability: Generally available since 7.4

## Paths

- `PUT` `/_slm/policy/{policy_id}/_execute`

#### Path parameters

- `policy_id` (string) — required
  The id of the snapshot lifecycle policy to be executed

## Description

Immediately create a snapshot according to the snapshot lifecycle policy without waiting for the scheduled time.
The snapshot policy is normally applied according to its schedule, but you might want to manually run a policy before performing an upgrade or other maintenance.

## 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`

- `snapshot_name` (string)
## Code examples

#### Console

```console
PUT /_slm/policy/daily-snapshots/_execute
```

#### JavaScript

```javascript
const response = await client.slm.executeLifecycle({
  policy_id: "daily-snapshots",
});
```

#### Python

```python
resp = client.slm.execute_lifecycle(
    policy_id="daily-snapshots",
)
```

#### curl

```curl
curl -X PUT "$ELASTICSEARCH_URL/_slm/policy/daily-snapshots/_execute" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.slm().executeLifecycle(e -> e
    .policyId("daily-snapshots")
);
```

#### C#

```c#
var response = await client.SnapshotLifecycleManagement.ExecuteLifecycleAsync(policyId: "daily-snapshots");
```

#### PHP

```php
$resp = $client->slm()->executeLifecycle([
    "policy_id" => "daily-snapshots",
]);
```

#### Ruby

```ruby
response = client.slm.execute_lifecycle(
  policy_id: "daily-snapshots"
)
```

## Response examples

#### Execute snapshot lifecycle response example1

`application/json`

Run `POST /_slm/policy/daily-snapshots/_execute` to take an immediate snapshot according to the `daily-snapshots` policy.

```json
{
  "snapshot_name": "daily-snap-2019.04.24-gwrqoo2xtea3q57vvg0uea"
}
```

