# Check the calculation instance before deleting it

Check the active tasks and workflow bindings that need to be processed before deleting the compute instance.

```text
GET https://moi.matrixorigin.cn/newmoi/compute-resources/{resource_id}/preflight-delete
```

## Preparation before calling

First [query the computing instance details](get-compute-resource.md) and confirm the instance to be deleted. Prepare a personal access token with access to the target workspace, the target workspace ID, and the compute instance ID.

The example below uses:

- `$AI_STUDIO_API_KEY`: The actual personal access token, passed through the `X-API-Key` Header.
- `$WORKSPACE_ID`: Target workspace ID, passed through `X-Workspace-ID` Header.
- `$RESOURCE_ID`: The computing instance ID to be deleted.

Deletions are not reversible and this check should always be performed first.

## Request example

```bash
curl "https://moi.matrixorigin.cn/newmoi/compute-resources/$RESOURCE_ID/preflight-delete" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

## Path parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `resource_id` | string | Yes | The ID of the computing instance to be deleted. |

## Successful response

Returns `200` on success, `data` lists active tasks and workflow bindings that still need to be processed.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "active_tasks": 1,
    "active_task_ids": ["task-001"],
    "bound_workflows": 1,
    "bound_workflow_details": [
      {
        "id": "wf-001",
        "name": "daily-load"
      }
    ]
  }
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data.active_tasks` | integer | Number of active tasks. |
| `data.active_task_ids` | string[] | Active task IDs; returned when active tasks exist. |
| `data.bound_workflows` | integer | Number of bound workflows. |
| `data.bound_workflow_details` | object[] | Bound workflow details; returned when bindings exist. |
| `data.bound_workflow_details[].id` | string | Workflow ID. |
| `data.bound_workflow_details[].name` | string | Workflow name. |
| `data.bound_workflow_details[].node_names` | string[] | The name of the node bound to this instance; returned if there is a value. |

In this document, `[]` after a type means an array; for example, `string[]` is an array of strings. In field paths, `[]` means each item in an array; for example, `data.bound_workflow_details[].id` is the `id` field of each item in `data.bound_workflow_details`.

## Error response

```json
{
  "code": "PREFLIGHT_FAILED",
  "msg": "Server error",
  "data": null
}
```

### Common HTTP errors

```{list-table}
:header-rows: 1
:widths: 12 22 32 34

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `401`
  - —
  - Missing or invalid access credentials.
  - Check API Key and Workspace Header.
* - `403`
  - `ErrForbidden`
  - The current identity does not have permission to query or delete instances.
  - Use valid credentials, or contact your administrator for authorization.
* - `404`
  - `NOT_FOUND`
  - The instance does not exist or does not belong to the current workspace.
  - Check `resource_id` and workspace.
* - `500`
  - `PREFLIGHT_FAILED`
  - The service was unable to complete dependency checking.
  - Try again later; don't skip checking before deleting.
```

## Follow-up operations

Process active tasks and workflow bindings first; pre-check again after there are no dependencies, and then [Delete calculation instance](delete-compute-resource.md).
