<span id="删除无引用工作区文件"></span>

# Delete an unreferenced workspace file

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

Delete a workspace file with reference count0.

```text
DELETE https://api.moi.matrixorigin.cn/v5/workspaces/{id}/files/{file_id}
```

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

## Before you call this API

`BASE_URL` uses the product API prefix `https://api.moi.matrixorigin.cn/v5`. For a dedicated deployment, use its corresponding product API address.

Prepare a personal access token for the target workspace. WORKSPACE_ID must match the path workspace, and FILE_ID must come from actual file results. BASE_URL includes the same environment's product prefix. Example files/IDs are placeholders.

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

## Request parameters

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

```bash
curl --fail-with-body -sS -X DELETE "$BASE_URL/workspaces/$WORKSPACE_ID/files/$FILE_ID" \
  -H "X-API-Key: $MOI_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID"
```

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

No business request body. Use the actual target workspace and file ID in the path.

Success returns HTTP 204 without a body. Positive references, built-in samples, and concurrent cleanup state may reject deletion. Volume-file detachment and global file deletion are separate. External files remove MOI metadata only, not connector source objects.

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

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

## Successful response

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

```text
HTTP/1.1 204 No Content
```

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

HTTP 204, no JSON body.

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

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

## Error response

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

```json
{
  "code": 2,
  "message": "示例错误信息"
}
```

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

Unreleased references or inability to claim cleanup may return 409/4; invalid input400/2; missing files404/3. Handle built-in-file protection according to actual errors.

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