Delete File
Deletes an existing file from the system. This will remove both the file record and the actual file from storage.
HTTP Request
DELETE/api/media/files/:id
Authorization
Authorization
- Required: Yes
- Permission: Staff or Admin
- Authentication: Token-based (Authorization: Token <your_api_key>)
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | Integer | Yes | Unique ID of the file to delete |
Example Requests
- 🐍 Python
- 🌐 Curl
1import requests
2
3response = requests.delete('http://www.example.com/api/media/files/123',
4 headers={'Authorization': 'Token <your_api_key>'}
5)
6print(response.status_code) # Should be 204 for successful deletion
7
8# Check if file was deleted
9if response.status_code == 204:
10 print("File deleted successfully")
11elif response.status_code == 404:
12 print("File not found")
13else:
14 print(f"Error: {response.status_code}")1curl -X DELETE "http://www.example.com/api/media/files/123" \
2-H "Authorization: Token <your_api_key>" \
3-vStatus Codes
| Code | Description |
|---|---|
| 204 | File deleted successfully |
| 401 | Unauthorized — authentication required |
| 403 | Forbidden — insufficient permissions |
| 404 | File not found |
| 500 | Internal server error |
Response Fields
| Field | Type | Description |
|---|---|---|
| None | None | No content returned on successful deletion |
Notes
- This action permanently deletes both the file record and the actual file from storage
- Deletion cannot be undone - the file will be completely removed from the system
- Any references to this file URL will become invalid after deletion
- Make sure to update any applications or content that reference this file before deletion
- File deletion is immediate and irreversible
- Use this endpoint with caution in production environments