Job
Job protocol schemas
Cron Schedule Schema
Schedule jobs using cron expressions
Source: packages/spec/src/system/job.zod.ts
import { CronSchedule, IntervalSchedule, Job, JobExecution, JobExecutionStatus, OnceSchedule, RetryPolicy, Schedule } from '@objectstack/spec/system';
import type { CronSchedule, IntervalSchedule, Job, JobExecution, JobExecutionStatus, OnceSchedule, RetryPolicy, Schedule } from '@objectstack/spec/system';
// Validate data
const result = CronSchedule.parse(data);
| Property | Type | Required | Description |
|---|
| type | string | ✅ | |
| expression | string | Object | ✅ | Cron expression — cron0 0 * * * for daily at midnight. Build emits {dialect:"cron",source} envelope. |
| timezone | string | optional | Timezone for cron execution (e.g., "America/New_York") |
| Property | Type | Required | Description |
|---|
| type | string | ✅ | |
| intervalMs | integer | ✅ | Interval in milliseconds |
| Property | Type | Required | Description |
|---|
| id | string | optional | Unique job identifier (defaults to name when omitted) |
| name | string | ✅ | Job name (snake_case) |
| label | string | optional | Human-readable label |
| description | string | optional | Job description / purpose |
| schedule | Object | Object | Object | ✅ | Job schedule configuration |
| handler | string | ✅ | Handler function name (must match a key in defineStack({ functions })) |
| retryPolicy | Object | optional | Retry policy configuration |
| timeout | integer | optional | Timeout in milliseconds |
| enabled | boolean | optional | Whether the job is enabled |
| Property | Type | Required | Description |
|---|
| jobId | string | ✅ | Job identifier |
| startedAt | string | ✅ | ISO 8601 datetime when execution started |
| completedAt | string | optional | ISO 8601 datetime when execution completed |
| status | Enum<'running' | 'success' | 'failed' | 'timeout'> | ✅ | Execution status |
| error | string | optional | Error message if failed |
| duration | integer | optional | Execution duration in milliseconds |
running
success
failed
timeout
| Property | Type | Required | Description |
|---|
| type | string | ✅ | |
| at | string | ✅ | ISO 8601 datetime when to execute |
| Property | Type | Required | Description |
|---|
| maxRetries | integer | ✅ | Maximum number of retry attempts |
| backoffMs | integer | ✅ | Initial backoff delay in milliseconds |
| backoffMultiplier | number | ✅ | Multiplier for exponential backoff |
This schema accepts one of the following structures:
Type: cron
| Property | Type | Required | Description |
|---|
| type | string | ✅ | |
| expression | string | Object | ✅ | Cron expression — cron0 0 * * * for daily at midnight. Build emits {dialect:"cron",source} envelope. |
| timezone | string | optional | Timezone for cron execution (e.g., "America/New_York") |
Type: interval
| Property | Type | Required | Description |
|---|
| type | string | ✅ | |
| intervalMs | integer | ✅ | Interval in milliseconds |
Type: once
| Property | Type | Required | Description |
|---|
| type | string | ✅ | |
| at | string | ✅ | ISO 8601 datetime when to execute |