space.schedule.preview()
See the next 5 times a schedule runs, without creating a job.
Returns the next 5 times a schedule runs, without creating a job. Use it to check a schedule before you save it.
function preview(
schedule: string,
options?: CallOptions & { timeZone?: string }
): Promise<Preview>Parameters
schedulestringA 5-field cron schedule, or a shortcut such as
@daily. It cannot be empty. See Schedule format.options.timeZonestringAn IANA time zone, such as
Africa/Dar_es_Salaam. UTC when you leave it out.options.signalAbortSignalCancels the call.
options.timeoutMsnumberHow long the call may take, in milliseconds. The
timeoutMsset increateSpacewhen you leave it out, 30,000 by default.
Returns
A promise of the preview:
{
"schedule": "30 8 * * MON-FRI",
"timeZone": "Africa/Dar_es_Salaam",
"next": [
"2026-09-28T05:30:00Z",
"2026-09-29T05:30:00Z",
"2026-09-30T05:30:00Z",
"2026-10-01T05:30:00Z",
"2026-10-02T05:30:00Z"
]
}schedulestringThe schedule you sent.
timeZonestringThe time zone it runs in.
nextstring[]The next 5 times it runs, as ISO 8601 strings in UTC.
preview() needs an API key but no project. It is sent again, up to retries times, when it fails in a way that may pass, such as a network failure or 503.
Errors
| Code | When |
|---|---|
validation_failed | The schedule is empty, or the scheduler cannot read the schedule or time zone |
Every call can also fail with the codes shared by all of space, such as missing_api_key or network_error. See SpaceError.
Example
import { space } from "digitospace"
const preview = await space.schedule.preview("30 8 * * MON-FRI", {
timeZone: "Africa/Dar_es_Salaam",
})
for (const time of preview.next) {
console.log(new Date(time).toLocaleString("en-GB", { timeZone: "Africa/Dar_es_Salaam" }))
}Last updated