N8n API | Stop/cancel execution

I have a webhook that receives a query from a GUI interface and starts a process. Depending on the query, this process can take a long time in most cases.

I need a way to cancel the process based on the execution ID without having to open n8n executions and stop it manually from there.

I think I could solve this with:
Webhook w/ n8n execution ID => n8n API to stop the execution

However, it doesn’t look like the n8n API currently supports this. It only supports deleting an execution, but I want to keep that execution there and just stop or cancel it.

This would be very useful in many cases, especially when the end user doesn’t have access to n8n and keeping the execution running consumes API credits (in my case, OpenAI credits).

Hi brahimh, you can do that with

/rest/executions/{{$execution.id}}/stop

1 Like

Could you tell me more about this solution? How do you implement it?

Hi Mauro, you just need to pass the execution ID in the URL and the login cookie in the headers

Hi
Is this endpoint still working?

/rest/executions/{{$execution.id}}/stop

Trying it with GET returns The resource you are requesting could not be found - Though the execution is running. Sending a POST returns Authorization failed - please check your credentials

Hi @mido9,

I believe it does but its limited. I tried it earlier today too and had the same issues. I tried using both

/api/v1/executions.../stop

&

/api/v1/executions.../cancel

with different header types, but as stated above you need to pass in the login cookie which is not a solution for any production environment.

Good news however! There is another thread on this issue where someone made a Pull Request to implement this functionality into the api properly. So I guess we wait and see what comes of it, someone did mention we should be merging these requests as the votes are being split, but I’m not sure how to do that.

Let’s hope it gets approved soon, I could really use this feature🤞🏼