# Get the picture of a contact

`GET /api/v1/vaults/{vault}/contacts/{contact}/avatar` and `QUERY /api/v1/vaults/{vault}/contacts/{contact}/avatar`

Return the small picture a contact is drawn as, byte for byte.

This endpoint does not answer in JSON. The body is the picture, 96 pixels square, sent with its image type, so it can be drawn as it arrives. It is the size the vault cards of the application draw, and the address every face of a vault points at in avatar_url.

The address belongs to the contact rather than to one picture, so a replaced picture comes back under the same address. The answer may be kept in a private cache for an hour, which is how long a replaced picture can take to show.

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://monica.kentandrian.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.

## Returns

The picture. A contact with no picture, a picture 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://monica-789392842564.asia-southeast1.run.app/api/v1/vaults/9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31/contacts/c4a1f7b2-8e36-4d59-b0a7-2f5c9d81e364/avatar \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://monica-789392842564.asia-southeast1.run.app/api/v1/vaults/9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31/contacts/c4a1f7b2-8e36-4d59-b0a7-2f5c9d81e364/avatar', {
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->get('https://monica-789392842564.asia-southeast1.run.app/api/v1/vaults/9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31/contacts/c4a1f7b2-8e36-4d59-b0a7-2f5c9d81e364/avatar');
```

## Request with QUERY

```sh
curl https://monica-789392842564.asia-southeast1.run.app/api/v1/vaults/9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31/contacts/c4a1f7b2-8e36-4d59-b0a7-2f5c9d81e364/avatar \
  -X QUERY \
  -H "Authorization: Bearer $MONICA_TOKEN"
```

```javascript
const response = await fetch('https://monica-789392842564.asia-southeast1.run.app/api/v1/vaults/9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31/contacts/c4a1f7b2-8e36-4d59-b0a7-2f5c9d81e364/avatar', {
  method: 'QUERY',
  headers: { Authorization: `Bearer ${token}` },
})
const data = await response.json()
```

```php
$response = Http::withToken($token)->query('https://monica-789392842564.asia-southeast1.run.app/api/v1/vaults/9d4f1c2e-7b3a-4f88-9a2d-6c1e5b0f7a31/contacts/c4a1f7b2-8e36-4d59-b0a7-2f5c9d81e364/avatar');
```

## Response

`200`, with no body.
