# Dereference file

Dereference a set of files. All files must belong to the same root volume.

```text
POST https://moi.matrixorigin.cn/newmoi/catalog/file/delete_ref
```

## Preparation before calling

First [query the file list](list-files.md) to obtain the file ID to be dereferenced. Prepare the personal access token, target workspace ID, and file ID that have access to the target workspace.

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.
- `$FILE_ID`: The file ID to be dereferenced.

All files must belong to the same root volume.

## Request example

```bash
curl -X POST "https://moi.matrixorigin.cn/newmoi/catalog/file/delete_ref" \
  -H "X-API-Key: $AI_STUDIO_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d '{
    "file_ids": ["'"$FILE_ID"'"]
  }'
```

## Request body

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `file_ids` | array[string] | Yes | One or more file IDs to dereference. |
| `volume_id` | integer | No | The declaration must be consistent with the resolved root volume. |

## Successful response

Returns `200` on success, `data` is `null`. This operation disassociates the file from the volume and does not mean deleting the file itself.

```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 association is successful. |

## Error response

```json
{
  "code": "ErrParamInvalid",
  "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`
  - `file_ids` is empty, contains an invalid ID, conflicts with `volume_id`, or the file does not belong to the same root volume.
  - Pass in a valid file ID from the same root volume.
* - `403`
  - `ErrForbidden`
  - The current identity does not have write permissions to the root volume.
  - Use credentials with write access, or contact your administrator for authorization.
* - `404`
  - `ErrNotFound`
  - A file does not exist.
  - Check all file IDs.
* - `409`
  - `ErrReadonly`
  - The destination volume is not writable.
  - Select a writable volume.
* - `500`
  - `ErrServer`
  - The service cannot disassociate the file.
  - Record the request time and error message and try again; if it continues to fail, contact support.
```

## Follow-up operations

After completion, [Query Catalog details](get-catalog.md) confirms the result.
