<span id="预检查计算资源删除"></span>

# Preflight compute resource deletion

```{raw} html
<div class="mo-api-page-show-toc" aria-hidden="true"></div>
```

Read current active tasks and workflow bindings before deletion.

```text
GET https://api.moi.matrixorigin.cn/v5/admin/compute-resources/{id}/preflight-delete
```

<span id="调用前准备"></span>

## Before you call this API

Prepare a compute specification administrator identity configured for the current deployment and an accessible authentication workspace. Workspace Owner privileges or Genesis administrative scopes do not substitute for this identity. Replace example IDs with targets you are authorized to read or operate on. See [Compute Instances](../../../../../developer/cli/tasks/compute-resources.md).

Results describe dependencies observed at read time. They neither reserve the resource nor grant deletion privileges. Workflow-level and node-level bindings are deduplicated by workflow ID. Some draft DSLs that cannot be parsed are skipped; version JSON parse failures return errors. Zero counts do not prove there will be no new bindings or external workloads later.

<span id="查询参数"></span>

## Query parameters

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Request example

```bash
curl --get "https://api.moi.matrixorigin.cn/v5/admin/compute-resources/cr-example/preflight-delete" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $AUTH_WORKSPACE_ID"
```

:::::
:::::{tab-item} Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `X-API-Key` | string | Yes (example) | Valid personal access token for a compute specification administrator configured in this deployment. |
| `X-Workspace-ID` | string | Yes | Exactly one nonempty authentication workspace, separate from the target resource workspace and the workspace_id list filter. |
| `id` | string | Yes | Target resource ID. The service resolves its owning workspace from the administrative repository. |

:::::
::::::
:::::::

<span id="成功响应"></span>

## Successful response

HTTP 200。

:::::::{div} mo-api-tabs mo-api-response-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{
  "code": "OK",
  "msg": "OK",
  "data": {
    "active_tasks": 0,
    "bound_workflows": 0
  }
}
```

:::::
:::::{tab-item} Fields

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | OK on success. |
| `msg` | string | OK on success. |
| `data` | object | Data returned by this API; see the fields below. |
| `data.active_tasks` | integer | Number of active tasks collected at this time. |
| `data.active_task_ids` | string (array of strings), optional | Optional active task IDs; omitted when empty. |
| `data.bound_workflows` | integer | Number of bound workflows, deduplicated by workflow ID. |
| `data.bound_workflow_details` | object (array of objects), optional | Optional bound workflow details; omitted when empty. |

See [Common objects](compute-admin-crud-objects.md) for nested objects and omission rules.
:::::
::::::
:::::::

<span id="错误响应"></span>

## Error response

:::::::{div} mo-api-tabs
::::::{tab-set}
:::::{tab-item} Response example

```json
{"code": "INVALID_PARAMS", "msg": "invalid compute resource request", "data": null}
```

:::::
:::::{tab-item} Fields

| HTTP / code | Conditions and recovery |
| --- | --- |
| 400 / INVALID_PARAMS | Missing principal, authentication workspace, or resource ID. |
| 403 / ErrForbidden | Classified denial of administrator eligibility, principal, or workspace access. |
| 503 / ErrServiceUnavailable | Classified shared authorization unavailability; does not cover every catalog or configuration error. |
| 404 / NOT_FOUND | Resource does not exist or has been excluded from the administrative read set. |
| 500 / ErrServer | Unclassified service error while reading facts, parsing versions, or similar operations. |

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | Classified by the failure stage. |
| `msg` | string | Error text; shared errors may be localized. |
| `data` | null or omitted | Direct compute errors use null. See error recovery for shared error shapes. |

:::::
::::::
:::::::

An error does not mean every stage was rolled back. See [Errors and recovery](compute-admin-crud-errors-recovery.md).
