# Zip files and folders

`POST https://api.mailmasker.org/api/v1/drive/zip-jobs`

Build one zip of the files and folders you pick, saved into your Archives folder.

- Who can use it: Any signed-in account
- Area: Drive
- Answers 201 Created when it works
- Page: https://developer.mailmasker.org/drive-zip

The zip is built in the background and saved as a new file in a folder called Archives at your top level, made the first time it is needed. A folder goes in whole, subfolders and all. The answer is a job `id` to follow with See if a zip is ready, and the name and place the finished file will have.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `file_ids` | body | no | Ids of files to put in the zip. Give this, folder_ids, or both. | `[41,42]` |
| `folder_ids` | body | no | Ids of folders to put in the zip, with everything inside them. | `[7]` |

## Good to know

- Ids that aren't yours, and anything in Trash, are quietly left out. With no ids, or nothing left to zip, the answer is 400.
- Two files with the same name both go in, one of them with a number added, such as notes (01).txt.
- If the service that builds zips is down, the answer is 502 or 504; try again later.

## Examples

cURL:

```bash
curl -s -X POST 'https://api.mailmasker.org/api/v1/drive/zip-jobs' \
  -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/zip-jobs',
    { 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

201 Created:

```json
{
  "id": 318,
  "output_name": "drive-export-you-example-com-1793763730.zip",
  "dest_path": "Archives/drive-export-you-example-com-1793763730.zip"
}
```
