# Delete files

Delete the specified file.

```text
POST $CLOUDSIGMA_API_BASE/catalog/file/delete
```

## Before you call this API

Configure the [regional API endpoint and authentication](https://omnifabric.cloudsigma.com/docs/developer/endpoints-and-authentication.html.md), and select the target workspace.

First [query the file list](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/resource-center/catalog/list-files.html.md) to obtain the target file ID and the volume ID to which it belongs.

Set the operation-specific values used in the request:

- `$FILE_ID`: File ID to delete.
- `$VOLUME_ID`: ID of the volume to which the file belongs.

This action removes the file association and deletes the file irreversibly.

## Request example

```bash
curl -X POST "$CLOUDSIGMA_API_BASE/catalog/file/delete" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "id": "'"$FILE_ID"'",
    "volume_id": "'"$VOLUME_ID"'"
  }'
```

## Request body

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `id` | string | Yes | File ID. |
| `volume_id` | string | Yes | The volume ID to which the file belongs. |

## Successful response

Returns `200` on success, `data` is `null`. This operation removes the file association and deletes the file irreversibly.

```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 deleted successfully. |

## Error response

```json
{
  "code": "ErrNotFound",
  "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`
  - `ErrParamInvalid`
  - `id`, `volume_id` are missing or invalid.
  - Check file ID and owning volume ID.
* - `403`
  - `ErrForbidden`
  - The current identity does not have write permissions on the root volume to which it belongs.
  - Use credentials with write access, or contact your administrator for authorization.
* - `404`
  - `ErrNotFound`
  - The file or the volume it belongs to does not exist.
  - Check file ID and volume ID.
* - `409`
  - `ErrReadonly`
  - The volume where the file is located is not writable.
  - Select files in a writable volume.
* - `500`
  - `ErrServer`
  - The service cannot delete the file.
  - Record the request time and error message and try again; if it continues to fail, contact support.
```

## Follow-up operations

[Query file products](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/resource-center/catalog/list-file-artifacts.html.md), confirm that the target no longer appears.
