MVMP Labs
← All posts

How To Delete Webflow CMS Items via Airtable Scripts

Delete one confirmed Webflow test draft from Airtable with a default dry run, saved snapshot, and recovery guidance.

By Connor FinlaysonOctober 23, 20213 min read
How To Delete Webflow CMS Items via Airtable Scripts
Tools coveredAirtableWebflow

The original 2021 tutorial deleted Webflow items using Airtable scripts. Deletion needs a narrower scope than routine updates.

This replacement uses Airtable automation scripting and Webflow Data API v2. Start with one disposable draft item in a test collection.

Confirm the exact target

Use an Airtable Listings table with text fields Webflow ID and Deletion Log. Keep the source record after deletion.

Configure inputs recordId, collectionId, confirmedItemId, and dryRun. Begin with dryRun set to true.

Add a script secret named webflowToken containing a token limited to the intended test site.

Copy the target item ID into confirmedItemId only after reviewing it. A blank or mismatched confirmation must stop the script.

Read before deleting

const { recordId, collectionId, confirmedItemId, dryRun } = input.config();
const token = input.secret.webflowToken;
if (!recordId || !collectionId || !token) throw new Error('Missing configuration.');
const table = base.getTable('Listings');
const record = await table.selectRecordAsync(recordId);
if (!record) throw new Error('Record not found.');
const itemId = record.getCellValueAsString('Webflow ID').trim();
if (!itemId || confirmedItemId !== itemId) {
  throw new Error('Confirm the exact Webflow item ID first.');
}
const url = `https://api.webflow.com/v2/collections/${encodeURIComponent(collectionId)}/items/${encodeURIComponent(itemId)}`;
const headers = { Authorization: `Bearer ${token}` };
const read = await fetch(url, { headers });
if (!read.ok) throw new Error(`Target lookup failed: ${read.status}`);
const item = await read.json();
if (item.id !== itemId) throw new Error('Target mismatch.');
if (!item.isDraft || item.lastPublished) {
  throw new Error('This example deletes only never-published draft test items.');
}
const snapshot = JSON.stringify({ itemId, collectionId, item });
output.set('preview', snapshot);
if (dryRun === false) {
  await table.updateRecordAsync(recordId, { 'Deletion Log': snapshot });
  const result = await fetch(url, { method: 'DELETE', headers });
  if (result.status !== 204) throw new Error(`Delete failed: ${result.status}`);
  await table.updateRecordAsync(recordId, {
    'Deletion Log': JSON.stringify({ itemId, deleted: true, snapshot: item }),
    'Webflow ID': ''
  });
  output.set('deletedItemId', itemId);
}

Webflow’s delete reference documents the endpoint and 204 success response.

Airtable’s scripting action explains automation inputs and secret access.

The example refuses published items. Live removal and publication behavior require their own reviewed workflow.

Test the stop rules

Dry-run one selected item. Compare the returned name, slug, collection, and ID with Webflow before proceeding.

Try a mismatched confirmation ID. It should stop before deletion.

Delete one disposable test draft with boolean dryRun = false. Check that another draft remains unchanged.

Confirm the saved log contains the deleted item data. A repeated run should stop because the mapping is empty.

A network timeout can leave deletion uncertain. Recheck the destination before trying again.

Plan recovery before a larger change

Keep an independent export of target records and files. A JSON snapshot alone may omit reusable file assets or related records.

Recreating an item can produce a new ID. Update relationships and source mappings during recovery.

Prefer a reviewed archive or unpublish action when it meets your goal. Do not use deletion to hide a record temporarily.

Review the create-item workflow before designing recovery.

Original recording timestamps

  • 01:55: Original script library.
  • 04:13: Installing the script and button.
  • 05:07: Changing the script.
  • 10:03: Original test and run.
  • 11:18: Debugging errors.

Original video

Watch the original demonstration.

Keep learning

More guides, free videos and course access for existing members, all in one place.

Go to Learn

Rather have it built for you?

We'll match you with vetted agentic talent who build it with AI, inside the tools you already use.

Schedule a call