Delete Objects
Remove files from WAYSCloud Storage using DELETE requests.
Endpoint
DELETE /v1/storage/{bucket}/{key}
Basic Delete
cURL
curl -X DELETE "https://api.wayscloud.services/v1/storage/my-bucket/old-file.txt" \
-H "Authorization: Bearer wayscloud_storage_abc123_YourSecretKey"
Python
import requests
import os
API_KEY = os.getenv('WAYSCLOUD_API_KEY')
response = requests.delete(
'https://api.wayscloud.services/v1/storage/my-bucket/old-file.txt',
headers={'Authorization': f'Bearer {API_KEY}'}
)
print(f'Status: {response.status_code}') # 204 = success
JavaScript
const axios = require('axios');
await axios.delete(
'https://api.wayscloud.services/v1/storage/my-bucket/old-file.txt',
{
headers: { 'Authorization': `Bearer ${process.env.WAYSCLOUD_API_KEY}` }
}
);
Batch Delete
import requests
import os
API_KEY = os.getenv('WAYSCLOUD_API_KEY')
bucket = 'my-bucket'
files_to_delete = ['file1.txt', 'file2.txt', 'file3.txt']
for key in files_to_delete:
response = requests.delete(
f'https://api.wayscloud.services/v1/storage/{bucket}/{key}',
headers={'Authorization': f'Bearer {API_KEY}'}
)
if response.status_code == 204:
print(f'✓ Deleted: {key}')
else:
print(f'✗ Failed: {key}')
Response
Success
HTTP/1.1 204 No Content
Not Found
HTTP/1.1 404 Not Found
{"error": "Object not found"}
Best Practices
- Verify before deleting - Check if file exists
- Implement confirmation - Especially for user actions
- Log deletions - Keep audit trail
- Handle errors gracefully - 404 may be acceptable