client.defineJob({
  id: "scheduled-job-1",
  name: "Scheduled Job 1",
  version: "0.1.1",
  // Every 5 minutes
  trigger: intervalTrigger({
    seconds: 60 * 5,
  }),
  run: async (payload, io, ctx) => {
    await io.logger.info("Received the scheduled event", {
      payload,
    });

    return { foo: "bar" };
  },
});

Development

Scheduled Triggers do not trigger Jobs in the DEV Environment. When you're working locally you should use the Test feature to trigger any scheduled Jobs.

Defining an interval

Intervals are set with a number of seconds. There are some important considerations:

  • The Job will first run the specified number of seconds after it has first connected to an Environment. This will happen when you first deploy that Job.
  • The minimum interval is 20 seconds (any input less than this it will default to 20).
  • The maximum interval is 2_592_000 seconds (30 days), if you pass more than this it will trigger every 30 days.

If you wish to Run a Job at an exact time or less frequently than once pr day you should use a cronTrigger() instead.

Parameters

options
object
required
seconds
number
required

The number of seconds for the interval. Min = 60, Max = 2_592_000 (30 days)