Cron jobs
Cron jobs run recurring backend work on a schedule. Starting with the JavaScript SDK version 0.5.0, you can create and manage command or HTTP cron jobs directly from your application code.
These APIs require
stackmachineversion 0.5.0 or later. Cron jobs created through the SDK useclient.apps.cronjobs.
Features
Command and HTTP targets
Create an EXECUTE job to run a command in the app environment, or a FETCH job to call an HTTP path on the app. A job’s target kind is fixed when it is created.
Lifecycle management
Create, retrieve, update, pause, and delete API-sourced cron jobs without leaving the SDK.
Filtering and pagination
List an app’s cron jobs, filter them by EXECUTE or FETCH, sort by newest or oldest, and use the standard SDK pagination helpers.
Execution controls
Set whether a job is enabled and optionally configure retries, maximum schedule drift, and a timeout when creating or updating it.
Common workflow
- Choose the app and decide whether the job should execute a command or fetch an HTTP path.
- Create the cron job with a name, cron schedule, and exactly one target.
- List or retrieve jobs to inspect their current configuration.
- Update the schedule or enabled state, or delete an API-sourced job when it is no longer needed.
SDK examples
Create command and HTTP cron jobs
Schedule a nightly cleanup command and a five-minute HTTP health check. Pass exactly one of execute or fetch when creating each job.
List and retrieve cron jobs
List jobs for an app with optional kind and sort filters, then retrieve one job by ID.
Update and delete a cron job
Pause a job without deleting it, change its schedule, or permanently delete an API-sourced job.
Related docs
Source: stackmachine/sdks JavaScript examples.