Cancel API Workflow Loop

I have a workflow loop that refreshes the token to one of the software I am connected to.
I cannot call the token every single time, as this software has problems with it.
As my limit of loops is 5 k it dies at some point.
But, I would like to give a user the button, to stop the workflow loop and start new. Not to have 2 loops running in the background.
Is there a way to do it directly?
If not what is the best way to handle?

I have an idea to create an element in the database that will stop the loop from happening and only the newest loop will have the freshest and correct parameter. But maybe you people know a better way?

Hey @michal.friedrich. So not sure whether you’re using a recurring event or whether you have configured an API workflow to be recursive workflow.

If you’re using a recurring event to refresh token:
Use the action ‘set/cancel recurring event’ to stop the loop

If you’re using an API workflow that is configured recursively so essentially reschedules itself periodically I would suggest using the action ‘Cancel a scheduled workflow’ to cancel the loop, before triggering the new loop.

Hope that helps

Thanks @betteredbritain

You have navigated me to one place in documentation that helps me:

I was looking for this answer:

Whenever you schedule an API workflow Bubble generates a unique ID for that specific instance. The Schedule API workflow returns that ID so that you can reference that in a later step in the same workflow:

You can use this ID to cancel the API workflow at any time before it is scheduled to run by using the Cancel a scheduled API Workflow action.

So it means I have to store it somewhere in a special database and then later cancel the newest one. Brilliant! BTW Interesting if I can retrieve information from it. - that would be good as I actaully miss this feature to show user the running api workflows.

PS: I cannot use recurring workflows - for me one the most useless feature of whole bubble - as it doesn’t allow to create incidents more often than once per day. Apart from maybe 3-5 situations - all my recurring actions happen more often.

I’m glad this was helpful!

I would agree. Recursive workflows are annoyingly limited and pretty much not viable for most use cases at scale.

If this is the answer you were looking for, please mark it as the solution. It will look really good on my profile :sweat_smile:

No problem.

But if you want to really give solutions to problems - it would be good to be more precise as canceling workflow isn’t the solution - as in normal workflow you can only catch previous wf id. What I explained in my post is the solution based on what you navigated me to :slight_smile:

Ahh I see. thanks anyway man :slightly_smiling_face: