跳到主要内容

Delete the backup history

This example demonstrates how to delete the entire backup history in ONLYOFFICE DocSpace using the API.

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
// Set API base URL
const API_HOST = 'https://yourportal.onlyoffice.com';
const API_KEY = 'your_api_key';

// Headers with authentication
const HEADERS = {
Authorization: API_KEY,
};

function deleteBackupHistory(dump) {
// Optional query parameter: dump backups or not
const params = new URLSearchParams({ Dump: String(dump).toLowerCase() });
const url = `${API_HOST}/api/2.0/backup/deletebackuphistory?${params.toString()}`;

// Send DELETE request to remove backup history
return fetch(url, {
method: 'DELETE',
headers: HEADERS,
})
.then((res) => {
if (res.status === 200) return res.json();
const text = await res.text();
console.log(`Backup history deletion failed. Status code: ${res.status}, Message: ${text}`);
return null;
})
.then((data) => {
if (!data) return null;
const result = data?.response;
console.log(`Backup history deleted: ${result}`);
return result;
})
.catch((err) => {
console.log(`Backup history deletion error: ${err.message}`);
});
}

// Example: Delete history without dump backups
deleteBackupHistory(false);

How it works

A DELETE request is sent to /api/2.0/backup/deletebackuphistory with an optional query parameter:

Dump — boolean; set to true if the history should also include dump backups in the deletion, or false otherwise.

If successful (200), the API returns:

  • response — boolean (true if the deletion was successful).
  • count, links, status, statusCode — metadata fields.

After this operation, the backup history will be cleared, and the records will no longer be available in /api/2.0/backup/getbackuphistory.