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

# Run a policy

Availability: 7.4+

## Paths

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

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

- `policy_id` (string Name)
  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 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`

- `snapshot_name` (string Name)
## 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

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"
}
```

