> For the complete documentation index, see [llms.txt](https://docs.delos.financial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.delos.financial/files/delete-file.md).

# Delete File

Removes a specific file from the storage system by its unique ID. This operation performs a soft delete, marking the file as deleted while potentially retaining it in the system for audit purposes.

**Endpoint**

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

**Link**

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

### **Request**

#### **Path Parameters**

| Parameter | Type     | Description                   | Required | Example        |
| --------- | -------- | ----------------------------- | -------- | -------------- |
| **`id`**  | `string` | **File unique ID** to delete. | 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`        | `application/json` | Yes      |

***

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

Returns a success status and message confirming the file deletion.

#### **Response Fields**

| Field         | Type      | Description                   | Example                       |
| ------------- | --------- | ----------------------------- | ----------------------------- |
| **`success`** | `boolean` | **Deletion status**.          | `true`                        |
| **`message`** | `string`  | **Operation result message**. | `"File deleted successfully"` |

***

### **Examples**

#### **Request (Delete File)**

bash

```
curl -X DELETE 'https://stagep.tst-apidmndelss.com/v2/storage/file/file_78901' \
  -H 'Authorization: 123' \
  -H 'Accept: application/json'
```

#### **Response**

json

```
{
  "success": true,
  "message": "File deleted successfully"
}
```

#### **Request (Delete File with Customer Context)**

bash

```
curl -X DELETE 'https://stagep.tst-apidmndelss.com/v2/storage/file/file_78902?customerId=cust_12345' \
  -H 'Authorization: 123' \
  -H 'Accept: application/json'
```

#### **Response**

json

```
{
  "success": true,
  "message": "File file_78902 deleted for customer cust_12345"
}
```

#### **Request (Delete Non-Existent File)**

bash

```
curl -X DELETE 'https://stagep.tst-apidmndelss.com/v2/storage/file/file_99999' \
  -H 'Authorization: 123' \
  -H 'Accept: application/json'
```

#### **Response (Error)**

json

```
{
  "success": false,
  "message": "File not found: file_99999"
}
```

***

### **Error Responses**

1. **File Not Found**:

   json

   ```
   {
     "success": false,
     "message": "File not found: file_99999"
   }
   ```
2. **File Locked**:

   json

   ```
   {
     "success": false, 
     "message": "File is locked and cannot be deleted"
   }
   ```
3. **Access Denied**:

   json

   ```
   {
     "success": false,
     "message": "Access denied to file: file_78901"
   }
   ```
4. **Unauthorized**:

   json

   ```
   {
     "success": false,
     "message": "Unauthorized"
   }
   ```
5. **Customer Mismatch**:

   json

   ```
   {
     "success": false,
     "message": "File does not belong to specified customer"
   }
   ```

***

### **Notes**

* **Soft Delete**: Files are typically marked as deleted rather than permanently removed
* **Audit Trail**: Deletion is logged for compliance and tracking purposes
* **Access Control**: Files can only be deleted by authorized users with proper permissions
* **Locked Files**: Files with `isLock=true` cannot be deleted
* **Customer Context**: Providing `customerId` adds an additional security layer
* **Idempotent**: Deleting an already deleted file returns success

**Common Use Cases**:

* Removing outdated customer documents
* Cleaning up temporary uploads
* Compliance with data retention policies
* User-initiated file management
* Administrative file cleanup

**Security Considerations**:

* Files are only deletable by users with appropriate permissions
* Customer context validation prevents cross-customer file access
* Locked files require administrative override
* Deletion operations are logged for audit purposes


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.delos.financial/files/delete-file.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
