# Delete files

Delete temporary files, which cannot be recovered after deletion.

```text
POST $CLOUDSIGMA_API_BASE/connectors/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.

Make sure the file is no longer needed before deleting it.

Set the operation-specific values used in the request:

- `$CONN_FILE_ID`: Temporary file ID to delete, passed via `conn_file_id`.

## Request example

```bash
curl -X POST "$CLOUDSIGMA_API_BASE/connectors/file/delete" \
  -H "X-API-Key: $CLOUDSIGMA_API_KEY" \
  -H "X-Workspace-ID: $WORKSPACE_ID" \
  -H 'Content-Type: application/json' \
  -d "{
    \"conn_file_id\": \"$CONN_FILE_ID\"
  }"
```

## Request body

| Field | Type | Is it required | Description |
| --- | --- | --- | --- |
| `conn_file_id` | string | Yes | The ID of the temporary file to be deleted. |

## Successful response

Returns `200` on success and `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 | This interface does not return metadata of deleted files. |

## Error response

```json
{
  "code": "ErrParamInvalid",
  "msg": "invalid file identifier",
  "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`
  - The JSON request body is invalid.
  - Check the JSON format and try again.
* - `404`
  - `ErrNotFound`
  - `conn_file_id` is empty or the temporary file does not exist.
  - Confirm the file ID; no need to delete the file again if it has already been deleted.
* - `401`
  - `ErrUnauthorized`
  - The access token is invalid or has expired.
  - Try again after updating the access token.
* - `403`
  - `ErrForbidden`
  - The caller does not have permission to delete temporary files.
  - Check workspace ID and access permissions.
* - `503`
  - `ErrServiceUnavailable`
  - The service is temporarily unable to delete files.
  - Keep the desensitization error message and try again.
```

## Follow-up operations

When you need to confirm the deletion result, keep `conn_file_id` and [Preview file](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/connector-files/preview-file.html.md) or [Download file](https://omnifabric.cloudsigma.com/docs/reference/api/ai-studio/data-connections/connector-files/download-file.html.md) again. Both interfaces return a non-exist error when the temporary file has been deleted.
