Schedules API

schedules.task#

Declare a recurring task in code.

import { schedules } from "@trigger.dev/sdk";
 
export const morningTask = schedules.task({
  id: "morning-task",
  cron: {
    pattern: "0 5 * * *",
    timezone: "Asia/Tokyo",
  },
  run: async () => {},
});

Output: a version-controlled task schedule that accounts for the declared timezone.

schedules.create#

Create a schedule through the SDK for a task, including dynamic or multi-tenant use cases.

const createdSchedule = await schedules.create({
  task: "morning-task",
  cron: "0 0 * * *",
  deduplicationKey: "my-deduplication-key",
});

Output: a created schedule. Confirm the current parameter names in the upstream scheduled tasks guide before use.

Next steps#

Updated

Was this page helpful?