Skip to main content

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

ParameterTypeRequiredDescription
idIntegerYesUnique ID of the file to delete

Example Requests

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}")

Status Codes

CodeDescription
204File deleted successfully
401Unauthorized — authentication required
403Forbidden — insufficient permissions
404File not found
500Internal server error

Response Fields

FieldTypeDescription
NoneNoneNo 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