Activate Workflow Node

Maybe I missed out, but is there a way to activate a specific workflow by any trigger f.e webhook.
Almost like the “Workflow” Node only difference that I want to activate a workflow from disabled to “active” to run a workflow just using an interval trigger or cron Job.
Same other way around to disable a whole flow would be a great function for my usecase too.

Thank you in advance :slight_smile:

There is currently no official node for that. What you can however do is to use the the API the editor-UI uses to achieve that.

Here an example how you can active the workflow with the ID 100:

But be aware that the way that API behaves can change in the future and so maybe break. So make sure to test whenever you upgrade n8n to a new version.

Hello @jan,
I have been plying arount with the internal REST again lately.
Is there a way to kill all “Active Tasks”?

https://localhost:5567/rest/executions-current/$n/stop

Is it possible to do a workflow timeout via api? (the function from workflow settings // timeout) It would be very helpful in batch workflows to kill the workflow before restarting it via a cron for example.

It depends on what you are looking for exactly. There is no way to stop all active tasks via the API with one call. What you can do, is to query all active executions and then execute a stop call for each of them.

You can define a timeout for each workflow in its workflow settings. It is also possible to set that value via the API (as everything that can be changed via the editor-UI). Anyway, changes to that value will not change the behaviour of already running workflows.

Hi,
are there any plans in to create such a node?

I need to monitor a website for a certain value, every 17 minutes by cron. when i find this value i trigger a telegram message. After that i can disable the flow.

i managed this manually but an official way would be nicer.

Welcome to the community @Ludger_Berse!

Yes, it is planned. We want to create an n8n-Node that will be able to control n8n itself. It will be identical to other nodes which control external services will this node be able to controle the n8n instance itself. Sadly do have no eta at the moment.

@jan is the toggle workflow active state URL /rest/workflows/:id same for all workflows ?

hey, I’m facing an issue with my workflow. I have just followed the above steps in passing the workflow url http://localhost:5678/workflow/109 through a separate API call as mentioned. I’m not able to deactivate the workflow http://localhost:5678/workflow/109.

Am I going in the right direction? Can you please suggest me any solution??

It changed.

Log into N8N, click settings, click n8n API, generate an API Key.

Use this Nodes and in the headers section enter your api key

api docs: http://yourn8ntld/api/v1/docs/

2 Likes

Hi MartiNBG,

I realize this is an old thread but I am having issues doing this as well. I created a test request within Postman following the details in your example http node, however I receive this as a response

{
    "code": 404,
    "message": "The requested webhook \"GET v1/workflows/9/deactivate\" is not registered.",
    "hint": "The workflow must be active for a production URL to run successfully. You can activate the workflow using the toggle in the top-right of the editor. Note that unlike test URL calls, production URL calls aren't shown on the canvas (only in the executions list)"
}

My url is structured exactly as yours, and I have the same body parameters. I can confirm that this workflow is indeed active. What am I missing?

Hey @wumbowarrior,

It is probably easier to just use the n8n node, If you check out the thread below I shared an example on how you can toggle a workflow from a telegram message.

Hi @Jon,

Yes I saw the n8n nodes, but it is not taking my API key, which is the reason I was attempting it the other way.

Hey @wumbowarrior,

Are you using basic auth with n8n or have n8n in queue mode? It is probably best to open a new thread so we can look into it properly.

Hi Jon,

I did not build this instance, but I’m pretty sure it is in queue mode. I think I will open a new thread. Thanks for the suggestion :slight_smile: