---
type: api
title: Update data streams
description: Performs one or more data stream modification actions in a single atomic operation.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-indices-modify-data-stream
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-indices-modify-data-stream
products:
  - Elasticsearch
---

# Update data streams

Availability: 7.16+

## Paths

- `POST` `/_data_stream/_modify`

- [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)

## Description

Performs one or more data stream modification actions in a single atomic operation.

## Request Body

`application/json`

- `actions` ([] Action) — required
  Actions to perform.
  - `add_backing_index` ({} IndexAndDataStreamAction) — optional
    Adds an existing index as a backing index for a data stream.
The index is hidden as part of this operation.
WARNING: Adding indices with the `add_backing_index` action can potentially result in improper data stream behavior.
This should be considered an expert level API.
    - `data_stream` (string) — required
      Data stream targeted by the action.
    - `index` (string IndexName) — required
      Index for the action.
  - `remove_backing_index` ({} IndexAndDataStreamAction) — optional
    Removes a backing index from a data stream.
The index is unhidden as part of this operation.
A data stream’s write index cannot be removed.
    - `data_stream` (string) — required
      Data stream targeted by the action.
    - `index` (string IndexName) — required
      Index for the action.

## 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
POST _data_stream/_modify
{
  "actions": [
    {
      "remove_backing_index": {
        "data_stream": "my-data-stream",
        "index": ".ds-my-data-stream-2023.07.26-000001"
      }
    },
    {
      "add_backing_index": {
        "data_stream": "my-data-stream",
        "index": ".ds-my-data-stream-2023.07.26-000001-downsample"
      }
    }
  ]
}
```

#### JavaScript

```javascript
const response = await client.indices.modifyDataStream({
  actions: [
    {
      remove_backing_index: {
        data_stream: "my-data-stream",
        index: ".ds-my-data-stream-2023.07.26-000001",
      },
    },
    {
      add_backing_index: {
        data_stream: "my-data-stream",
        index: ".ds-my-data-stream-2023.07.26-000001-downsample",
      },
    },
  ],
});
```

#### Python

```python
resp = client.indices.modify_data_stream(
    actions=[
        {
            "remove_backing_index": {
                "data_stream": "my-data-stream",
                "index": ".ds-my-data-stream-2023.07.26-000001"
            }
        },
        {
            "add_backing_index": {
                "data_stream": "my-data-stream",
                "index": ".ds-my-data-stream-2023.07.26-000001-downsample"
            }
        }
    ],
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_data_stream/_modify" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "actions": [
      {
        "remove_backing_index": {
          "data_stream": "my-data-stream",
          "index": ".ds-my-data-stream-2023.07.26-000001"
        }
      },
      {
        "add_backing_index": {
          "data_stream": "my-data-stream",
          "index": ".ds-my-data-stream-2023.07.26-000001-downsample"
        }
      }
    ]
  }'
```

#### Java

```java
client.indices().modifyDataStream(m -> m
    .actions(List.of(Action.of(a -> a
            .removeBackingIndex(r -> r
                .dataStream("my-data-stream")
                .index(".ds-my-data-stream-2023.07.26-000001")
        )),Action.of(ac -> ac
            .addBackingIndex(ad -> ad
                .dataStream("my-data-stream")
                .index(".ds-my-data-stream-2023.07.26-000001-downsample")
        ))))
);
```

#### C#

```c#
var response = await client.Indices
    .ModifyDataStreamAsync(d1 => d1
        .Actions(d2 => d2
            .RemoveBackingIndex(d3 => d3
                .DataStream("my-data-stream")
                .Index(".ds-my-data-stream-2023.07.26-000001")
            ), d2 => d2
            .AddBackingIndex(d3 => d3
                .DataStream("my-data-stream")
                .Index(".ds-my-data-stream-2023.07.26-000001-downsample")
            )
        )
    );
```

#### PHP

```php
$resp = $client->indices()->modifyDataStream([
    "body" => [
        "actions" => array(
            [
                "remove_backing_index" => [
                    "data_stream" => "my-data-stream",
                    "index" => ".ds-my-data-stream-2023.07.26-000001",
                ],
            ],
            [
                "add_backing_index" => [
                    "data_stream" => "my-data-stream",
                    "index" => ".ds-my-data-stream-2023.07.26-000001-downsample",
                ],
            ],
        ),
    ],
]);
```

#### Ruby

```ruby
response = client.indices.modify_data_stream(
  body: {
    "actions": [
      {
        "remove_backing_index": {
          "data_stream": "my-data-stream",
          "index": ".ds-my-data-stream-2023.07.26-000001"
        }
      },
      {
        "add_backing_index": {
          "data_stream": "my-data-stream",
          "index": ".ds-my-data-stream-2023.07.26-000001-downsample"
        }
      }
    ]
  }
)
```

