> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/rest-api/identity-api/identity-api-reference/security-compliance/document-custody/download-document.md).

# Download Document

Service for downloading a stored document using the pre-signed download URL.

The download URL is valid for **5 years** from its generation. The response is a redirect to the file's actual location.

{% hint style="info" %}
When used in a browser, the browser will follow the redirect transparently for the user.
{% endhint %}

{% hint style="warning" %}
The download URL contains a JWT Token valid for 5 years. If the download URL is lost, it will not be possible to recover the file.
{% endhint %}

### Endpoint

```
GET /custody/download/{downloadToken}
```

### Route parameters

| Parameter       | Type   | Required | Description                                                   |
| --------------- | ------ | -------- | ------------------------------------------------------------- |
| `downloadToken` | string | **Yes**  | Download Token of the pre-signed URL (JWT valid for 5 years). |

### Responses

#### `302` Found

Redirects to the file's direct download URL.

#### Response headers

| Header         | Type   | Description               |
| -------------- | ------ | ------------------------- |
| `Location`     | string | Direct file download URL. |
| `Content-Type` | string | File content type.        |

#### `401` Unauthorized

```json
{
  "message": "Unauthorized"
}
```

#### `403` Forbidden

```json
{
  "Message": "User is not authorized to access this resource with an explicit deny"
}
```

#### `404` Not Found

```json
{
  "status": 404,
  "title": "Not Found",
  "detail": "Document doesn't exist.",
  "type": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404",
  "errors": []
}
```

#### `502` Bad Gateway

```json
{
  "status": 502,
  "title": "Bad Gateway",
  "detail": "Server got an invalid response.",
  "type": "https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502"
}
```

#### `504` Gateway Timeout

```json
{
  "message": "Endpoint request timed out"
}
```
