Scheduling API workflows
API Workflows can be triggered or scheduled internally in your app
While the is useful for building workflows that can be exposed and triggered by external applications and systems, can also be used to schedule workflows in your application.
Scheduled API workflow use cases
There are many use cases where scheduling an API Workflow is a better alternative than running a workflow on the page.
When you need to schedule an action in the future, such as:
Sending an email X number of hours after a User signs up
Send a reminder X number of days before an event
Terminate a trial one month after it has started
Schedule recurring events, such as
Sending a weekly newsletter
Calculate and save statistics or aggregations
Delete redundant data to clean up the database
Performing complex workflows, such as:
Actions that involve complex searches and filtering
Workflows that contain a long list of actions that can take some time to complete
Set up , such as:
Deleting Things in your database that are connected to other things that also need to be deleted or updated
Running from the Bubble editor
If you need to quickly change something on a list of things
Note that bulk operations only accept one parameter: the list of things on which to perform the operation
How to schedule an API Workflow
After you have built the API Workflow you want to trigger, you schedule it to run at the current date-time or in the future by using the action Schedule API Workflow.
You pick the API workflow you want to schedule and define the time of the scheduling. You'll be prompted to fill the different that have been defined at the API workflow level.
Note that if you schedule an API workflow in the past, it will trigger immediately.
Schedule an API Workflow on a list of things
The Schedule an API workflow on a list action currently supports scheduling up to 100,000 workflows. See our dedicated article on hard limits for details
Article: Bubble's hard limits
You can also schedule an API workflow on a list of things. This way you are scheduling one workflow per entry in the list.
For example, if you want to run a workflow on 5,000 users, you can use the Schedule API Workflow on a list of things action to schedule 5,000 separate API workflows. You can then set up that workflow to perform actions on one user at a time.
While this can be used to run a given workflow separately on each item in a list, it's not technically looping – scheduling an API Workflow on a list will schedule one workflow per item, but it will not wait for one to finish before it moves on to the next. In other words, they run in parallell.
Interval
The Schedule an API workflow on a list feature lets you set an interval for the processing. This instructs Bubble to schedule the workflows with a defined gap, such as one second. When using this action, keep in mind the following:
Empty interval: the default empty state (not zero, but empty) interval for Schedule API Workflow on a list will schedule the workflows with a slight gap in order to balance the need to complete jobs as quickly as possible with allowing other workflows in your app to run simultaneously. The entire batch does not need to finish before other scheduled API workflows can run, but for large lists it may take some time to finish.
0 seconds: setting the interval to 0 is technically possible, but it has the drawback of blocking other scheduled workflows until the entire batch is completed. To avoid this bottleneck and allow for smoother processing of scheduled tasks, it's often more effective to leave the interval at its default setting. This approach helps in managing the execution flow more efficiently, ensuring that all scheduled workflows are processed without significant delay.
Third-party rate limits: please note that while an interval is no longer needed to protect the performance of your Bubble app, there are some cases where it may be useful. For example, if your workflows are interacting with external APIs with restrictive rate limits, you may use the scheduling interval to slow down execution and avoid HTTP 429 Error responses.
Workflows still run in parallel: Keep in mind that adding an interval does not guarantee that the workflows will not overlap – see the box below if you need to force your workflows to run sequentially.
Hard limits: keep in mind the hard limits on the lengths of lists that can be scheduled, as stated above.
If you are looking to create an API Workflow that loops over entries in a list sequentially, you can use instead of Schedule API workflow on a list.
Note that recursive workflows are slower and cost more WU than Schedule API workflow on a list.
To schedule an API Workflow on a list, make sure to define your endpoint with a parameter for a particular data type. In this example, we're adding a user parameter.
Then, when you schedule the API workflow on a list, you'll choose the type of thing, the list to run on, and for the parameter you'll be able to choose "this thing".
The API workflow well then run in the context of this thing for each thing in the list.
Canceling a scheduled workflow
The Bubble editor also retains a list of scheduled API workflows where you can view, pause and cancel individual or all scheduled workflows. See more in the article below:
Article: The API workflow scheduler
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 action.
To cancel a list of scheduled Workflows you can use the action.
Other ways to learn
Last updated