﻿---
title: Migrate Elasticsearch data using the reindex API
description: The reindex API offers a convenient way for you to copy your Elasticsearch documents from a source index, data stream, or alias in one deployment to another...
url: https://docs-v3-preview.elastic.dev/elastic/docs-content/tree/main/manage-data/migrate/migrate-data-using-reindex-api
products:
  - Elastic Cloud Hosted
  - Elasticsearch
applies_to:
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Generally available
---

# Migrate Elasticsearch data using the reindex API
The [reindex API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-reindex) offers a convenient way for you to copy your Elasticsearch documents from a source index, data stream, or alias in one deployment to another.
<important>
  This guide gives the example of reindexing a full index from an Elastic Cloud Hosted deployment to an Elastic Cloud Serverless project using the remote host parameters as shown in the [reindex from remote](https://docs-v3-preview.elastic.dev/elastic/elasticsearch/tree/main/reference/elasticsearch/rest-apis/reindex-indices#reindex-from-remote) example. These steps can be adapted to other deployment types as well. When you copy your data to deployment types other than Serverless, there are [additional considerations](#migrate-reindex-from-remote-others) to make note of.
</important>

For more advanced use cases, including data modification using scripts or ingest pipelines, refer to the [Reindex indices examples](https://docs-v3-preview.elastic.dev/elastic/elasticsearch/tree/main/reference/elasticsearch/rest-apis/reindex-indices#reindex-from-remote) and the [reindex API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-reindex) documentation.

## Prerequisites

- An Elastic Cloud Hosted deployment with data to migrate
- An [Elastic Cloud Serverless](https://docs-v3-preview.elastic.dev/elastic/docs-content/tree/main/deploy-manage/deploy/elastic-cloud/serverless) project configured and running
- An [API key](https://docs-v3-preview.elastic.dev/elastic/docs-content/tree/main/deploy-manage/api-keys/elastic-cloud-api-keys) for authentication with the Elastic Cloud Hosted deployment
  Basic authentication can be used in place of an API key, but an API key is recommended as a more secure option.

<important>
  Kibana assets must be migrated separately using the Kibana [export/import APIs](https://www.elastic.co/docs/api/doc/kibana/group/endpoint-saved-objects) or recreated manually. Refer to [Migration options](/elastic/docs-content/tree/main/manage-data/migrate#migration-options) for details about migrating different types of Elasticsearch data.Index templates, data stream definitions, and data lifecycle settings must be in place _before_ you start reindexing data. However, if you have any [ingest pipelines](https://docs-v3-preview.elastic.dev/elastic/docs-content/tree/main/manage-data/ingest/transform-enrich/ingest-pipelines) configured, it's typically best to add these _after_ data migration so as to avoid re-transforming data that had already been transformed at the time that it was ingested into your source deployment. If the data is idempotent, re-transforming is not a concern.Visual components, such dashboard and visualizations, can be migrated after you have migrated the data.
</important>


## Migrate documents from Elastic Cloud Hosted to Serverless

The following steps walk you through locating the source index and Elasticsearch endpoint in your Elastic Cloud Hosted deployment, then running a remote reindex from your Serverless project so documents are copied into a destination index.
1. In your Elastic Cloud Hosted deployment:
   1. Navigate to the deployment home page and copy the Elasticsearch endpoint.
2. Open Kibana and go to the **Index Management** page in the navigation menu or use the [global search field](https://docs-v3-preview.elastic.dev/elastic/docs-content/tree/main/explore-analyze/find-and-organize/find-apps-and-objects).
3. Use the search field to identify the indices that you want to migrate.
2. In your Serverless project:
   1. Open the Developer Tools [Console](https://docs-v3-preview.elastic.dev/elastic/docs-content/tree/main/explore-analyze/query-filter/tools/console).
2. Call the reindex API to migrate your index. If you have multiple indices to migrate, then you should perform a separate call for each.
   Example: Reindex from an Elastic Cloud Hosted deployment to a Serverless project using an API key:
   ```
   POST _reindex
   {
     "source": {
       "remote": {
         "host": "https://<SERVERLESS_HOST_URL>:443", 
         "api_key": "<ECH_API_KEY>" 
       },
       "index": "<SOURCE_INDEX>" 
     },
     "dest": {
       "index": "<DESTINATION_INDEX>" 
     }
   }
   ```
3. Verify that the new index is present:
   ```sh
   GET INDEX-NAME/_search?pretty
   ```
4. If you are not planning to reindex more data from the remote and you configured a `reindex.remote.whitelist` user setting, that setting can now be removed.


## Notes for migrating between other deployment types

The page demonstrates copying data from an Elastic Cloud Hosted deployment to Serverless. When you use the reindex API to copy data across other deployment types there are a couple of things to consider.

### Using non–publicly trusted TLS certificates

If you're migrating from a self-managed cluster that uses non–publicly trusted TLS certificates, including self-signed certificates and certificates signed by a private certificate authority (CA), refer to our guide [Reindex from a self-managed cluster using a private CA](https://docs-v3-preview.elastic.dev/elastic/docs-content/tree/main/manage-data/migrate/migrate-from-a-self-managed-cluster-with-a-self-signed-certificate-using-remote-reindex).

### Connecting to the source cluster

The target deployment must be able to access your original source cluster to perform the reindex operation. When you migrate to Serverless, access to all Elastic Cloud Hosted endpoints is allowed automatically. For migrating to other deployment types, access is controlled by the Elasticsearch `reindex.remote.whitelist` user setting.
Domains matching the patterns `["*.io:*", "*.com:*"]` are allowed by default, so if your remote host URL matches that pattern you do not need to explicitly define `reindex.remote.whitelist`.
Otherwise, if your remote endpoint is not covered by the default patterns, adjust the setting to add the remote Elasticsearch cluster as an allowed host:
1. From your deployment menu, go to the **Edit** page.
2. In the **Elasticsearch** section, select **Manage user settings and extensions**. For deployments with existing user settings, you might have to expand the **Edit elasticsearch.yml** caret for each node type instead.
3. Add the following `reindex.remote.whitelist: [REMOTE_HOST:PORT]` user setting, where `REMOTE_HOST` is a pattern matching the URL for the remote Elasticsearch host that you are reindexing from, and `PORT` is the host port number. Do not include the `https://` prefix.
   If you override the parameter, it replaces the defaults: `["*.io:*", "*.com:*"]`. If you still want these patterns to be allowed, you need to specify them explicitly in the value.
   For example:
   `reindex.remote.whitelist: ["*.us-east-1.aws.found.io:9243", "*.com:*"]`
4. Save your changes.