Delete a backup
This example demonstrates how to delete a specific backup in ONLYOFFICE DocSpace using the API by providing its unique backup ID.
Before you start
- Replace
https://yourportal.onlyoffice.comandYOUR_API_KEYwith your actual DocSpace portal URL and API key. Ensure you have the necessary data and permissions to perform migration operations. - Before you can make requests to the API, you need to authenticate. Check out the Personal access tokens page to learn how to obtain and use access tokens.
Full example
- Node.js
- Python
// Config
const API_HOST = 'https://yourportal.onlyoffice.com';
const API_KEY = 'your_api_key';
// Headers with authentication
const HEADERS = {
Authorization: API_KEY,
};
function deleteBackup(backupId) {
const url = `${API_HOST}/api/2.0/backup/deletebackup/${backupId}`;
return fetch(url, {
method: 'DELETE',
headers: HEADERS,
})
.then((res) => {
if (res.status === 200) return res.json();
const text = await res.text();
console.log(`Backup deletion failed. Status code: ${res.status}, Message: ${text}`);
return null;
})
.then((data) => {
if (!data) return null;
const result = data?.response;
console.log(`Backup deleted: ${result}`);
return result;
})
.catch((err) => {
console.error(err.message);
});
}
// Run example
deleteBackup('your-backup-id');
import requests
API_HOST = 'https://yourportal.onlyoffice.com'
API_KEY = 'your_api_key'
# Headers with authentication
HEADERS = {
'Authorization': API_KEY
}
def delete_backup(backup_id: str):
# Send DELETE request to remove the specified backup
response = requests.delete(
f'{API_HOST}/api/2.0/backup/deletebackup/{backup_id}',
headers=HEADERS
)
if response.status_code == 200:
result = response.json().get('response')
print(f"Backup deleted: {result}")
return result
else:
print(f"Backup deletion failed. Status code: {response.status_code}, Message: {response.text}")
return None
if __name__ == '__main__':
# Example: Replace with actual backup ID from backup history
delete_backup('your-backup-id')
How it works
A DELETE request is sent to /api/2.0/backup/deletebackup/:id where:
id— UUID of the backup to delete (retrievable from /api/2.0/backup/getbackuphistory).
If successful (200), the API returns:
response— boolean (true if the deletion was successful).count,links,status,statusCode— metadata fields.
After deletion, the specified backup file is removed from the configured storage and will no longer be available for restoration.