> **Source:** https://knowledge.leegality.com/document-execution/api/download-files > **Site:** Leegality Knowledge Base — https://knowledge.leegality.com > **About:** Leegality is a document execution platform covering eSigning, stamps, NeSL, workflows, and REST API integration. > **Navigation:** Every article on this site has a plain-text version at `.txt` (this format). To get an index of all articles with their `.txt` links, read: https://knowledge.leegality.com/llms.txt > **AI Guide:** For instructions on how to navigate this knowledge base as an AI agent, read: https://knowledge.leegality.com/ai-readable.txt --- # GET /v4/packs/download — Download files :::info[Sandbox endpoint] **Authentication:** `X-Auth-Token` header required on every request. ## Request URL ``` GET https://app1.leegality.com/api/v4/packs/download?downloadType=DOCUMENT&documentId=01HN8Z2K7M9P4Q5R6S7T8U9V0&signUrl=https://app1.leegality.com/sign/abc123&index=0&mode=stream ``` **Environments:** - Production: `https://app1.leegality.com/api/v4/packs/download` - Sandbox: `https://sandbox.leegality.com/api/v4/packs/download` --- ## Parameters | Name | In | Required | Type | Description | Example | |------|----|----------|------|-------------|---------| | `downloadType` | query | Yes | string | The type of file to download. One of `DOCUMENT`, `AUDIT_TRAIL`, `ATTACHMENT`, `SUPPORTING_DOCUMENT`. Only one per call. | `DOCUMENT` | | `documentId` | query | No | string | The document's ULID. **Required for `DOCUMENT`, `AUDIT_TRAIL`, and `ATTACHMENT`.** Sending it with `SUPPORTING_DOCUMENT` is a validation error. | `01HN8Z2K7M9P4Q5R6S7T8U9V0` | | `signUrl` | query | No | string | The invitee's sign URL. **Required for `SUPPORTING_DOCUMENT`.** Sending it with a document-family `downloadType` is a validation error. | `https://app1.leegality.com/sign/abc123` | | `index` | query | No | integer | 0-indexed position of the file to fetch. Defaults to `0`. Required for `ATTACHMENT` and `SUPPORTING_DOCUMENT`. | `0` | | `mode` | query | No | string | Set to `stream` to receive the raw file directly. If omitted, the response format follows your account configuration. | `stream` | --- ## Responses ### 200 — Returns the requested file. Depending on your account setup (or the `mode` parameter), you get one of two things: - A JSON response with a temporary download link (`data.url`) that expires shortly (`data.expiresAt`). - The file itself, sent back directly (for example, a PDF). Check the `Content-Type` response header to tell which one you received. | Field | Type | Required | Description | Example | |-------|------|----------|-------------|---------| | `data` | object | No | See **data** below. | — | #### data | Field | Type | Required | Description | Example | |-------|------|----------|-------------|---------| | `url` | string | No | Temporary link to download the file. Expires shortly. | `https://sandbox-downloads.leegality.com/export/…?Expires=…&S` | | `expiresAt` | string | No | When the download link expires (ISO 8601). | `2026-08-19T09:23:40.297Z` | ### 400 — The request was rejected. Possible errors: - `LE_ERR_AP_043` — `downloadType` is missing - `LE_ERR_AP_044` — `downloadType` is not a supported value - `LE_ERR_AP_029` — `documentId` is missing (for `DOCUMENT`, `AUDIT_TRAIL`, or `ATTACHMENT`) - `LE_ERR_AP_045` — `signUrl` is missing (for `SUPPORTING_DOCUMENT`) - `LE_ERR_AP_046` — `index` is a negative number - `LE_ERR_AP_062` — `index` is not a whole number - `LE_ERR_AP_024` — the document isn't fully signed yet, so its audit trail can't be downloaded | Field | Type | Required | Description | Example | |-------|------|----------|-------------|---------| | `code` | string | No | Top-level error code (matches the first entry in `errors`). | `LE_ERR_AP_007` | | `traceId` | string | No | Trace identifier for the request, or `null`. | `null` | | `errors` | array\ | No | One or more errors describing why the request failed. See **errors** below. | — | #### errors | Field | Type | Required | Description | Example | |-------|------|----------|-------------|---------| | `message` | string | No | Human-readable error message. | `max must be >= 1` | | `path` | string | No | Request path that produced the error. | `/api/v4/packs/search` | | `code` | string | No | Error code. | `LE_ERR_AP_007` | ### 401 — Authentication failed. - `LE_ERR_AP_080` — missing or invalid authentication token | Field | Type | Required | Description | Example | |-------|------|----------|-------------|---------| | `code` | string | No | Top-level error code (matches the first entry in `errors`). | `LE_ERR_AP_007` | | `traceId` | string | No | Trace identifier for the request, or `null`. | `null` | | `errors` | array\ | No | One or more errors describing why the request failed. See **errors** below. | — | #### errors | Field | Type | Required | Description | Example | |-------|------|----------|-------------|---------| | `message` | string | No | Human-readable error message. | `max must be >= 1` | | `path` | string | No | Request path that produced the error. | `/api/v4/packs/search` | | `code` | string | No | Error code. | `LE_ERR_AP_007` | ### 404 — Not found. - `LE_ERR_AP_001` — no document matches the `documentId` - `LE_ERR_AP_047` — the requested file isn't available (for example, there's no attachment at that `index`) | Field | Type | Required | Description | Example | |-------|------|----------|-------------|---------| | `code` | string | No | Top-level error code (matches the first entry in `errors`). | `LE_ERR_AP_007` | | `traceId` | string | No | Trace identifier for the request, or `null`. | `null` | | `errors` | array\ | No | One or more errors describing why the request failed. See **errors** below. | — | #### errors | Field | Type | Required | Description | Example | |-------|------|----------|-------------|---------| | `message` | string | No | Human-readable error message. | `max must be >= 1` | | `path` | string | No | Request path that produced the error. | `/api/v4/packs/search` | | `code` | string | No | Error code. | `LE_ERR_AP_007` | ### Sample Response (200) ```json { "data": { "url": "https://sandbox-downloads.leegality.com/export/…?Expires=…&Signature=…&Key-Pair-Id=…", "expiresAt": "2026-08-19T09:23:40.297Z" } } ```