---
type: api
title: Update security index settings
description: Update the user-configurable settings for the security internal index (`.security` and associated indices). Only a subset of settings are allowed to be modified. This includes `index.auto_expand_replicas` and `index.number_of_replicas`.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-security-update-settings
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch/v8/operation/operation-security-update-settings
products:
  - Elasticsearch
---

# Update security index settings

## Paths

- `PUT` `/_security/settings`

## Description

Update the user-configurable settings for the security internal index (`.security` and associated indices). Only a subset of settings are allowed to be modified. This includes `index.auto_expand_replicas` and `index.number_of_replicas`.

NOTE: If `index.auto_expand_replicas` is set, `index.number_of_replicas` will be ignored during updates.

If a specific index is not in use on the system and settings are provided for it, the request will be rejected.
This API does not yet support configuring the settings for indices before they are in use.

## Required authorization

- Cluster privileges: `manage_security`

## 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/guide/en/elasticsearch/reference/current/token-authentication-services.html)

## Query string parameters

- `master_timeout` (string · default: 30s) — optional
  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) — optional
  The 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`

- `security` (object) — optional
  Settings for the index used for most security configuration, including native realm users and roles configured with the API.
  - `index` (object) — optional
- `security-profile` (object) — optional
  Settings for the index used to store profile information.
  - `index` (object) — optional
- `security-tokens` (object) — optional
  Settings for the index used to store tokens.
  - `index` (object) — optional

## Response

`application/json`

- `acknowledged` (boolean)
## Code examples

#### Console

```console
PUT /_security/settings
{
    "security": {
        "index.auto_expand_replicas": "0-all"
    },
    "security-tokens": {
        "index.auto_expand_replicas": "0-all"
    },
    "security-profile": {
        "index.auto_expand_replicas": "0-all"
    }
}
```

#### JavaScript

```javascript
const response = await client.security.updateSettings({
  security: {
    "index.auto_expand_replicas": "0-all",
  },
  "security-tokens": {
    "index.auto_expand_replicas": "0-all",
  },
  "security-profile": {
    "index.auto_expand_replicas": "0-all",
  },
});
```

#### Python

```python
resp = client.security.update_settings(
    security={
        "index.auto_expand_replicas": "0-all"
    },
    security_tokens={
        "index.auto_expand_replicas": "0-all"
    },
    security_profile={
        "index.auto_expand_replicas": "0-all"
    },
)
```

#### curl

```curl
curl -X PUT "$ELASTICSEARCH_URL/_security/settings" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "security": {
      "index.auto_expand_replicas": "0-all"
    },
    "security-tokens": {
      "index.auto_expand_replicas": "0-all"
    },
    "security-profile": {
      "index.auto_expand_replicas": "0-all"
    }
  }'
```

#### Java

```java
client.security().updateSettings(u -> u
    .security(s -> s)
    .securityProfile(s -> s)
    .securityTokens(s -> s)
);
```

#### C#

```c#
var response = await client.Security
    .UpdateSettingsAsync(d1 => d1
        .Security()
        .SecurityProfile()
        .SecurityTokens()
    );
```

#### PHP

```php
$resp = $client->security()->updateSettings([
    "body" => [
        "security" => [
            "index.auto_expand_replicas" => "0-all",
        ],
        "security-tokens" => [
            "index.auto_expand_replicas" => "0-all",
        ],
        "security-profile" => [
            "index.auto_expand_replicas" => "0-all",
        ],
    ],
]);
```

#### Ruby

```ruby
response = client.security.update_settings(
  body: {
    "security": {
      "index.auto_expand_replicas": "0-all"
    },
    "security-tokens": {
      "index.auto_expand_replicas": "0-all"
    },
    "security-profile": {
      "index.auto_expand_replicas": "0-all"
    }
  }
)
```

