Clean up archived workflows with the n8n API on a schedule
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 Runs every day at 09:00 (workflow timezone) on a schedule. Fetches workflows from the n8n API (optionally scoped to a specific project) and keeps only workflows marked as archived. Validates configuration, then selects deletion candidates based on the retention cutoff date while excluding workflows that include a protected tag. If dry-run mode is enabled or no candidates exist, outputs a preview-style summary with stats and the candidate list. If dry-run mode is disabled, splits candidates into individual items and deletes the workflows via the n8n API using configurable batching. Outputs a final summary including retention settings, candidate details, and deletion success/failure counts.
Setup Create/select an n8n API credential and assign it to the workflow list and delete actions. In the config values, set your retention period and keep dry_run enabled until you have reviewed the preview output. If you plan to enable live deletion (dry_run = false), set project_id to the target n8n project to avoid validation errors. Set protected_tag to a tag name (for example, "keep") and ensure any workflows you never want deleted are tagged accordingly. Adjust batch_size and batch_interval_ms to match your instance’s API limits and desired deletion pace.
Related Templates
Automate Customer Support & Calendar Bookings with OpenAI GPT and Google Calendar
Website AI Agent with Calendar Integration Categories: AI Agents, Website Integration, Calendar Automation This workfl...
Score Company ICP (Ideal Customer Profile) with Airtop
Automating Company ICP Scoring via LinkedIn Use Case This automation scores companies based on their LinkedIn profile...
Enrich new accounts in Pipedrive using Datagma API
This workflow enriches new accounts in Pipedrive using Datagma API by adding data about ICP (ideal customer profile). In...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments