client.defineJob({
id: "my-job",
name: "My job",
version: "0.1.1",
trigger: eventTrigger({
  name: "dynamic.cron",
  schema: z.object({
    id: z.string(),
    cron: z.string(),
  }),
}),
run: async (payload, io, ctx) => {
  //registers a DynamicSchedule with a CRON expression 
  await io.registerCron("register-cron", dynamicSchedule, payload.id, {
    cron: payload.cron,
  });
},
});

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 schedule. This is used to identify and unregister the schedule later.

options
object
required

An object containing options about the interval.

cron
string
required

A CRON expression that defines the schedule. A useful tool when writing CRON expressions is crontab guru. Note that the timezone used is UTC.

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 “cron”.

options
object
required

An object containing options about the CRON schedule.

cron
string
required

The registered CRON expression.

metadata
any
required

Any additional metadata about the interval.