# Restore a file from Trash

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

Bring a file back out of Trash, to the folder it was in.

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

The file goes back where it was. If its folder is in Trash too, that folder and any above it come back as well, so the file has somewhere to land; their other contents stay in Trash. Links you shared for it work again.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `id` | path | yes | The file's id. | `42` |

## Good to know

- A file that isn't in your Trash answers 404.

## Examples

cURL:

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

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/files/42/restore',
    { 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 restore 42
```

## Response

200 OK:

```json
{ "ok": true }
```
