# Log deleted records to Google Sheets

> Keep a copy of every record deleted from a table: use the built-in Delete Logs, or send each deleted record to a Google Sheet with Apps Script.

Source: https://tadabase.com/docs/developers/webhook-to-save-deleted-records  
Status: Verified Nov 17, 2026. Checked against the current product

Sometimes you need a record of what was deleted. Tadabase already keeps one in its Delete Logs. If you want the deleted records in a Google Sheet as well, an outgoing webhook can send each one to a short Apps Script.

> **Workflows have no delete trigger:** No workflow trigger runs when a record is deleted: the record triggers are **Record Created**, **Record Updated** and **Record Created or Updated**. The webhook in this example uses the older **Automation** > **Webhooks** screen, which has a **Delete Record** event.

## No code: the Delete Logs

Open **Settings** > **Logs** > **Records** > **Delete Logs** to see the records deleted from your app. The logs your plan includes decide whether this screen is available.

To read the same log from your own code, call `GET /api/v1/logs/deleted-record-logs` with an API key that has **Allow Logs** turned on. Your plan must include the log API. See [Logs API](https://tadabase.com/docs/developers/logs-api).

## Send deleted records to a Google Sheet

> **Older screen:** If your app can use workflows and has no outgoing webhooks yet, **Automation** > **Webhooks** no longer lets you add one and points you to the **Trigger Webhook** workflow action instead. Apps that already have outgoing webhooks, and apps without workflows, can still add them. If you cannot add one, use the Delete Logs above.

1. **Create the sheet and script** Create a Google Sheet, choose **Extensions** > **Apps Script** and paste the script below. Replace the field slugs in `FIELDS` with the fields you want to keep.
2. **Store a shared secret** In **Project Settings** > **Script Properties**, add `SHARED_SECRET` set to a long random string of your choice.
3. **Deploy it as a web app** Choose **Deploy** > **New deployment**, select the **Web app** type, run it as yourself and give access to **Anyone**. Copy the web app URL.
4. **Add the webhook** In the builder, go to **Automation** > **Webhooks** and click **Add New Webhook**. Give it a **Name**, pick the **Data Table**, and in **URL** paste the web app URL followed by `?key=` and your shared secret.
5. **Choose the event** Set **Event** to **Delete Record** and save.

```javascript
// Adds a row to the "Deleted records" tab for every record a Tadabase webhook reports as deleted.
// Script Properties: SHARED_SECRET

var SHEET_NAME = 'Deleted records';
var FIELDS = ['field_36', 'field_40', 'field_42'];   // replace with your field slugs

function doPost(e) {
  var props = PropertiesService.getScriptProperties();
  if (!e.parameter.key || e.parameter.key !== props.getProperty('SHARED_SECRET')) {
    return ContentService.createTextOutput('forbidden');
  }

  var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = spreadsheet.getSheetByName(SHEET_NAME) || spreadsheet.insertSheet(SHEET_NAME);
  if (sheet.getLastRow() === 0) {
    sheet.appendRow(['Logged at', 'Record ID'].concat(FIELDS));
  }

  // These webhooks send the record as form fields, one per field slug.
  var row = [new Date(), e.parameter.id || ''];
  FIELDS.forEach(function (slug) {
    row.push(e.parameter[slug] || '');
  });
  sheet.appendRow(row);

  return ContentService.createTextOutput('ok');
}

```

Each time a record of that table is deleted, a row is added with the time, the record's ID and the values of the fields you listed.

## Check it worked

- Delete a test record and look for a new row in the **Deleted records** tab.
- If no row appears, check the webhook's log ([Outgoing webhook logs](https://tadabase.com/docs/settings/outgoing-webhook-logs)) and, in the Apps Script editor, **Executions**.
- After you change the script, deploy a new version (**Deploy** > **Manage deployments**) so the web app URL runs the new code.
