# Delete a file

`DELETE https://api.mailmasker.org/api/v1/drive/files/:id`

Delete one file at once and for good, or move it to Trash.

- Who can use it: Any signed-in account
- Area: Drive
- Answers 200 OK when it works
- Page: https://developer.mailmasker.org/drive-delete-file

Unlike the Drive web page, this deletes the file immediately and for good. Add `soft=1` to move it to Trash instead, where it can be restored; `trashed` in the answer says which happened.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `id` | path | yes | The file's id. | `42` |
| `soft` | query | no | 1 to move the file to Trash instead of deleting it for good. |  |

## Good to know

- Any link you shared for the file stops working.
- A file that isn't yours, doesn't exist or is already in Trash answers 404.

## Examples

cURL:

```bash
curl -s -X DELETE 'https://api.mailmasker.org/api/v1/drive/files/42' \
  -H "Authorization: Bearer $TOKEN"
```

Perl:

```perl
use Mojo::Base -strict;
use Mojo::UserAgent;

my $ua  = Mojo::UserAgent->new;
my $res = $ua->delete('https://api.mailmasker.org/api/v1/drive/files/42',
    { Authorization => "Bearer $ENV{TOKEN}" })->result;
die $res->code, ' ', ($res->json('/error') // $res->message), "\n" unless $res->is_success;
print $res->body, "\n";
```

homelab-cli:

```bash
homelab-cli drive delete 42
```

## Response

200 OK:

```json
{ "ok": true, "trashed": false }
```
