<!-- Generated by scripts/build-docs.js. Edit docs/swagger.yaml or docs/guides/, then run `npm run docs:build`. -->

# Get a document download link

`GET https://marketplace-api.sequifi.com/v1/documents/{id}/download`

Module: Documents · operationId: `getDocumentDownloadUrl` · Auth: `Authorization: Bearer <token>`
Web page: https://apidocs.sequifi.com/#/api/get-document-download-url

Exchanges a document `id` from `GET /v1/documents` for a signed download link that works for 10 minutes. Fetch the file right away and never store the link; call again for a fresh one.

**What happens:**

- Checks that the document still meets the list's rules (an unsigned e-sign document or the default avatar is never downloadable) and that its file exists.
- Returns a link that downloads the file as an attachment named `file_name`.
- Each link issued is logged against your API credentials and the document id. There is no other side effect, so retries are safe and each call returns a new link.

**Formats:**

- `download_url` is an HTTPS link. A `GET` on it returns the file itself, not JSON. Do not send your API token to it.
- `expires_at` is a UTC timestamp about 10 minutes after the call. The link can stop working a little earlier, so use it at once.

**Errors:**

- `400 Invalid document id`: not in the form `manual_<n>`, `esign_<n>`, `photo_u_<n>` or `photo_oe_<n>`.
- `400 Cannot use query parameters on the download route`
- `403 Documents API is not provisioned for this client`: contact Sequifi support.
- `404 Document not found`: no such document, or it is not downloadable (for example an unsigned e-sign document).
- `404 File not found in storage`: the document exists but its file is missing. Retrying does not help.
- `500 Internal Server Error`: a storage problem on our side. Retry later.
- A `403` from the download link itself (an XML body, not JSON) means the link expired or was changed. Request a new one.

**Related:**

- `GET /v1/documents` lists document ids.

## Path parameters

- `id` (string, **required**): Document id from `GET /v1/documents`: `manual_<n>`, `esign_<n>`, `photo_u_<n>` or `photo_oe_<n>`. Example: `manual_19014`.

## Example request

```bash
curl -X GET "https://marketplace-api.sequifi.com/v1/documents/manual_19014/download" \
  -H "Authorization: Bearer $SEQUIFI_TOKEN"
```

## Responses

### 200: A download link, valid for about 10 minutes.

- `status` (integer): Same as the HTTP status code. Example: `200`.
- `message` (string) Example: `success`.
- `data` (object)
  - `requestedBy` (string): Label of the API credentials that made the call.
  - `document_id` (string): The document id you sent.
  - `file_name` (string): File name the download is saved as.
  - `download_url` (string): Signed HTTPS link to the file. Use it at once; do not store it.
  - `expires_at` (string): UTC timestamp when the link expires, about 10 minutes after the call.

```json
{
  "status": 200,
  "message": "success",
  "data": {
    "requestedBy": "acme",
    "document_id": "manual_19014",
    "file_name": "Front Of Drivers License_1783369551_412.jpeg",
    "download_url": "https://files.example.com/presigned/...?X-Amz-Expires=600&X-Amz-Signature=...",
    "expires_at": "2026-07-10T18:25:00.000Z"
  }
}
```

### 400: The document id is invalid, or query parameters were sent.

Example (invalid_id): Not a valid document id

```json
{
  "status": 400,
  "message": "Invalid document id",
  "data": {}
}
```

### 401: Missing, unknown, expired or disabled token. Sent by the gateway as `{"message":"Unauthorized"}`, without `status` or `data`.

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

### 403: Your company is not set up for the Documents API. Contact Sequifi support.

```json
{
  "status": 403,
  "message": "Documents API is not provisioned for this client",
  "data": {}
}
```

### 404: The document does not exist or is not downloadable, or its file is missing.

Example (document_not_found): No downloadable document with this id

```json
{
  "status": 404,
  "message": "Document not found",
  "data": {}
}
```

### 500: A storage problem on our side. Retry later.

```json
{
  "status": 500,
  "message": "Internal Server Error",
  "data": {}
}
```
