---
type: api
title: Create or update an autoscaling policy
description: NOTE: This feature is designed for indirect use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported.
url: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/v8/operation/operation-autoscaling-put-autoscaling-policy
resource: https://www.elastic.co/elastic/docs-builder/docs/4641/api/doc/elasticsearch/v8/operation/operation-autoscaling-put-autoscaling-policy
products:
  - Elasticsearch
---

# Create or update an autoscaling policy

Authentication: required

Availability: Generally available since 7.11

## Paths

- `PUT` `/_autoscaling/policy/{name}`

#### Path parameters

- `name` (string) — required
  Name of the autoscaling policy

## Description

NOTE: This feature is designed for indirect use by Elasticsearch Service, Elastic Cloud Enterprise, and Elastic Cloud on Kubernetes. Direct use is not supported.

[Read the reference documentation](https://www.elastic.co/guide/en/cloud/current/ec-autoscaling.html)

## Query string parameters

- `master_timeout` (string · default: 30s) — optional
  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
  Period to wait for a response. If no response is received before the timeout expires, the request fails and returns an error.

## Request body

`application/json`

- `roles` (string[]) — required
- `deciders` (map string to object) — required
  Decider settings.

## Response

`application/json`

- `acknowledged` (boolean)
  For a successful response, this value is always true. On failure, an exception is returned instead.
## Code examples

### Creates or updates an autoscaling policy.

#### Console

```console
PUT /_autoscaling/policy/<name>
{
  "roles": [],
  "deciders": {
    "fixed": {
    }
  }
}
```

#### JavaScript

```javascript
const response = await client.autoscaling.putAutoscalingPolicy({
  name: "<name>",
  policy: {
    roles: [],
    deciders: {
      fixed: {},
    },
  },
});
```

#### Python

```python
resp = client.autoscaling.put_autoscaling_policy(
    name="<name>",
    policy={
        "roles": [],
        "deciders": {
            "fixed": {}
        }
    },
)
```

#### curl

```curl
curl -X PUT "$ELASTICSEARCH_URL/_autoscaling/policy/<name>" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "roles": [],
    "deciders": {
      "fixed": {}
    }
  }'
```

#### Java

```java
client.autoscaling().putAutoscalingPolicy(p -> p
    .name("<name>")
    .policy(po -> po
        .deciders("fixed", JsonData.fromJson("{}"))
    )
);
```

#### PHP

```php
$resp = $client->autoscaling()->putAutoscalingPolicy([
    "name" => "<name>",
    "body" => [
        "roles" => array(
        ),
        "deciders" => [
            "fixed" => new ArrayObject([]),
        ],
    ],
]);
```

#### Ruby

```ruby
response = client.perform_request(
  "PUT",
  "/_autoscaling/policy/&lt;name&gt;",
  {},
  {
    "roles": [],
    "deciders": {
      "fixed": {}
    }
  },
  { "Content-Type": "application/json" },
)
```

### Creates an autoscaling policy.

#### Console

```console
PUT /_autoscaling/policy/my_autoscaling_policy
{
  "roles" : [ "data_hot" ],
  "deciders": {
    "fixed": {
    }
  }
}
```

#### JavaScript

```javascript
const response = await client.autoscaling.putAutoscalingPolicy({
  name: "my_autoscaling_policy",
  policy: {
    roles: ["data_hot"],
    deciders: {
      fixed: {},
    },
  },
});
```

#### Python

```python
resp = client.autoscaling.put_autoscaling_policy(
    name="my_autoscaling_policy",
    policy={
        "roles": [
            "data_hot"
        ],
        "deciders": {
            "fixed": {}
        }
    },
)
```

#### curl

```curl
curl -X PUT "$ELASTICSEARCH_URL/_autoscaling/policy/my_autoscaling_policy" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "roles": [
      "data_hot"
    ],
    "deciders": {
      "fixed": {}
    }
  }'
```

#### Java

```java
client.autoscaling().putAutoscalingPolicy(p -> p
    .name("my_autoscaling_policy")
    .policy(po -> po
        .roles("data_hot")
        .deciders("fixed", JsonData.fromJson("{}"))
    )
);
```

#### PHP

```php
$resp = $client->autoscaling()->putAutoscalingPolicy([
    "name" => "my_autoscaling_policy",
    "body" => [
        "roles" => array(
            "data_hot",
        ),
        "deciders" => [
            "fixed" => new ArrayObject([]),
        ],
    ],
]);
```

#### Ruby

```ruby
response = client.perform_request(
  "PUT",
  "/_autoscaling/policy/my_autoscaling_policy",
  {},
  {
    "roles": [
      "data_hot"
    ],
    "deciders": {
      "fixed": {}
    }
  },
  { "Content-Type": "application/json" },
)
```

## Response examples

#### A successful response when creating an autoscaling policy.

`application/json`

```json
{
  "acknowledged": true
}
```

