---
type: api
title: Convert an index alias to a data stream
description: Converts an index alias to a data stream.
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-indices-migrate-to-data-stream
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/elasticsearch/v8/operation/operation-indices-migrate-to-data-stream
products:
  - Elasticsearch
---

# Convert an index alias to a data stream

Availability: 7.9+

## Paths

- `POST` `/_data_stream/_migrate/{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 IndexName)
  Name of the index alias to convert to a data stream.

## Description

Converts an index alias to a data stream.
You must have a matching index template that is data stream enabled.
The alias must meet the following criteria:
The alias must have a write index;
All indices for the alias must have a `@timestamp` field mapping of a `date` or `date_nanos` field type;
The alias must not have any filters;
The alias must not use custom routing.
If successful, the request removes the alias and creates a data stream with the same name.
The indices for the alias become hidden backing indices for the stream.
The write index for the alias becomes the write index for the stream.

## Required authorization

* Index privileges: `manage`

## 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.

## 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/_migrate/my-time-series-data
```

#### JavaScript

```javascript
const response = await client.indices.migrateToDataStream({
  name: "my-time-series-data",
});
```

#### Python

```python
resp = client.indices.migrate_to_data_stream(
    name="my-time-series-data",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_data_stream/_migrate/my-time-series-data" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.indices().migrateToDataStream(m -> m
    .name("my-time-series-data")
);
```

#### C#

```c#
var response = await client.Indices.MigrateToDataStreamAsync(name: "my-time-series-data");
```

#### PHP

```php
$resp = $client->indices()->migrateToDataStream([
    "name" => "my-time-series-data",
]);
```

#### Ruby

```ruby
response = client.indices.migrate_to_data_stream(
  name: "my-time-series-data"
)
```

