> **Source:** https://knowledge.leegality.com/document-execution/api/fetch-document > **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 /v3.3/document/fetchDocument — Fetch document Downloads the signed document, audit trail, sender attachments, or invitee supporting documents associated with a completed document. **Authentication:** `X-Auth-Token` header required on every request. ## Request URL ``` GET https://app1.leegality.com/api/v3.3/document/fetchDocument?documentId={documentId}&documentDownloadType={documentDownloadType}&supportDocumentUrl={supportDocumentUrl}&index={index} ``` **Environments:** - Production: `https://app1.leegality.com/api/v3.3/document/fetchDocument` - Sandbox: `https://sandbox.leegality.com/api/v3.3/document/fetchDocument` --- ## Parameters | Name | In | Required | Type | Description | Example | |------|----|----------|------|-------------|---------| | `documentId` | query | Yes | string | The unique Document ID generated by Leegality when the eSigning request was created. Can also be retrieved from the Leegality dashboard. **Note:** Only completed documents can be fetched. SENT or DRAFT documents return error `no.document.found`. | — | | `documentDownloadType` | query | Yes | string | The type of file to download. Only one value can be passed per API call. **Possible values:** - `DOCUMENT` — The signed PDF document - `AUDIT_TRAIL` — The audit trail generated by Leegality on document completion - `ATTACHMENT` — Reference attachments uploaded by the sender (requires `index`) - `SUPPORTING_DOCUMENT` — Supporting documents uploaded by an invitee (requires `supportDocumentUrl` and `index`) **Note:** Values are **case-sensitive** and must be uppercase. Lowercase or invalid values return error code `document.download.type` with the list of valid values. | — | | `supportDocumentUrl` | query | No | string | The invitation URL of the invitee whose supporting documents you want to fetch. The invitation URL is returned in the Create eSigning Request API response. Accepts either the full invitation URL (e.g., `https://sandbox.leegality.com/sign/544bf18f-...`) or just the UUID portion (e.g., `544bf18f-91b8-4afb-96ee-8ff1927a2726`). **Required when** `documentDownloadType` = `SUPPORTING_DOCUMENT`. Ignored for other `documentDownloadType` values. | — | | `index` | query | No | integer | The 0-based index of the attachment or supporting document to fetch. **Example:** Pass `0` for the first file, `1` for the second, and so on. **Required when** `documentDownloadType` = `ATTACHMENT` or `SUPPORTING_DOCUMENT`. Ignored for `DOCUMENT` and `AUDIT_TRAIL` types. **Error codes:** - `index.not.negative` — Returned if a negative value is passed - `index.out.of.bound` — Returned if the index exceeds the number of available files - `no.attachments.exists` — Returned if no attachments exist for the document | — | --- ## Responses ### 200 — Default Response Response for the Fetch Document API. | Field | Type | Required | Description | Example | |-------|------|----------|-------------|---------| | `status` | integer | No | API response status. `1` = Success — the `data.file` field contains the CDN download URL `0` = Failure — check the `messages` array for error details | `1` | | `data` | FetchDocumentData | No | Contains the CDN download URL for the requested file. Empty object `{}` on failure. See **FetchDocumentData** below. | — | | `messages` | array\ | No | Array of error/validation messages. Empty array `[]` on success. **Common error codes:** - `no.document.found` — Document ID not found or document is not in COMPLETED status - `document.download.type` — Invalid `documentDownloadType` value (case-sensitive, must be uppercase) - `no.attachments.exists` — No attachments exist for the given document ID - `index.out.of.bound` — Index exceeds the number of available files - `index.not.negative` — Negative index value passed - `invitation.not.found` — Invalid `supportDocumentUrl` (invitee not found) - `validator.invalid` — Required parameter missing or invalid See **Message** below. | — | #### FetchDocumentData Contains the CDN download URL for the requested file. Empty object `{}` on failure. | Field | Type | Required | Description | Example | |-------|------|----------|-------------|---------| | `file` | string | No | A temporary CDN download URL for the requested file. **Important:** - The URL expires in **15 seconds**. Download the file immediately at the server level. - Do not use this URL for previewing files in a browser — it is intended for server-side downloads only. - Each API call generates a **unique URL**. If the URL expires, simply call the API again to get a new one. **URL format:** `https:///export//?Expires=&Signature=&Key-Pair-Id=` | `https://sandbox-downloads.leegality.com/export/2026/03/05/70` | #### Message Message object containing a machine-readable code and a human-readable description. Used for success confirmations, errors, and warnings. | Field | Type | Required | Description | Example | |-------|------|----------|-------------|---------| | `code` | string | No | Response message code. | `simpleWorkFlow.success` | | `message` | string | No | Human-readable success or error message. | `Invitations sent successfully.` | ### Sample Response (200) ```json { "status": 1, "data": { "file": "https://sandbox-downloads.leegality.com/export/2026/03/05/70476a7c-17bc-4d32-ae64-6687200ca73d?Expires=1772689002&Signature=...&Key-Pair-Id=..." }, "messages": [ { "code": "simpleWorkFlow.success", "message": "Invitations sent successfully." } ] } ```