# Keep a file out of search

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

Stop a file turning up in search results, or let it show again.

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

Private means only that the file stops coming back from a search. It isn't hidden or deleted; it stays in its folder and still downloads. Search catches up on its next indexing pass, not at once, as `notice` says.

## Parameters

| Name | In | Required | What it is | Example |
|---|---|---|---|---|
| `id` | path | yes | The file's id. | `42` |
| `private` | query | no | 0 (or false, no, off) to let search find it again. Leave it out, or send 1, to make it private. |  |

## Good to know

- A file inside a private folder stays out of search even when the file itself isn't marked.
- A file that isn't yours, or is in Trash, answers 404.

## Examples

cURL:

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

## Response

200 OK:

```json
{
  "id": 42,
  "name": "notes.txt",
  "kind": "file",
  "private": true,
  "notice": "Marked private. It stops appearing in search on the next index pass; it is not hidden, deleted or unindexed."
}
```
