# Read the content of a contact's file

`GET /api/v1/vaults/{vault}/contacts/{contact}/files/{file}/content` and `QUERY /api/v1/vaults/{vault}/contacts/{contact}/files/{file}/content`

Return a file held by a field of the contact, byte for byte.

Files need file upload to be available to your account. Until it is, this endpoint answers 404.

This endpoint does not answer in JSON. The body is the file, sent with the type and the name it was uploaded with, so what you receive can be written straight to disk or drawn. Images are marked to display in place and every other type is marked as a download. The address of each file is given in file.content by Get the pages of a contact.

The file of a field marked sensitive is sent only to a token carrying the sensitive fields scope, as its value is on the pages.

This endpoint answers GET and QUERY alike, and both return the same answer. GET sends the parameters in the address, QUERY in the request body. [How QUERY works](https://people.hansyeoh.com/docs/api/query-method).

## Path parameters

- `vault` (string, required): The vault the contact lives in, named either by the readable name it reports as slug or by its id. Both answer.
- `contact` (string, required): The contact, named either by the readable name it reports as slug or by its id. Both answer. A readable name is rebuilt whenever the record is renamed, and the previous one stops answering, so a client that stores a reference stores the id. A name a record has released is never given to another. The contact has to be in the vault the path names: a contact of yours addressed through the wrong vault answers 404, the same as one that never existed. A contact absorbed by a merge answers 404 here, and the merge endpoints say what became of them.
- `file` (uuid, required): The id of the file, as file.id gives it on the pages of the contact.

## Returns

The file. A file no field of this contact holds, the file of a sensitive field asked without the scope, a file whose content is no longer stored, a contact belonging to somebody else, or one reached through the wrong vault answers 404.

## Rate limit

Sixty requests per minute, per user, shared by every key and device. Every answer carries the budget left in `X-RateLimit-Remaining`.

## Request

```sh
curl https://people.hansyeoh.com/api/v1/vaults/9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31/contacts/c4a1f7b2-8e36-4d59-b0a7-2f5c9d81e364/files/e1c5a8f2-7d49-4b03-a6e8-5f2b9c1d7a40/content \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://people.hansyeoh.com/api/v1/vaults/9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31/contacts/c4a1f7b2-8e36-4d59-b0a7-2f5c9d81e364/files/e1c5a8f2-7d49-4b03-a6e8-5f2b9c1d7a40/content', {
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->get('https://people.hansyeoh.com/api/v1/vaults/9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31/contacts/c4a1f7b2-8e36-4d59-b0a7-2f5c9d81e364/files/e1c5a8f2-7d49-4b03-a6e8-5f2b9c1d7a40/content');
```

## Request with QUERY

```sh
curl https://people.hansyeoh.com/api/v1/vaults/9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31/contacts/c4a1f7b2-8e36-4d59-b0a7-2f5c9d81e364/files/e1c5a8f2-7d49-4b03-a6e8-5f2b9c1d7a40/content \
  -X QUERY \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://people.hansyeoh.com/api/v1/vaults/9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31/contacts/c4a1f7b2-8e36-4d59-b0a7-2f5c9d81e364/files/e1c5a8f2-7d49-4b03-a6e8-5f2b9c1d7a40/content', {
  method: 'QUERY',
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->query('https://people.hansyeoh.com/api/v1/vaults/9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31/contacts/c4a1f7b2-8e36-4d59-b0a7-2f5c9d81e364/files/e1c5a8f2-7d49-4b03-a6e8-5f2b9c1d7a40/content');
```

## Response

`200`, with no body.
