Scheduler API
What is the Scheduler?
The Scheduler is Rocketlane’s internal service that manages time-based execution of jobs. It’s what powers scheduled actions by determining when they should run and triggering them accordingly.
While you define the logic of a scheduled task using scheduledActions
, you must use the Scheduler API to actually register and manage these tasks.
Registering a Scheduled Job
Use r.scheduler.scheduleAppJobs()
to register a job. This is typically done during the onAppInstall lifecycle event.
await r.scheduler.scheduleAppJobs({
schedulerName: "daily_sync",
scheduledAt: Math.floor(Date.now() / 1000) + 60 // Start 1 minute from now
});
Parameters:
schedulerName
(string): Name of the scheduled action defined in your scheduledActions array.scheduledAt
(number): Unix timestamp in seconds for when the job should first run.
Deleting a Scheduled Job
You can cancel a job using:
await r.scheduler.deleteScheduledJob("daily_sync");
This is useful for conditional cleanup (e.g., after N runs, or if a feature is disabled).
Best Practices
- Always register jobs explicitly using
scheduleAppJobs()
insideonAppInstall
. - Use Unix seconds, not milliseconds.
- Handle retries and cleanup inside your run function to keep jobs idempotent.
- Don’t forget to clean up jobs in
onAppUninstall
if needed.
Updated about 1 month ago
What’s Next