# Remove a file

`DELETE https://app.whatsetter.com/api/v1/knowledge-bases/{id}/files/{fileId}`

Removes a file of any kind (text, PDF, Word): what the agents learned
from it, its stored copy and its entry. The agents stop using it on
their next reply. It cannot be brought back. Removing it a second time
answers `404`. A file that is still being read cannot be removed yet
(`409`): wait until it is `ready`. Requires scope `knowledge:write`.

## Parameters

| Name | In | Type | Required | Description |
|---|---|---|---|---|
| `id` | path | string | yes |  |
| `fileId` | path | string | yes |  |

## Example request

```bash
curl --request DELETE \
  --url 'https://app.whatsetter.com/api/v1/knowledge-bases/{id}/files/{fileId}' \
  --header 'Authorization: Bearer ws_live_…'
```

## Responses

### 204: Removed

### 401: Missing, unknown or revoked API key

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```

### 403: The key lacks the required scope (`insufficient_scope`), the plan does not have this part of the API (`not_in_plan`), or Instagram is not enabled on the workspace (`instagram_not_enabled`, Instagram routes)

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```

### 404: Resource not found in this workspace

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```

### 409: The file is still being read

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```

### 502: A store did not answer. The message says whether the agents still use the file; sending the same request again finishes the removal.

```json
{
  "error": {
    "code": "",
    "message": ""
  }
}
```


Source: https://docs.whatsetter.com/api-reference/operations/deleteknowledgefile/
