Deleting Files
Deleting a file permanently removes it from Storage and decrements the tenant's storage usage. This action cannot be undone.
What happens when you delete a file
Removed from Storage
The file binary is permanently deleted from Storage. There is no recovery.
Usage decremented
The tenant's storage_used_bytes is reduced by the file's size automatically.
Record removed
The file record is removed from Tenantbox's database. It will no longer appear in file listings.
Endpoint
Request body
| Field | Type | Required | Description |
|---|---|---|---|
file_path | string | Required | The file_path returned when the file was uploaded. |
Response
| Field | Type | Description |
|---|---|---|
detail | string | Confirmation message. Always returns "File deleted successfully" on success. |
Code examples
curl -X DELETE https://api.tenantbox.dev/api/storage/files/ \
-H "Authorization: Bearer sk_live_xxx" \
-H "Content-Type: application/json" \
-d '{
"file_path": "projects/abc.../tenants/def.../xyz_contract.pdf"
}'{
"detail": "File deleted successfully"
}Important notes
Deletion is permanent
Once a file is deleted it cannot be recovered. There is no trash, recycle bin, or soft-delete. Make sure your application confirms with the user before calling this endpoint.
Storage usage is updated automatically
Tenantbox automatically subtracts the file's size from the tenant's storage_used_bytes. You don't need to update usage manually.
Scoped to your project
You can only delete files belonging to your project's tenants. Passing a file_path from a different project returns a 404.
Tenants are not deleted with files
Deleting all files for a tenant does not delete the tenant itself. The tenant record remains with zero storage usage. This is by design — your tenant history is preserved.
Error responses
{ "detail": "Unauthorized" }{ "detail": "File not found" }{ "detail": "Failed to delete from storage: ..." }Next — Tenant management
Learn how to list tenants, track usage, and set storage quotas.