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

# Run an enrich policy

Availability: Generally available since 7.5

## Paths

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

#### Path parameters

- `name` (string) — required
  Enrich policy to execute.

## Description

Create the enrich index for an existing enrich policy.

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs support key-based authentication.
  You must create an API key and use the encoded value in the request header.
  For example:
  
  
  ```
  curl -X GET "${ES_URL}/_cat/indices?v=true" \
    -H "Authorization: ApiKey ${API_KEY}"
  ```
  
  To get API keys, use the `/_security/api_key` APIs.
- Basic: `Authorization: Basic <credentials>`
- Bearer: `Authorization: Bearer <token>`
  Elasticsearch APIs support the use of bearer tokens in the `Authorization` HTTP header to authenticate with the API.
  For examples, refer to [Token-based authentication services](https://www.elastic.co/docs/deploy-manage/users-roles/cluster-or-deployment-auth/token-based-authentication-services)

## Query string parameters

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

## Response

`application/json`

- `status` (object)
  - `phase` (enum)
    Values: `SCHEDULED`, `RUNNING`, `COMPLETE`, `FAILED`, `CANCELLED`
  - `step` (string)
- `task` (string)
## 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"
)
```

