Clean up archived workflows with the n8n API on a schedule
Ready for 3.0Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.
Nodes used (8)
- n8n
n8n-nodes-base.n8n - Schedule Trigger
n8n-nodes-base.scheduleTrigger - Edit Fields (Set)
n8n-nodes-base.set - Code
n8n-nodes-base.code - If
n8n-nodes-base.if - Split Out
n8n-nodes-base.splitOut - Stop and Error
n8n-nodes-base.stopAndError - Filter
n8n-nodes-base.filter
What it does
Quick overview This workflow runs daily and uses the n8n API to find archived workflows older than a retention threshold, optionally deleting unprotected ones in batches while producing a detailed preview or deletion summary. How it works 1. Runs every day at 09:00 (workflow timezone) on a schedule. 2. Fetches workflows from the n8n API (optionally scoped to a specific project) and keeps only workflows marked as archived. 3. Validates configuration, then selects deletion candidates based on the retention cutoff date while excluding workflows that include a protected tag. 4. If dry-run mode is enabled or no candidates exist, outputs a preview-style summary with stats and the candidate list. 5. If dry-run mode is disabled, splits candidates into individual items and deletes the workflows via the n8n API using configurable batching. 6. Outputs a final summary including retention settings, candidate details, and deletion success/failure counts. Setup 1. Create/select an n8n API credential and assign it to the workflow list and delete actions. 2. In the config values, set your retention period and keep dryrun enabled until you have reviewed the preview output. 3. If you plan to enable live deletion (dryrun = false), set projectid to the target n8n project to avoid validation errors. 4. Set protectedtag to a tag name (for example, "keep") and ensure any workflows you never want deleted are tagged accordingly. 5. Adjust batchsize and batchintervalms to match your instance’s API limits and desired deletion pace.