This has been deprecated in favor of DynamicSchedule.register

Parameters

keyrequired
string

Should be a stable and unique key inside the run(). See resumability for more information.

dynamicSchedulerequired
DynamicSchedule

A DynamicSchedule that will trigger any Jobs it’s attached to on a regular interval.

idrequired
string

A unique id for the interval. This is used to identify and unregister the interval later.

optionsrequired
object

An object containing options about the interval.

secondsrequired
number

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

Returns

A Promise that resolves to an object with the following fields:

idrequired
string

A unique id for the interval. This is used to identify and unregister the interval later.

metadatarequired
any

Any additional metadata about the interval.

accountIdrequired
string

This will be used by the Trigger.dev Connect feature, which is coming soon.

schedulerequired
object
typerequired
string

The type of schedule. This will always be “interval”.

optionsrequired
object

An object containing options about the interval.

secondsrequired
number

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

metadatarequired
any

Any additional metadata about the interval.

client.defineJob({
id: "my-job",
name: "My job",
version: "0.1.1",
trigger: eventTrigger({
  name: "dynamic.interval",
  schema: z.object({
    id: z.string(),
    seconds: z.number().int().positive(),
  }),
}),
run: async (payload, io, ctx) => {
  //registers a DynamicSchedule with an interval 
  await io.registerInterval("📆", dynamicSchedule, payload.id, {
    seconds: payload.seconds,
  });
},
});