{"product_id":"schedule-n8n-api-workflow-cleanup-delete-archived-workflows","title":"Schedule n8n API Workflow Cleanup: Delete Archived Workflows","description":"\u003ch3\u003eSchedule Daily Cleanup of Archived n8n Workflows—With a Safe Preview or Live Deletion\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow automatically scans your n8n instance every day, identifies workflows that are \u003cstrong\u003earchived\u003c\/strong\u003e and older than your chosen retention threshold, and either generates a detailed preview summary or deletes them in batches via the \u003cstrong\u003en8n API\u003c\/strong\u003e—while protecting anything tagged for keep.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eRuns daily at 09:00\u003c\/strong\u003e (in the workflow’s timezone) to start the cleanup process.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eFetches workflows from the n8n API\u003c\/strong\u003e (optionally scoped to a specific \u003cstrong\u003eproject_id\u003c\/strong\u003e).\u003c\/li\u003e\n  \u003cli\u003eFilters down to \u003cstrong\u003earchived workflows\u003c\/strong\u003e only, then validates configuration before proceeding.\u003c\/li\u003e\n  \u003cli\u003eSelects deletion candidates older than the \u003cstrong\u003eretention cutoff date\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003eExcludes any workflow that includes a \u003cstrong\u003eprotected tag\u003c\/strong\u003e (for example, \u003cem\u003e“keep”\u003c\/em\u003e).\u003c\/li\u003e\n  \u003cli\u003eIf \u003cstrong\u003edry_run\u003c\/strong\u003e is enabled (recommended first), outputs a \u003cstrong\u003epreview-style summary\u003c\/strong\u003e with stats and a candidate list.\u003c\/li\u003e\n  \u003cli\u003eIf \u003cstrong\u003edry_run\u003c\/strong\u003e is disabled, splits candidates into individual items and \u003cstrong\u003edeletes workflows via the n8n API\u003c\/strong\u003e using configurable \u003cstrong\u003ebatch_size\u003c\/strong\u003e and \u003cstrong\u003ebatch_interval_ms\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003eFinishes with a final report including retention settings, candidate details, and deletion success\/failure counts.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eKeep your n8n workspace tidy by automatically removing \u003cstrong\u003eold archived automations\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003eEstablish a repeatable retention policy for \u003cstrong\u003eSaaS operations\u003c\/strong\u003e and automation engineers.\u003c\/li\u003e\n  \u003cli\u003eSafely test cleanup rules with \u003cstrong\u003edry-run previews\u003c\/strong\u003e before enabling live deletions.\u003c\/li\u003e\n  \u003cli\u003ePrevent accidental removal by tagging important workflows (e.g., \u003cstrong\u003eprotected_tag\u003c\/strong\u003e = “keep”).\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eUses n8n nodes including \u003cstrong\u003eif\u003c\/strong\u003e, \u003cstrong\u003eset\u003c\/strong\u003e, \u003cstrong\u003ecode\u003c\/strong\u003e, \u003cstrong\u003efilter\u003c\/strong\u003e, and \u003cstrong\u003esplit out\u003c\/strong\u003e.\u003c\/li\u003e\n  \u003cli\u003eRelies on an \u003cstrong\u003en8n API credential\u003c\/strong\u003e for both listing and deleting workflows.\u003c\/li\u003e\n  \u003cli\u003eOutputs a preview or deletion summary depending on \u003cstrong\u003edry_run\u003c\/strong\u003e, with batching controlled by \u003cstrong\u003ebatch_size\u003c\/strong\u003e and \u003cstrong\u003ebatch_interval_ms\u003c\/strong\u003e.\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":45738572218547,"sku":"N8N-17533","price":56.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/Cgv1amJHUcf6-K51IYaQY_vfiO2uye.png?v=1785230045","url":"https:\/\/buyflowscripts.com\/products\/schedule-n8n-api-workflow-cleanup-delete-archived-workflows","provider":"N8N Commerce","version":"1.0","type":"link"}