# Delete calculation instance

Delete the compute instance in the current workspace.

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

## Preparation before calling

[Check](preflight-delete.md) before deleting to 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 compute instance ID to be deleted.

`force=true` will require the server to forcibly handle dependencies, and its impact should be confirmed before use.

## Request example

```bash
curl -X DELETE "https://moi.matrixorigin.cn/newmoi/compute-resources/$RESOURCE_ID" \
  -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. |

## Query parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `force` | boolean | No | Request forced deletion when passing `true`. |

## Successful response

Returns `200` on success, `data` is `null`.

```json
{
  "code": "OK",
  "msg": "OK",
  "data": null
}
```

The response fields are as follows.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | `OK` on success. |
| `msg` | string | `OK` on success. |
| `data` | null | Fixed to `null` when the delete request completes successfully. |

## Error response

```json
{
  "code": "DELETE_FAILED",
  "msg": "请求参数无效",
  "data": null
}
```

### Common HTTP errors

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

* - HTTP status code
  - error code
  - Common causes
  - Recommended actions
* - `400`
  - `DELETE_FAILED`
  - `resource_id` is invalid, or the current status of the instance does not allow deletion.
  - First execute [CHECK](preflight-delete.md) before deleting.
* - `401`
  - —
  - Missing or invalid access credentials.
  - Check API Key and Workspace Header.
* - `403`
  - `ErrForbidden`
  - The current identity does not have the permission to delete the instance.
  - 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.
* - `409`
  - `ErrConflict`
  - There are still active tasks or binding relationships, and they cannot be deleted based on the current conditions.
  - Retry after processing check results; only use `force=true` if impact is confirmed.
* - `500`
  - `DELETE_FAILED`
  - The server failed to delete the instance.
  - Record the request time and error message and try again.
```

## Follow-up operations

Re-[List calculation instances](list-compute-resources.md) to confirm that the resource is no longer visible.
