I have a scenario for an API call, the API requires an access token that is valid for 1 hour.
I’m storing the access token in a data store
The scenario has a router with 2 routes:
access token not found or expired, so request a new one and store in data store
access token found and still valid, so make API call
All of this works well, but my question is: since goal of scenario is to always make an API call, what’s the most elegant way of making the API call after new access token has been requested and stored, while avoiding duplication of modules?
Well since either way it goes you end up with a new valid token in the data store, search the data store to get the latest token and make the API call with that one.
Most elegant solution I could find is making first 2 routes conditional and set access token variable (either with value of newly generated one or with value of valid one from data store), then unconditionally run 3rd route afterwards and read access token variable
alternatively, route 2 could be removed and in api request module [1] an if statement in token value field could check if “get variable” [25] resulted in emptystring or not and then choosing retrieved [10] or generated [24] token accordingly
If–Else and Merge modules – Available early 2026 on all plans
Build robust, sophisticated automations faster by natively handling complex conditional logic. The new If–Else module provides a clean way to branch your scenarios, while the Merge module provides a much-requested way to consolidate them. Both empower your team to create efficient automations at speed while ensuring clarity and reducing long-term maintenance overhead.