Delete File
curl --request DELETE \
--url https://api.example.com/files/{file_id}import requests
url = "https://api.example.com/files/{file_id}"
response = requests.delete(url)
print(response.text)const options = {method: 'DELETE'};
fetch('https://api.example.com/files/{file_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/files/{file_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/files/{file_id}"
req, _ := http.NewRequest("DELETE", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.example.com/files/{file_id}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/files/{file_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
response = http.request(request)
puts response.read_body{
"success": false,
"error": {
"code": "not_found",
"message": "File not found or already deleted"
}
}
{
"success": false,
"error": {
"code": "permission_denied",
"message": "You don't have permission to delete this file"
}
}
{
"success": false,
"error": {
"code": "authentication_failed",
"message": "Invalid API key"
}
}
Endpoints
Delete File
Delete a file from your Hubsy Cloud account
DELETE
/
files
/
{file_id}
Delete File
curl --request DELETE \
--url https://api.example.com/files/{file_id}import requests
url = "https://api.example.com/files/{file_id}"
response = requests.delete(url)
print(response.text)const options = {method: 'DELETE'};
fetch('https://api.example.com/files/{file_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/files/{file_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "DELETE",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/files/{file_id}"
req, _ := http.NewRequest("DELETE", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.delete("https://api.example.com/files/{file_id}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/files/{file_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Delete.new(url)
response = http.request(request)
puts response.read_body{
"success": false,
"error": {
"code": "not_found",
"message": "File not found or already deleted"
}
}
{
"success": false,
"error": {
"code": "permission_denied",
"message": "You don't have permission to delete this file"
}
}
{
"success": false,
"error": {
"code": "authentication_failed",
"message": "Invalid API key"
}
}
Overview
Permanently delete a file from your Hubsy Cloud storage. This action cannot be undone.Path Parameters
string
required
The unique identifier of the file to delete
Example Request
curl -X DELETE https://api.hubsy.cloud/v1/files/file_abc123 \
-H "Authorization: Bearer YOUR_API_KEY"
const response = await fetch('https://api.hubsy.cloud/v1/files/file_abc123', {
method: 'DELETE',
headers: {
'Authorization': 'Bearer YOUR_API_KEY'
}
});
const data = await response.json();
console.log(data.success); // true
import requests
response = requests.delete(
'https://api.hubsy.cloud/v1/files/file_abc123',
headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
result = response.json()
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.hubsy.cloud/v1/files/file_abc123');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: Bearer YOUR_API_KEY'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
$data = json_decode($response, true);
Response
boolean
Indicates if the deletion was successful
object
Example Response
{
"success": true,
"data": {
"id": "file_abc123",
"name": "document.pdf",
"deleted_at": "2024-01-15T16:45:00Z",
"recoverable_until": "2024-02-14T16:45:00Z"
}
}
Error Responses
{
"success": false,
"error": {
"code": "not_found",
"message": "File not found or already deleted"
}
}
{
"success": false,
"error": {
"code": "permission_denied",
"message": "You don't have permission to delete this file"
}
}
{
"success": false,
"error": {
"code": "authentication_failed",
"message": "Invalid API key"
}
}
Important Notes
Trash and Recovery
Trash and Recovery
Deleted files are moved to trash for 30 days:
- Files remain recoverable for 30 days
- After 30 days, files are permanently deleted
- Use the restore endpoint to recover files
- Storage space is freed only after permanent deletion
Shared Links
Shared Links
When a file is deleted:
- All share links are immediately invalidated
- Users with existing links can no longer access the file
- Share analytics are preserved
- Restoring the file does NOT restore share links
Permanent Deletion
Permanent Deletion
To permanently delete immediately:
- Use the
permanent=truequery parameter - This bypasses the trash
- Action cannot be undone
- Requires elevated API key permissions
Permanent Deletion
To permanently delete a file immediately (bypass trash):curl -X DELETE "https://api.hubsy.cloud/v1/files/file_abc123?permanent=true" \
-H "Authorization: Bearer YOUR_API_KEY"
Permanent deletion cannot be undone. Files are immediately and irreversibly removed.
Bulk Delete
Delete multiple files at once:curl -X POST https://api.hubsy.cloud/v1/files/bulk-delete \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"file_ids": ["file_abc123", "file_def456", "file_ghi789"]
}'
const response = await fetch('https://api.hubsy.cloud/v1/files/bulk-delete', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
file_ids: ['file_abc123', 'file_def456', 'file_ghi789']
})
});
import requests
response = requests.post(
'https://api.hubsy.cloud/v1/files/bulk-delete',
json={'file_ids': ['file_abc123', 'file_def456', 'file_ghi789']},
headers={'Authorization': 'Bearer YOUR_API_KEY'}
)
Bulk Delete Response
{
"success": true,
"data": {
"deleted": ["file_abc123", "file_def456", "file_ghi789"],
"failed": [],
"total": 3,
"deleted_count": 3,
"failed_count": 0
}
}
Restore Deleted File
Restore a file from trash:curl -X POST https://api.hubsy.cloud/v1/files/file_abc123/restore \
-H "Authorization: Bearer YOUR_API_KEY"
Restore Response
{
"success": true,
"data": {
"id": "file_abc123",
"name": "document.pdf",
"restored_at": "2024-01-16T10:00:00Z",
"folder_id": "folder_123"
}
}
Related Endpoints
List Trash
GET /trash - View deleted filesEmpty Trash
DELETE /trash - Permanently delete all trashed filesRestore File
POST /files/{file_id}/restore - Restore from trashBulk Delete
POST /files/bulk-delete - Delete multiple filesBest Practices
Confirm Before Deleting
Confirm Before Deleting
Always confirm with users:
- Show file name and details
- Explain trash/recovery period
- Provide undo option
- Log deletion for audit trail
Error Handling
Error Handling
Handle common scenarios:
- File already deleted
- Permission errors
- Invalid file ID
- Network timeouts
Bulk Operations
Bulk Operations
For multiple file deletions:
- Use bulk delete endpoint
- Handle partial failures
- Show progress to users
- Provide summary of results