Scheduled Triggers in TypeScript SDK
Copy page
Define scheduled triggers in the TypeScript SDK to run agents on a cron schedule or one-time execution
Scheduled triggers run agents on a time-based schedule using cron expressions or at a one-time future timestamp. See Scheduled Triggers for a full conceptual overview.
Creating Scheduled Triggers
Use the scheduledTrigger() factory function to create both recurring and one-time scheduled triggers. The schema validation enforces that you specify either cronExpression or runAt, but not both.
Configuration Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | Yes | — | Human-readable name |
description | string | No | — | Description of the trigger's purpose |
enabled | boolean | No | true | Whether the trigger is active |
cronExpression | string | One of cron/runAt | — | 5-field cron expression (minute hour day month weekday) |
cronTimezone | string | No | UTC | IANA timezone for cron evaluation |
runAt | string | One of cron/runAt | — | ISO 8601 timestamp for one-time execution |
messageTemplate | string | No | — | Template with {{placeholder}} syntax |
payload | object | No | — | Static JSON payload passed to the agent |
maxRetries | number | No | 1 | Max retry attempts on failure (0–10) |
retryDelaySeconds | number | No | 60 | Seconds between retries (10–3600) |
timeoutSeconds | number | No | 780 | Execution timeout in seconds (30–780) |
runAsUserId | string | No | — | User ID whose identity and credentials are used during execution |
createdBy | string | — | — | Read-only. User ID of the trigger creator, set automatically on creation. |
You must specify either cronExpression or runAt, but not both. The system validates this at creation time.
Overriding Configuration with .with()
Use the .with() method to create a variant of an existing scheduled trigger:
User-Scoped Execution
Set runAsUserId to execute the trigger with a specific user's identity, enabling access to their connected credentials (e.g., per-user OAuth tokens for GitHub, Slack, or Jira):
See User-Scoped Execution for details on permissions, admin delegation, and runtime behavior.
Complete Example
Scheduled triggers are managed separately from webhook triggers via dedicated API endpoints. They are scoped to an agent and can be created, updated, enabled/disabled, and deleted through the API or Manage UI.
Best Practices
- Set appropriate timeouts - Ensure
timeoutSecondsis long enough for the agent to complete - Configure retries for critical tasks - Use
maxRetriesfor important scheduled jobs - Monitor invocations - Check the invocation history for failed runs
- Use one-time triggers for deferred work - Prefer
runAtover cron for tasks that should execute exactly once