Skip to main content

Overview

Schedule agents to run automatically at specific times or intervals.

Creating a Schedule

const schedule = await rt.schedules.create({
  deployment: 'my-email-bot',
  cron: '0 9 * * *',  // Every day at 9am
  message: 'Check my inbox and summarize important emails',
  timezone: 'America/New_York',
});

Cron Syntax

Standard 5-field cron format: minute hour day month weekday
FieldPositionValues
Minute1st0-59
Hour2nd0-23
Day of month3rd1-31
Month4th1-12
Day of week5th0-6 (0 = Sunday)

Examples

CronDescription
0 9 * * *Every day at 9:00 AM
0 * * * *Every hour at minute 0
0 9 * * 1-5Weekdays at 9:00 AM
0 9 * * 1Every Monday at 9:00 AM
0 9 1 * *1st of each month at 9:00 AM
*/15 * * * *Every 15 minutes

Managing Schedules

// List schedules
const schedules = await rt.schedules.list();

// Pause schedule
await schedule.pause();

// Resume schedule
await schedule.resume();

// Delete schedule
await schedule.delete();

// Update schedule
await schedule.update({
  cron: '0 10 * * *',  // Change to 10am
});

Schedule Runs

View runs triggered by a schedule:
const runs = await rt.runs.list({
  scheduleId: schedule.id,
});

for (const run of runs) {
  console.log(run.status, run.completedAt);
}

Notifications

Get notified when scheduled runs complete:
const schedule = await rt.schedules.create({
  deployment: 'my-bot',
  cron: '0 9 * * *',
  message: 'Daily task',
  webhookUrl: 'https://myapp.com/webhook',
});

Best Practices

Don’t schedule more frequently than needed. Consider costs.
Ensure scheduled runs have appropriate timeout limits.
Set up webhooks to catch failed scheduled runs.
Always specify timezone to avoid confusion.