---
type: api
title: Finalize detection alert migrations
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/operation/operation-finalizealertsmigration
resource: https://www.elastic.co/elastic/docs-builder/docs/4493/api/doc/kibana/operation/operation-finalizealertsmigration
products:
  - Kibana
---

# Finalize detection alert migrations

deprecated

- Server: `https://{kibana_url}`

## Paths

- `POST` `/api/detection_engine/signals/finalize_migration`
- `POST` `/s/{space_id}/api/detection_engine/signals/finalize_migration`

## Description

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

**DEPRECATED.** Completes a legacy alert index migration. Do not automate against this in new code.
**WARNING:** Finalizing swaps read aliases; confirm the migration has finished successfully before calling.

Finalize successful migrations of detection alerts. This replaces the original index's alias with the
successfully migrated index's alias. The endpoint is idempotent, so you can poll until a migration
finishes and then call this operation once.

## Authentication

- Api key: `Authorization: <value>`
  These APIs use key-based authentication. You must create an API key and use the encoded value in the request header. For example: `Authorization: ApiKey base64AccessApiKey`
- Basic: `Authorization: Basic <credentials>`

## Request body

Array of `migration_id`s to finalize

`application/json`

- `migration_ids` (string[] · min items: 1) — required
  Array of `migration_id`s to finalize.

## Responses

#### `200`

Successful response

`application/json`

Type: `object[]`

An array; each item has these fields:

- `completed` (boolean)
- `destinationIndex` (string)
- `error` (object)
  - `message` (string)
  - `status_code` (integer)
- `id` (string)
- `sourceIndex` (string)
- `status` (enum)
  Values: `success`, `failure`, `pending`
- `updated` (string · format: date-time)
- `version` (string)
#### `400`

Invalid input data response

`application/json`

One of:
- **{ error, statusCode }**
  - `error` (string)
  - `message` (string)
  - `statusCode` (integer)
- **{ status_code }**
  - `message` (string)
  - `status_code` (integer)
#### `401`

Unsuccessful authentication response

`application/json`

- `error` (string)
- `message` (string)
- `statusCode` (integer)
#### `500`

Internal server error response

`application/json`

- `message` (string)
- `status_code` (integer)
## Code examples

#### Console

```console
POST kbn:/api/detection_engine/signals/finalize_migration
{
  "migration_ids": [
    "924f7c50-505f-11eb-ae0a-3fa2e626a51d"
  ]
}
```

#### curl

```curl
curl -X POST "${KIBANA_URL}/api/detection_engine/signals/finalize_migration" \
  -H "Authorization: ApiKey ${API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{
    "migration_ids": [
      "924f7c50-505f-11eb-ae0a-3fa2e626a51d"
    ]
  }'
```

## Response examples

#### Success

```json
{
  "migrations": [
    {
      "completed": true,
      "destinationIndex": ".siem-signals-default-000002-r000016",
      "id": "924f7c50-505f-11eb-ae0a-3fa2e626a51d",
      "sourceIndex": ".siem-signals-default-000002",
      "status": "success",
      "updated": "2021-01-06T22:05:56.859Z",
      "version": 16
    }
  ]
}
```

#### Bad

```json
{
  "error": "Bad Request",
  "message": "[request body].migration_ids: at least one migration id is required to finalize",
  "statusCode": 400
}
```

#### Unauthorized

```json
{
  "error": "Unauthorized",
  "message": "[security_exception\n\tRoot causes:\n\t\tsecurity_exception: unable to authenticate user [elastic] for REST request [/_security/_authenticate]]: unable to authenticate user [elastic] for REST request [/_security/_authenticate]",
  "statusCode": 401
}
```

#### Server error

```json
{
  "message": "Internal Server Error",
  "status_code": 500
}
```

