---
type: api
title: Cleanup the Risk Engine
description: Stops risk scoring for the space. Removes the risk score data stream, the lookup index and its template, the risk engine configuration, and the risk score maintainer task, and clears risk fields stored on entity documents.
url: https://www.elastic.co/elastic/docs-builder/docs/4843/api/doc/kibana-serverless/operation/operation-cleanupriskengine
resource: https://www.elastic.co/elastic/docs-builder/docs/4843/api/doc/kibana-serverless/operation/operation-cleanupriskengine
products:
  - Kibana
---

# Cleanup the Risk Engine

Authentication: required

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

## Paths

- `DELETE` `/api/risk_score/engine/dangerously_delete_data`
- `DELETE` `/s/{space_id}/api/risk_score/engine/dangerously_delete_data`

#### Path parameters

- `space_id` (string) — optional
  An identifier for the space. If `space_id` is not provided in the URL, the default space is used. Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

## Description

Stops risk scoring for the space. Removes the risk score data stream, the lookup index and its template, the risk engine configuration, and the risk score maintainer task, and clears risk fields stored on entity documents.

## Responses

#### `200`

Successful response

`application/json`

- `cleanup_successful` (boolean)
#### `400`

Task manager is unavailable

`application/json`

- `message` (string)
- `status_code` (integer · min: 400)
#### `default`

Unexpected error

`application/json`

- `cleanup_successful` (boolean)
- `errors` (object[])
  - `error` (string)
  - `seq` (integer)
## Code examples

#### Console

```console
DELETE kbn:/api/risk_score/engine/dangerously_delete_data
```

#### curl

```curl
curl -X DELETE "${KIBANA_URL}/api/risk_score/engine/dangerously_delete_data" \
  -H "Authorization: ApiKey ${API_KEY}"
```

## Response examples

#### Successful cleanup response

`application/json`

```json
{
  "cleanup_successful": true
}
```

#### Task manager is unavailable

`application/json`

```json
{
  "message": "Task Manager is unavailable, but is required by the risk engine. Please enable the taskManager plugin and try again.",
  "status_code": 400
}
```

#### Cleanup failed

`application/json`

```json
{
  "cleanup_successful": false,
  "errors": [
    {
      "error": "Risk engine is disabled or deleted already.",
      "seq": 1
    }
  ]
}
```

