---
type: api
title: Cancel a migration reindex operation
description: Cancel a migration reindex attempt for a data stream or index.
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch-serverless/operation/operation-indices-cancel-migrate-reindex
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/elasticsearch-serverless/operation/operation-indices-cancel-migrate-reindex
products:
  - Elasticsearch Serverless
---

# Cancel a migration reindex operation

## Paths

- `POST` `/_migration/reindex/{index}/_cancel`

#### Path parameters

- `index` (union string | string[]) — required
  The index or data stream name

## Description

Cancel a migration reindex attempt for a data stream or index.

## Authentication

- Api key: `Authorization: <value>`
  Elasticsearch APIs use 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}"
  ```
  
  For more information about where to find API keys for the Elasticsearch endpoint (${ES_URL}) for a project, go to [Get started with Elasticsearch Serverless](https://www.elastic.co/docs/solutions/search/serverless-elasticsearch-get-started).

## 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 /_migration/reindex/my-data-stream/_cancel
```

#### JavaScript

```javascript
const response = await client.indices.cancelMigrateReindex({
  index: "my-data-stream",
});
```

#### Python

```python
resp = client.indices.cancel_migrate_reindex(
    index="my-data-stream",
)
```

#### curl

```curl
curl -X POST "$ELASTICSEARCH_URL/_migration/reindex/my-data-stream/_cancel" \
  -H "Authorization: ApiKey $ELASTIC_API_KEY"
```

#### Java

```java
client.indices().cancelMigrateReindex(c -> c
    .index("my-data-stream")
);
```

#### C#

```c#
var response = await client.Indices.CancelMigrateReindexAsync(indices: new[] { "my-data-stream" });
```

#### PHP

```php
$requestFactory = Psr17FactoryDiscovery::findRequestFactory();
$request = $requestFactory->createRequest(
    "POST",
    "/_migration/reindex/my-data-stream/_cancel",
);
$resp = $client->sendRequest($request);
```

#### Ruby

```ruby
response = client.indices.cancel_migrate_reindex(
  index: "my-data-stream"
)
```

