---
type: api
title: Run an enrich policy
description: Create the enrich index for an existing enrich policy.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-enrich-execute-policy
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/operation/operation-enrich-execute-policy
products:
  - Elasticsearch Serverless
---

# Run an enrich policy

Availability:

## Paths

- `PUT` `/_enrich/policy/{name}/_execute`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch-serverless/authentication#apikeyauth)

#### Path Parameters

- `name` (string Name)
  Enrich policy to execute.

## Description

Create the enrich index for an existing enrich policy.

## Query String Parameters

- `master_timeout` (string Duration · default: 30s)
  Period to wait for a connection to the master node.
- `wait_for_completion` (boolean · default: true)
  If `true`, the request blocks other enrich policy execution requests until complete.

## Response

`application/json`

- `status` ({} ExecuteEnrichPolicyStatus)
  - `phase` (enum EnrichPolicyPhase)
    Values: `SCHEDULED`, `RUNNING`, `COMPLETE`, `FAILED`, `CANCELLED`
  - `step` (string)
- `task` (string TaskId)
## Code Examples

#### Console

```console
PUT /_enrich/policy/my-policy/_execute?wait_for_completion=false
```

#### JavaScript

```javascript
const response = await client.enrich.executePolicy({
  name: "my-policy",
  wait_for_completion: "false",
});
```

#### Python

```python
resp = client.enrich.execute_policy(
    name="my-policy",
    wait_for_completion=False,
)
```

#### curl

```curl
curl -X PUT "$ELASTICSEARCH_URL/_enrich/policy/my-policy/_execute?wait_for_completion=false" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.enrich().executePolicy(e -> e
    .name("my-policy")
    .waitForCompletion(false)
);
```

#### C#

```c#
var response = await client.Enrich
    .ExecutePolicyAsync(name: "my-policy", d1 => d1
        .WaitForCompletion(false)
    );
```

#### PHP

```php
$resp = $client->enrich()->executePolicy([
    "name" => "my-policy",
    "wait_for_completion" => "false",
]);
```

#### Ruby

```ruby
response = client.enrich.execute_policy(
  name: "my-policy",
  wait_for_completion: "false"
)
```

