# Delete several files and folders at once

`POST https://api.mailmasker.org/api/v1/drive/bulk/delete`

Delete a selection of files and folders in one go, for good.

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

Through the API this is immediate and permanent; there is no Trash option here, so to keep things recoverable delete them one at a time with `soft=1`. Folders go first, with everything inside them, so a listed file that was in one of them comes back under `not_found`. Every id is reported, and one problem doesn't stop the rest.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `file_ids` | body | no | Ids of files to delete. | `[41,42]` |
| `folder_ids` | body | no | Ids of folders to delete, with everything inside them. | `[7]` |

## Good to know

- An id that isn't yours counts as not found, the same as one that doesn't exist.

## Examples

cURL:

```bash
curl -s -X POST 'https://api.mailmasker.org/api/v1/drive/bulk/delete' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"file_ids":[41,42],"folder_ids":[7]}'
```

Perl:

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

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

homelab-cli:

There is no homelab-cli command for this yet.

## Response

200 OK:

```json
{
  "files": { "deleted": [41, 42], "not_found": [] },
  "folders": { "deleted": [7], "not_found": [] },
  "counts": { "deleted": 3, "not_found": 0 }
}
```
