Kingdom of KumarBack to home

Fix · n8n

Get alerted when an n8n workflow silently stops succeeding

By Mayank Raj · Kingdom of Kumar · Published 5 November 2026

The problem

“When I use the API node to retrieve the primary workflow, I can “workflowPublishHistory” or “active”. Unfortunately, they are both true/activated even if the workflow is in error (red bullet in editor’s view).”

liar666, With the n8n API, How do know if a workflow is published and OK? (n8n community forum, 3 Nov 2026)

Same problem elsewhere: r/n8n: runs green but did nothing · r/n8n: monitoring many workflows · Zapier: a Zap that silently stopped

Short answer: Don't ask n8n whether the workflow is on. Ask when it last succeeded. Call GET /api/v1/executions?workflowId=<id>&status=success&limit=1 with the X-N8N-API-KEY header, compare the newest startedAt to your schedule, and alert when it is older than the gap you allow. The internal /rest/workflows/<id>/publication-status route behind the editor dot uses your login session, so an API key gets a 401 there.

A workflow on a 10 minute schedule can stay active for days while every run errors, or while the machine running n8n is asleep. The one signal that catches all of those is "how long since a successful execution". The watchdog checks that, plus the active flag and recent errors, and gives each workflow a verdict: OK, STALE, INACTIVE or ERRORING.

Download

Everything is free to use. The scripts are Python 3 standard library only and default to read-only or dry-run. Each one ships with an offline test on sample data.

Step by step

1. Create an API key

In n8n go to Settings, n8n API, and create a key. Then create a Header Auth credential named "n8n API key header" with Name X-N8N-API-KEY and the key as Value. This is the public API. Bearer tokens and the internal /rest routes will not work with it.

2. Test the key from the n8n machine

If this returns 200, the key is fine and any 401 is about how the node sends it.

curl -H "X-N8N-API-KEY: $N8N_API_KEY" http://localhost:5678/api/v1/workflows

3. Import the watchdog

Import watchdog.n8n.json. In the Config node, set the base URL, the workflow ids to watch (from each editor URL), maxSilenceMinutes (default 30) and your Slack, Discord or RocketChat incoming webhook URL. Select the credential on the HTTP Request nodes.

4. Understand the three calls

For each workflow id it reads the workflow (active flag), the newest successful execution, and the five newest error executions.

GET {base}/api/v1/workflows/{id}
GET {base}/api/v1/executions?workflowId={id}&status=success&limit=1
GET {base}/api/v1/executions?workflowId={id}&status=error&limit=5

5. Read the verdict

The Code node computes minutes since the last success. More than maxSilenceMinutes is STALE. Active false is INACTIVE. An error newer than the last success is ERRORING. Anything that is not OK goes to your alert webhook.

6. Optional: turn it back on

Set autoReactivate to true in Config and the watchdog will call POST /api/v1/workflows/{id}/activate for INACTIVE workflows. That only switches it on. It does not fix the cause.

7. Run the watchdog somewhere that stays awake

If n8n runs on a laptop, a watchdog inside the same n8n sleeps with it. Run watchdog.py from cron on a server or another always-on box. It is dry-run by default; --apply sends alerts.

*/30 * * * * N8N_API_KEY=... ALERT_WEBHOOK_URL=... /usr/bin/python3 /path/watchdog.py --base-url https://your-n8n --workflow-id abc123 --apply

8. Check it offline first

The zip includes fixtures for a healthy, a stale and an inactive workflow.

python3 watchdog.py --mock sample --workflow-id wf-healthy --workflow-id wf-stale --workflow-id wf-inactive
python3 test_fix.py

What this does not cover

Want this done for you?

Kingdom of Kumar runs it for $500/month, first automation live in 48 hours. Claude + Grok Bot + $500/month (my fee). Email me the task you hate doing every week.

Email me the task

Related: Internal workflow automation · All fixes