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

DELETE /api/storage/files/

Request body

FieldTypeRequiredDescription
file_pathstringRequiredThe file_path returned when the file was uploaded.

Response

FieldTypeDescription
detailstringConfirmation 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"
  }'
Sample response
{
  "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

401Unauthorized
Invalid or missing API key.
{ "detail": "Unauthorized" }
404Not Found
The file_path does not exist or belongs to a different project.
{ "detail": "File not found" }
400Storage Error
Storage returned an error during deletion.
{ "detail": "Failed to delete from storage: ..." }

Next — Tenant management

Learn how to list tenants, track usage, and set storage quotas.

Tenants