# Download a file

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

The file's contents, exactly as uploaded.

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

Answers with the file's bytes, sent as the file's own type. The api passes on the type but not the file's name, so save it under the name your file list shows.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `id` | path | yes | The file's id, from List your files. | `42` |

## Good to know

- A file that isn't yours answers 404, the same as one that doesn't exist, and so does a file in Trash until it is restored.

## Examples

cURL:

```bash
curl -s '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->get('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 download 42 --output notes.txt
```

## Response

200 OK:

```text
(the file's contents)
```
