With the n8n API, How do know if a workflow is published and OK?

I found some answers about testing if a workflow is running. But I’m interested in if it is published & OK (like the green bullet next to it in the workflow editor view).

Describe the problem/error/question

Running n8n locally on laptop.
CONTEXT: Created a workflow that is triggered / ~10 minutes. Checks my emails, selects some and summarizes them, then submits to a RocketChat channel.
Unfortunately, many errors happen, which “unpublish” it (e.g.: mail provider error, LLM errors, laptop lid closed → n8n sleeps, etc).
Thus, I’ve created a secondary workflow that restarts the primary:

  • on any error (nodes in primary raise errors)
  • on n8n start (n8n container starts at boot)

But I still get cases where the primary workflow stops. Wanting to add a 3rd case:

  • a trigger every 1h that checks if the workflow is “down” and, if so, restarts it.

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).
Due to my particular setup:

  • I cannot just check if my primary workflow is published
  • I cannot just check if it is running, like in the posts I found here, since my workflow can just be “sleeping” in-between two 10 min triggers.

So my question: How do I get the same information as is underlying the display of the red/green/yellow bullet next to a workflow in editor mode, using the n8n API node?

Information on your n8n setup

  • n8n version: 2.45.7
  • Database (default: SQLite): default
  • n8n EXECUTIONS_PROCESS setting (default: own, main): own, main
  • Running n8n via (Docker, npm, n8n cloud, desktop app): running in home made incus container that starts npx n8n
  • Operating system: Debian 14 guest / LMDE 7 Host

Checking the `active` flag via the n8n API only tells you if the workflow is toggled on, which is why it remains true even when runtime errors trigger a red bullet. To programmatically check health, you should query the `/executions` endpoint filtered by `status=error` alongside your workflow status check to verify if the last run succeeded. Let me know what database backend you are using for your self-hosted setup and I can outline the exact API call sequence right here.

Hey @liar666 Welcome to the commnuity,
The n8n API node’s Workflow Get doesn’t expose the same status as that dot in 2.45.7. The editor combines trigger publication status with draft changes and configuration issues, so active=true doesn’t guarantee a green dot.

With the default publication service enabled, the editor uses GET /rest/workflows/<id>/publication-status. Its response has data.status (published, partial, failed, in_progress or not_published) and data.triggers with activation errors. You can inspect it in your browser while logged in. It’s an internal session-authenticated route, so your n8n API key won’t work there. Yellow can just mean unpublished edits, and publication status doesn’t guarantee the next email/LLM execution will succeed. What does the red dot’s tooltip say when it stops?

The workflow object from the API has an active flag, so check that on your ten minute run and reactivate if it’s false. Active only tells you it’s switched on though, not that it’s healthy. Pulling the latest executions and checking for a recent success is a better test. A laptop that sleeps will keep biting you too.

Nice thanks.

Unfortunately I cannot manage to make that work to the end.

I’m using Http Request to get that URL, but I get the 401 Unauthorized error in return.

  • I tried adding a “Predefined Credential” with my n8n API key, but it does not work

  • I tried giving more accesses to this key (it was configured with least priviledges in mind: read&activate workflows only), but it still does not work

  • I tried adding a custom HTTP header with “Authorization” and ‘Bearer [key]’, but it still does not work.

Any ideas what I’m doing wrong here?

@liar666 The 401 means the request isn’t carrying the API key in the header n8n expects. In the HTTP Request node, don’t use a generic “Predefined Credential” — instead set Authentication to “Generic Credential Type” → “Header Auth”, with Name X-N8N-API-KEY and Value = your n8n API key. Or use the dedicated “n8n API” credential type if your node version offers it.

A couple of things to double-check: the key must be created under Settings → n8n API (not a user password), and if your instance sits behind a reverse proxy, make sure the proxy isn’t stripping the X-N8N-API-KEY header before it reaches n8n. You can verify quickly with curl from the same machine: curl -H "X-N8N-API-KEY: <key>" http://localhost:5678/api/v1/workflows — if that returns 200, the key is fine and the issue is just how the node sends it.

@liar666 HomelabAgent’s tip is correct for the public API (/api/v1/...), but GET /rest/workflows/<id>/publication-status is not part of that API. In 2.45.7 that path is an editor/rest route that expects a logged-in browser session cookie, so X-N8N-API-KEY (or Authorization: Bearer) will keep returning 401 no matter how you send it. That matches what Deepankar described earlier.

What you can do with an API key for a watchdog:

  1. Confirm the workflow is still switched on:

    • GET /api/v1/workflows/<id> → check active === true
    • if false → POST /api/v1/workflows/<id>/activate
  2. Treat “OK” as “recent successful run”, not the editor bullet (the bullet mixes publication status, draft changes and trigger config, and isn’t exposed on the public API):

    • GET /api/v1/executions?workflowId=<id>&limit=5
    • if the newest finished execution is error / crashed, or there is no success newer than your ~10‑minute cadence plus a buffer, treat it as down and reactivate / alert

HTTP Request node setup that works with the key:

  • Authentication → Generic Credential Type → Header Auth
  • Name: X-N8N-API-KEY
  • Value: your key from Settings → n8n API
  • URL example: http://localhost:5678/api/v1/executions?workflowId=YOUR_WORKFLOW_ID&limit=5

Quick curl check from the same host:

curl -sS -H "X-N8N-API-KEY: YOUR_KEY" \
  "http://localhost:5678/api/v1/workflows/YOUR_WORKFLOW_ID"

If that returns 200 but /rest/.../publication-status still returns 401, you’re not doing anything wrong — that endpoint simply isn’t API-key auth’d. For a laptop that sleeps, also keep the re-activate-on-start path; no status API will fire while the process is suspended.

Hi @liar666,

The reason active: true or workflowPublishHistory doesn’t tell you if the workflow is in error is that the Workflows API only returns the registered activation state (whether the trigger listener is enabled), not the runtime execution health.

To get the equivalent of the red/green status bullet, you should query the Executions API instead:

GET /api/v1/executions?workflowId=<WORKFLOW_ID>&limit=1

One correction that matters for this watchdog: a node, email, or LLM error does not normally set the workflow’s active flag to false. active=true only means its trigger is registered. The red/green dot in the editor also reflects publication, draft, and trigger-configuration state, not whether the latest business execution succeeded.

I would use two independent checks:

  1. GET /api/v1/workflows/{id}
    If active === false, activate it once and send an alert. Do not automatically reactivate merely because an execution failed; that can hide the real error and create a restart loop.

  2. GET /api/v1/executions?workflowId={id}&limit=5
    Inspect the latest completed execution. Alert if the status is error/crashed, or if there is no successful execution within schedule interval + grace period. For a 10-minute schedule, something like 15 minutes is a reasonable starting threshold.

  3. Put the heartbeat outside n8n.
    On every successful scheduled run, call a monitor such as Healthchecks.io, Uptime Kuma push, or another external endpoint. If n8n is stopped, the laptop sleeps, or the container dies, the missing heartbeat must generate the alert. A watchdog running inside the same n8n instance cannot report that n8n itself is down.

Also enable Save failed production executions and configure an Error Workflow. The key is to keep activate-if-inactive separate from alert-if-unhealthy. A failed run is normally a node/credential/API problem, not a reason for n8n to unpublish the workflow.