跳到主要内容

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

  1. Replace https://yourportal.onlyoffice.com and YOUR_API_KEY with your actual DocSpace portal URL and API key. Ensure you have the necessary data and permissions to perform migration operations.
  2. 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
// 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');

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.