# Download File

**Endpoint**

`GET/v2/storage/file/{id}`

**Link**

{% embed url="<https://stagep.tst-apidmndelss.com/openapi/v2.html#/operations/Storage_Download>" %}

### **Request**

#### **Path Parameters**

| Parameter | Type     | Description                     | Required | Example        |
| --------- | -------- | ------------------------------- | -------- | -------------- |
| **`id`**  | `string` | **File unique ID** to download. | Yes      | `"file_78901"` |

#### **Query Parameters**

| Parameter        | Type     | Description                                           | Required | Example        |
| ---------------- | -------- | ----------------------------------------------------- | -------- | -------------- |
| **`customerId`** | `string` | **Customer ID** for additional authorization context. | No       | `"cust_12345"` |

#### **Headers**

| Key             | Value                       | Required |
| --------------- | --------------------------- | -------- |
| `Authorization` | `123`                       | Yes      |
| `Accept`        | `*/*` or specific MIME type | No       |

***

### **Response (200 OK)**

Returns the raw binary content of the file with appropriate Content-Type header.

#### **Response Headers**

| Header                | Value                                 | Description                      |
| --------------------- | ------------------------------------- | -------------------------------- |
| `Content-Type`        | `application/pdf`                     | MIME type of the downloaded file |
| `Content-Length`      | `2048576`                             | Size of the file in bytes        |
| `Content-Disposition` | `attachment; filename="document.pdf"` | File download behavior           |

#### **Response Body**

Raw binary content of the requested file.

***

### **Examples**

#### **Request (Download PDF Document)**

bash

```
curl -X GET 'https://stagep.tst-apidmndelss.com/v2/storage/file/file_78901' \
  -H 'Authorization: 123' \
  --output downloaded_document.pdf
```

#### **Response Headers (PDF Example)**

text

```
HTTP/1.1 200 OK
Content-Type: application/pdf
Content-Length: 2048576
Content-Disposition: attachment; filename="passport_scan.pdf"
X-File-ID: file_78901
X-Customer-ID: cust_12345
```

#### **Request (Download Image with Customer Context)**

bash

```
curl -X GET 'https://stagep.tst-apidmndelss.com/v2/storage/file/file_78902?customerId=cust_12345' \
  -H 'Authorization: 123' \
  --output driver_license.jpg
```

#### **Response Headers (Image Example)**

text

```
HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Length: 1536000
Content-Disposition: inline; filename="driver_license_front.jpg"
X-File-ID: file_78902
X-Customer-ID: cust_12345
```

#### **Request (Direct Browser Display)**

bash

```
curl -X GET 'https://stagep.tst-apidmndelss.com/v2/storage/file/file_45678' \
  -H 'Authorization: 123' \
  -H 'Accept: image/jpeg'
```

#### **Response Headers (Inline Display)**

text

```
HTTP/1.1 200 OK
Content-Type: image/jpeg
Content-Length: 1024000
Content-Disposition: inline; filename="utility_bill.jpg"
X-File-ID: file_45678
```

***

### **Alternative JSON Response Format**

If Accept header is set to `application/json`, returns file metadata with base64-encoded content:

#### **Response Fields**

| Field             | Type     | Description                               | Example             |
| ----------------- | -------- | ----------------------------------------- | ------------------- |
| **`contentType`** | `string` | **MIME type** of the file content.        | `"application/pdf"` |
| **`data`**        | `string` | **File content** as base64-encoded bytes. | `"JVBERi0xLjQK..."` |
| **`extensions`**  | `array`  | **Additional metadata** (optional).       | -                   |

#### **JSON Response Example**

json

```
{
  "contentType": "application/pdf",
  "data": "JVBERi0xLjQKMSAwIG9iago8PAovVHlwZSAvQ2F0YWxvZwovUGFnZXMgMiAwIFIKPj4KZW5kb2JqCjIgMCBvYmoKPDwKL1R5cGUgL1BhZ2VzCi9LaWRzIFszIDAgUl0KL0NvdW50IDEKPj4KZW5kb2JqCjMgMCBvYmoKPDwKL1R5cGUgL1BhZ2UKL1BhcmVudCAyIDAgUgovQ29udGVudHMgNCAwIFIKPj4KZW5kb2JqCjQgMCBvYmoKPDwKL0xlbmd0aCA1MjMKPj4Kc3RyZWFtC..."
}
```

***

### **Error Responses**

1. **File Not Found**:

   json

   ```
   { "error": "File not found: file_99999" }
   ```
2. **Access Denied**:

   json

   ```
   { "error": "Access denied to file: file_78901" }
   ```
3. **File Locked**:

   json

   ```
   { "error": "File is locked and cannot be downloaded" }
   ```
4. **Unauthorized**:

   json

   ```
   { "error": "Unauthorized" }
   ```

***

### **Notes**

* **Binary Response**: Default behavior returns raw file bytes with proper Content-Type
* **JSON Alternative**: Use `Accept: application/json` for base64-encoded content in JSON
* **Security**: Files are subject to access control based on customer association
* **Performance**: Large files are streamed efficiently
* **Browser Behavior**: Content-Disposition controls whether file is displayed or downloaded
* **Caching**: Appropriate cache headers may be included for static files

**Common Use Cases**:

* Downloading customer documents for verification
* Retrieving operation-related files
* Accessing identity verification documents
* Displaying files directly in web applications
* Batch processing of stored documents

**Content-Disposition Options**:

* `attachment`: Browser downloads the file
* `inline`: Browser attempts to display the file
* Filename preserves original file name for downloads


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.delos.financial/files/download-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
