Skip to main content
Permanently remove files from your workspace to manage storage space and maintain data organization and security.

Delete a File

Remove files from your account:
Delete by file ID:
gravixlayer files delete 977ca95b-0705-4ad2-846e-7d3d15af3eb2
Delete by filename:
gravixlayer files delete README.md
Example Output (Delete by ID):
🗑️  Deleting file: 977ca95b-0705-4ad2-846e-7d3d15af3eb2
✅ File deleted successfully!
Example Output (Delete by filename):
🗑️  Deleting file: README.md
Looking up file by name...
Found file ID: a804e4a3-ea8b-4ac7-855b-c7977f9d0ed4
✅ File deleted successfully!
Flexible Delete Options: You can delete files using either the file ID or the filename. When using a filename, the CLI will automatically look up the corresponding file ID.

Delete Multiple Files

import os
from gravixlayer import GravixLayer

client = GravixLayer()

# Delete multiple files by ID
file_ids_to_delete = ["708a4c39-d99b-450b-91a3-42513499baf1", "cc470690-1f66-4f09-844b-d0cbeede804b"]

for file_id in file_ids_to_delete:
    try:
        delete_response = client.files.delete(file_id)
        print(f"Deleted: {delete_response.file_id}")
    except Exception as e:
        print(f"Failed to delete {file_id}: {e}")

# Delete files by purpose
files_response = client.files.list()
temp_files = [f for f in files_response.data if f.purpose == "batch"]

for file in temp_files:
    try:
        delete_response = client.files.delete(file.id)
        print(f"Deleted batch file: {file.filename}")
    except Exception as e:
        print(f"Failed to delete {file.filename}: {e}")

Example Output
Deleted: 6d9a8af0-376e-4e34-86d6-33e648b9b6de
Deleted: 40548770-462e-461f-b115-47d212600468
Deleted batch file: test1.jpg

Delete Parameters

ParameterTypeRequiredDescription
file_idstringYesFile ID (e.g., 977ca95b-0705-4ad2-846e-7d3d15af3eb2)