Ability to set One Time flow Execution then disable part of workflow (use case: Generate API Token / Refresh API)

The idea is:

The addition of a feature that enables users to set workflows or specific nodes within a workflow to execute only once and then automatically disable or turn off. This functionality would be particularly useful in scenarios where a one-time execution is required, such as generating or refreshing an API token.

My use case:

In my current projects, I frequently need to generate new API tokens for accessing third-party services. Each token has a limited lifetime, and for security reasons, it’s vital to refresh these tokens periodically. Currently, managing this process requires manual intervention or custom scripting, which is not only time-consuming but also prone to errors.

Another use case involves setting up a workflow to perform a one-time data migration or setup task. Once the task is completed, there’s no need for the workflow to run again, and manually disabling it can be a hassle, especially in complex workflows where it’s easy to forget.

I think it would be beneficial to add this because:

  • Efficiency: Automates the process of disabling workflows or nodes after a one-time execution, saving time and reducing manual effort.
  • Error Reduction: Minimizes the risk of accidentally re-running critical one-time processes, which could lead to data duplication, inconsistencies, or breaches in security.
  • Flexibility: Offers more control over workflow execution, allowing for more complex and dynamic setups tailored to specific project requirements.

This feature would enhance the usability and robustness of n8n for a wide range of use cases, making it an even more powerful tool for automating tasks.

Any resources to support this?

While I don’t have direct links to resources that showcase this exact feature, many workflow and automation platforms lack this capability, which often leads to the need for workaround solutions that can be cumbersome and inefficient. Implementing this in n8n would set it apart and provide a strong selling point for users requiring precise control over their automation tasks.

Are you willing to work on this?

I am willing to contribute by providing detailed feedback and testing the feature during its development phase. However, my programming skills are limited, so I might not be able to contribute code directly.

hello @anas

you can handle that with workflowStaticData variable and IF node, or you can move the one-time functionality to another workflow that will have an n8n node in the end, which will disable the flow.

But the right way is to check when the API will return the 401 error and then execute the separate workflow, which will refresh the token.

1 Like

Hey @barn4k Nice workaround for the staticData, but my main reason is to create templates to share. However, I can’t share two templates. It’s also my first time hearing about workflowStaticData. I believe it will be helpful in my templates. Just asking, did you include a workflowStaticData in the example you provided? I’ve checked the code and couldn’t find any workflowStaticData.

A possible example is Self-Destruct After Run X times. The node will be deleted automatically from the workflow on the next run, similar to deleting in the GUI mode when deleting middle node, and both path automatically linked to each other nodes.

You can work with static data only within the Code nodes.

But your scenario is, honestly, not correlates to the n8n logic. As it is a tool to automate stuff. Automate means repetitativity. One-time stuff is a completely different area.