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 | ✅ | Cron expression (e.g., "0 0 * * *" for daily at midnight) |
| timezone | string | ✅ | 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 | ✅ | Unique job identifier |
| name | string | ✅ | Job name (snake_case) |
| schedule | Object | Object | Object | ✅ | Job schedule configuration |
| handler | string | ✅ | Handler path (e.g. "path/to/file:functionName") or script ID |
| retryPolicy | Object | optional | Retry policy configuration |
| timeout | integer | optional | Timeout in milliseconds |
| enabled | boolean | ✅ | 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 | ✅ | Cron expression (e.g., "0 0 * * *" for daily at midnight) |
| timezone | string | ✅ | 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 |