---
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/4371/api/doc/elasticsearch/v8/operation/operation-autoscaling-put-autoscaling-policy
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-autoscaling-put-autoscaling-policy
products:
  - Elasticsearch
---

# Create or update an autoscaling policy

Availability: 7.11+

## Paths

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

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#basicauth)
- [Bearer auth](/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/authentication#bearerauth)

#### Path Parameters

- `name` (string Name)
  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 Duration · default: 30s)
  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)
  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

#### 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" },
)
```

## Response Examples

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

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

