# Download a document

Canonical page: https://docs.ovok.com/api/document/download-a-document

`GET /document/{id}`

Downloads the file of a document by answering with a redirect to a short-lived signed URL. Use it to show or download a file you have access to.

**Auth:** bearer token. The DocumentReference is read with your token, so you need read access to it.

## Behaviour

- The response is `307 Temporary Redirect`. The `Location` header holds the file URL. Follow the redirect to get the file.
- For files Ovok stored, the signed URL is valid for one hour. Images (`image/jpeg`, `image/jpg`, `image/png`, `image/gif`, `image/webp`) are served inline; every other type is served as an attachment with the document's file name.
- Pass `width` and `height` together to get a resized copy of an image. Both must be positive integers up to 16384. `fit` sets how the image fits the box (`cover` by default; also `contain`, `fill`, `inside`, `outside`). The resized copy is cached, so later requests for the same size are fast. Files that are not resizable images, and images larger than 40 MB, are returned unchanged.
- If the image cannot be resized, the original file is returned.

## Example

```bash
curl -L 'https://api.sandbox.ovok.com/document/c3499c27-2973-0a7f-807e-fb8676a92dcb?width=200&height=200&fit=cover' \
  -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE3NjcyNjg4MDAsImV4cCI6MTc2NzI3MjQwMH0.Ql3B_ztDvctlyZ2z0vp4sl3ExXRQGkzmxdmTAqxNzZk' \
  -o cat.png
```
