Triggers

Scheduled Triggers

Copy page

Run your Agents on a schedule using cron expressions or one-time execution

Scheduled triggers let you run agents automatically on a recurring schedule (cron) or at a specific future time (one-time). Scheduled triggers are driven by time and can be used for daily reports, hourly health checks, periodic data syncs, or deferred tasks.

Schedule Types

Cron Expressions (Recurring)

Cron triggers use standard 5-field cron syntax to define recurring schedules:

┌───────────── minute (0–59)
│ ┌───────────── hour (0–23)
│ │ ┌───────────── day of month (1–31)
│ │ │ ┌───────────── month (1–12)
│ │ │ │ ┌───────────── day of week (0–7 or MON–SUN)
│ │ │ │ │
* * * * *

Common examples:

ExpressionDescription
0 9 * * *Every day at 9:00 AM
0 9 * * MON-FRIWeekdays at 9:00 AM
*/15 * * * *Every 15 minutes
0 */2 * * *Every 2 hours
0 0 1 * *First day of every month at midnight

Trigger Configuration

OptionTypeRequiredDefaultDescription
namestringYesHuman-readable name
descriptionstringNoDescription of the trigger's purpose
enabledbooleanNotrueWhether the trigger is active
cronExpressionstringOne of cronExpression or runAt5-field cron expression for recurring execution
cronTimezonestringNoUTCIANA timezone for cron evaluation
runAtstringOne of cronExpression or runAtISO 8601 timestamp for one-time execution
messageTemplatestringNoTemplate with {{placeholder}} syntax
payloadobjectNoStatic JSON payload passed to the agent
maxRetriesnumberNo1Max retry attempts on failure (0–10)
retryDelaySecondsnumberNo60Seconds between retries (10–3600)
timeoutSecondsnumberNo780Execution timeout in seconds (30–780)
Note
Note

You must specify either cronExpression or runAt, but not both. The system validates this at creation time.

Message Templates

Message templates use {{placeholder}} syntax to interpolate values from the payload:

const weeklyDigest = scheduledTrigger({
  name: 'Weekly Digest',
  cronExpression: '0 8 * * MON',
  payload: {
    reportType: 'weekly',
    includeMetrics: true,
  },
  messageTemplate: 'Generate a {{reportType}} digest. Include metrics: {{includeMetrics}}',
});

When the trigger fires, the agent receives:

  • A text part with the interpolated message: "Generate a weekly digest. Include metrics: true"
  • A data part with the full payload object

If messageTemplate is omitted, the agent receives only the JSON-serialized payload.

Retry Configuration

Failed executions are automatically retried based on your configuration:

const resilientTask = scheduledTrigger({
  name: 'Critical Data Sync',
  cronExpression: '0 */4 * * *',
  messageTemplate: 'Sync data from external source',
  maxRetries: 5,           // Retry up to 5 times
  retryDelaySeconds: 120,  // Wait 2 minutes between retries
  timeoutSeconds: 600,     // Each attempt times out after 10 minutes
});

Each retry creates a new conversation with the agent. All conversation IDs are tracked on the invocation record so you can review each attempt.

Invocation Tracking

Every scheduled execution creates an invocation record with full observability:

FieldDescription
Statuspendingrunningcompleted, failed, or cancelled
Scheduled ForThe time the invocation was scheduled to run
Started AtWhen execution actually began
Completed AtWhen execution finished
Attempt NumberCurrent attempt (1-based, increments on retry)
Conversation IDsAll conversations created across attempts
Idempotency KeyEnsures exactly-once execution

Invocation Statuses

Manual Operations

Run Now

Trigger an immediate execution of any scheduled trigger, regardless of its schedule:

POST /manage/tenants/{tenantId}/projects/{projectId}/agents/{agentId}/scheduled-triggers/{id}/run

This creates a new invocation scheduled for the current time and executes it immediately with the trigger's configured payload, message template, and retry settings.

Rerun a Past Invocation

Rerun any completed, failed, or cancelled invocation:

POST /manage/tenants/{tenantId}/projects/{projectId}/agents/{agentId}/scheduled-triggers/{id}/invocations/{invocationId}/rerun

This creates a new invocation using the same trigger configuration and executes it immediately.

Cancel an Invocation

Cancel a pending or running invocation:

POST /manage/tenants/{tenantId}/projects/{projectId}/agents/{agentId}/scheduled-triggers/{id}/invocations/{invocationId}/cancel
Note
Note

Completed and failed invocations cannot be cancelled.

View Upcoming Runs

See all pending and running invocations across all scheduled triggers for an agent:

GET /manage/tenants/{tenantId}/projects/{projectId}/agents/{agentId}/scheduled-triggers/upcoming-runs

Next Steps