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,
  });
},
});

This has been deprecated in favor of DynamicSchedule.register

Parameters

cacheKey
string
required

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

dynamicSchedule
DynamicSchedule
required

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

id
string
required

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

options
object
required

An object containing options about the interval.

seconds
number
required

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:

id
string
required

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

metadata
any
required

Any additional metadata about the interval.

accountId
string
required

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

schedule
object
required
type
string
required

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

options
object
required

An object containing options about the interval.

seconds
number
required

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

metadata
any
required

Any additional metadata about the interval.