Use the n8n API to CANCEL (NOT DELETE) a currently running execution for a given workflow.
My use case:
I sometimes want to terminate executions earlier than expected, and this would allow me to create a watchdog workflow to perform these actions, out of band.
I think it would be beneficial to add this because:
I’m honestly flabbergasted that there still exists NO way to cancel a running execution via the n8n API. Yes, there is a concept of DELETE-ing an execution but: 1) that does NOT work for running executions and 2) does not PRESERVE evidence of the execution getting cancelled.
Literally, you can’t even currently QUERY for the list of currently RUNNING executions UNLESS you manually query the backend DB directly (which is another facepalm).
Any resources to support this?
Are you willing to work on this?
I mean, honestly, this work should be handled by the core team. I mean, it’s effectively already implemented in the UI – it’s just a matter of exposing that via the official n8n API. I really don’t understand why AI features are getting prioritized over this (in my opinion) tablestakes feature.
Hi @Javier_from_Flowbyte , the problem is that this endpoint only works if you provide a valid browser cookie – it’s NOT an officially supported n8n API endpoint – meaning, if you try to provide an n8n API key, that endpoint will not work properly.
That’s the core issue – instead of making this endpoint only work for browser interaction, we’re asking to make this endpoint work for official n8n API interactions.
@Darien_Kindlund , @Chris_Masto_DV
I have made a Pull request with this feature. I think your reaction can help.
And, if it possible, you can compile own version with this feature from source.
Hi @Romannep , thanks for contributing! It looks like there were a couple of issues flagged during the PR; however, I’m not sure if any of them are valid. Once you’ve resolved them, let me know and will check it out further.
I can’t comment on the code review due to my company’s restrictive GitHub account, but I have a question/concern:
It looks like this only allows you to stop an execution that is in a “running” status. The workflows that I need to cancel spend most of their time in “waiting”. If I understand this PR correctly, it won’t be possible to use it for that scenario.
Related: while I was looking at that, I noticed the “delete” operation is the other way around: it won’t let you delete a “running” execution, but it doesn’t prevent a “waiting” one from being deleted. I wonder if the latter is actually a bug. I have been using delete as a workaround, but wondering what happens to all those executions. I haven’t traced through the code in detail to see if they are properly cleaned up.