# Combine files into one

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

Join several files end to end into a new file, in the order you give.

- Who can use it: Any signed-in account
- Area: Drive
- Answers 202 Accepted when it works
- Page: https://developer.mailmasker.org/drive-combine

For putting a file back together from its pieces, such as `backup.iso.001`, `backup.iso.002` and so on. The work happens in the background, so the answer is a job `id` to follow with See how a combine is going. The pieces are kept, and the new file lands next to the first piece unless you say otherwise.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `file_ids` | body | yes | At least two of your file ids, in the order their bytes should go. | `[41,42,43]` |
| `output_name` | body | no | The new file's name. Left out, it is the first piece's name without its piece number, so backup.iso.001 gives backup.iso.  | `backup.iso` |
| `folder_id` | body | no | The folder to put the new file in. Left out, it goes in the first piece's folder. |  |

## Good to know

- Every piece must be one of your files and not in Trash. If any isn't, nothing starts and the answer is 400.
- The new file counts against your storage limit on top of the pieces; if it won't fit, the answer is 413.

## Examples

cURL:

```bash
curl -s -X POST 'https://api.mailmasker.org/api/v1/drive/append-jobs' \
  -H "Authorization: Bearer $TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"file_ids":[41,42,43],"output_name":"backup.iso"}'
```

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/append-jobs',
    { Authorization => "Bearer $ENV{TOKEN}" },
    json => { file_ids => [41, 42, 43], output_name => 'backup.iso' })->result;
die $res->code, ' ', ($res->json('/error') // $res->message), "\n" unless $res->is_success;
print $res->body, "\n";
```

homelab-cli:

```bash
homelab-cli drive append 41 42 43 --output backup.iso
```

## Response

202 Accepted:

```json
{ "id": 12, "output_name": "backup.iso" }
```
