---
title: "Delete a file"
description: "Deletes an upload that nothing depends on. Its bytes go, and there is no undo."
url: "https://nextmail.sh/docs/api/files/delete"
area: "API"
category: "Mailbox"
---

# Delete a file

Deletes an upload that nothing depends on. Its bytes go, and there is no undo.

`DELETE /files/{id}`

## DELETE /files/{id}

Deletes an upload that nothing depends on. Its bytes go, and there is no undo.

## Example

Needs `files:write`, from a key or from any member’s app. Only an upload can be deleted, and only while nothing depends on it, which `deletable` on the file says ahead of time. The row stays, marked deleted.

**curl**

```
curl -X DELETE "$OE/files/file_0c4e7a91d2b84f63a5e19b7d" -H "$AUTH"
```

**Response**

```
{
  "object": "file",
  "id": "file_0c4e7a91d2b84f63a5e19b7d",
  "deleted": true
}
```

> A file in use is a 409 `file_in_use`, and the message says why: it came in or went out on a message, it went out as a download link that still works, or it is attached to a message that has not gone out yet. An upload sent inside a message can still go, because the sent message keeps its own copy.

> A key limited to particular addresses or domains reaches only the files on them, so an upload for the whole workspace is a 404 to it, the same as an unknown or deleted id.

## Reference

- [`DELETE /files/{id}`](https://nextmail.sh/docs/api/reference/files#delete-files-id): full reference
