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

schedulestringRequired

A 5-field cron schedule, or a shortcut such as @daily. It cannot be empty. See Schedule format.

options.timeZonestring

An IANA time zone, such as Africa/Dar_es_Salaam. UTC when you leave it out.

options.signalAbortSignal

Cancels the call.

options.timeoutMsnumber

How long the call may take, in milliseconds. The timeoutMs set in createSpace when 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"
  ]
}
schedulestring

The schedule you sent.

timeZonestring

The 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

CodeWhen
validation_failedThe 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

preview.ts
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