<span id="删除工作区沙箱"></span>

# Delete a workspace sandbox

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

Delete a confirmed workspace hosted sandbox and clean up associated runtime resources. This interrupts sessions using the sandbox.

```text
DELETE https://api.moi.matrixorigin.cn/v5/agent-sandboxes/{sandbox_id}
```

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

## Before you call this API

Prepare a personal access token and operation permissions for the target workspace. Keep environment, token, workspace, and sandbox ID consistent. [Common objects and result confirmation](objects.md) describes resource identity, fields, and states. Replace example resource values with actual values.

<span id="请求"></span>

## Request

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

```bash
curl -X DELETE "https://api.moi.matrixorigin.cn/v5/agent-sandboxes/$SANDBOX_ID" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

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

sandbox_id is a required path string; there is no request body. Deletion has irreversible runtime resource side effects. Confirm ID, workspace, and ownership first.

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

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

## Successful response

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

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

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

HTTP 200 data has the following meaning; example values are not defaults.

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | OK on success. |
| `msg` | string | Response description. |
| `data` | object | Empty object on success. |

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

<span id="结果确认"></span>

## Confirm the result

200 means the deletion chain returned normally; subsequent details may return 404. A 404 or empty list alone does not establish complete external cleanup, because queries hide deleting objects. On failure, retain the original ID and request records. Do not delete other same-name objects as a cleanup substitute.

<span id="错误处理"></span>

## Error handling

Use HTTP status and response code. [Common errors and recovery](objects.md#错误与恢复) distinguishes parameters, permissions, quotas, providers, and unknown outcomes. An error does not prove no resource was created or that retries/cleanup have completed.
