Schedule
The $schedule module lets you create, get, update, pause, resume, and delete scheduled jobs.
Schedule types: ONE_TIME (run once at a time), CRON (cron expression), RECURRING (fixed interval).
Import / Usage
const { AppnestFunctions } = require('appnest-app-sdk-utils');
const { $schedule } = AppnestFunctions;
// or from path:
// const AppnestFunctions = require('<path-to-sdk>/appnestFunctions');
// const { $schedule } = AppnestFunctions;
Common Fields
| Field | Type | Required | Constraints |
|---|---|---|---|
| name | string | yes | Non-empty, max 30 characters. |
| type | string | yes | ONE_TIME | CRON | RECURRING |
| data | object | yes (create/update) | At least one key; payload delivered to the scheduled handler. |
Type-specific (create / update)
ONE_TIME
| Field | Type | Required | Description |
|---|---|---|---|
| runAt | string | yes | Date-time string (e.g. ISO 8601: YYYY-MM-DDTHH:mm:ssZ). |
Do not pass cronExpression or repeat for ONE_TIME.
CRON
| Field | Type | Required | Description |
|---|---|---|---|
| cronExpression | string | yes | Valid cron expression (e.g. 0 * * * * for hourly). |
Do not pass runAt or repeat for CRON.
RECURRING
| Field | Type | Required | Description |
|---|---|---|---|
| repeat | object | yes | { frequency: number, timeUnit: string } |
| repeat field | Type | Required | Constraints |
|---|---|---|---|
| frequency | number | yes | Integer >= 1; if timeUnit is MINUTES, >= 10. |
| timeUnit | string | yes | MINUTES | HOURS | DAYS | WEEKS | MONTHS | YEARS |
Do not pass runAt or cronExpression for RECURRING.
API
| Method | Signature | Description |
|---|---|---|
| create | $schedule.create({ name, type, data, runAt | cronExpression | repeat }) | Create a schedule. Returns nothing. |
| get | $schedule.get({ name, type }) | Get schedule by name and type. Returns nothing. |
| update | $schedule.update({ name, type, data, runAt | cronExpression | repeat }) | Update existing schedule. Returns nothing. |
| pause | $schedule.pause({ name, type }) | Pause a schedule. Returns nothing. |
| resume | $schedule.resume({ name, type }) | Resume a paused schedule. Returns nothing. |
| delete | $schedule.delete({ name, type }) | Delete a schedule. Returns nothing. |
Return: All schedule methods return Promise<void> (no response body). They resolve when the operation completes.
Examples
ONE_TIME:
await $schedule.create({
name: 'dailyReportOnce',
type: 'ONE_TIME',
runAt: '2026-02-05T10:00:00Z',
data: { reportType: 'daily' }
});
CRON:
await $schedule.create({
name: 'hourlyReport',
type: 'CRON',
cronExpression: '0 * * * *',
data: { reportType: 'hourly' }
});
RECURRING:
await $schedule.create({
name: 'everyTwoHours',
type: 'RECURRING',
repeat: { frequency: 2, timeUnit: 'HOURS' },
data: { task: 'sync' }
});
Get: (returns nothing; use to ensure the schedule exists or to trigger a side effect)
await $schedule.get({ name: 'hourlyReport', type: 'CRON' });
Update:
await $schedule.update({
name: 'hourlyReport',
type: 'CRON',
cronExpression: '0 */2 * * *',
data: { reportType: 'hourly' }
});
Pause / Resume:
await $schedule.pause({ name: 'hourlyReport', type: 'CRON' });
await $schedule.resume({ name: 'hourlyReport', type: 'CRON' });
Delete:
await $schedule.delete({ name: 'hourlyReport', type: 'CRON' });