[Canonical page](<https://docs.dhtmlx.com/planning-engine/js/api/schedule/>)
[Full documentation index](<https://docs.dhtmlx.com/planning-engine/llms.txt>)


# schedule

Schedules a [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/js/api/types/project-data.md>) snapshot once and returns the result. The call is stateless: it creates a temporary [`Project`](<https://docs.dhtmlx.com/planning-engine/js/api/project.md>) with default options, calls [`solve`](<https://docs.dhtmlx.com/planning-engine/js/api/project-solve.md>) on it, and disposes it. Nothing is kept between calls. To keep the baseline for later previews or edits, use [`Project#solve`](<https://docs.dhtmlx.com/planning-engine/js/api/project-solve.md>).

## Signature

```ts
function schedule(data: ProjectData, options?: SolveOptions): ScheduleResult
```

Synchronous. Runs on the calling thread. The same `data` and `options` always produce the same dates.

## Parameters

| Name | Type | Description |
|---|---|---|
| `data` | [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/js/api/types/project-data.md>) | The full snapshot to schedule. Never mutated. |
| `options` | [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/types/solve-options.md>) | Optional. What to schedule and what to report. Default `{}`: the whole project. |

`data` is always validated in `"strict"` mode. For `"repair"` mode, create a `Project` with `validation: "repair"` and call `solve` on it.

## Returns

A [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/js/api/types/schedule-result.md>), a fresh object that shares nothing with `data`.

`baselineId` is set, but it names the baseline of the temporary project, so no later call can use it.

:::note
`schedule()` always returns dates as `"YYYY-MM-DD HH:MM"` strings. To get local `Date` objects, create a `Project` with `dates: "date"` and call `solve` on it.
:::

## Errors

| Error | When |
|---|---|
| [`InputError`](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>) | `data` or `options` fails parsing or strict validation; `kind`, `message` and `path` name the field. Also thrown for a non-finite number or an invalid `Date` in the input. |
| `TypeError` | The input has a circular reference or a `BigInt`. |

`schedule` never throws [`ProjectError`](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>): each call starts from a fresh project.

## Example

```js
import { schedule } from "plen-js";

const result = schedule({
  tasks: [
    { id: "design", start_date: "2026-01-05 08:00", duration: 2 },
    { id: "build", start_date: "2026-01-05 08:00", duration: 3 },
  ],
  links: [{ id: "l1", source: "design", target: "build", type: "fs" }],
});

for (const update of result.updates) {
  if (update.start_date && update.end_date) {
    console.log(`${update.id}: ${update.start_date} - ${update.end_date}`);
  }
}
```

## Related

- [`Project#solve`](<https://docs.dhtmlx.com/planning-engine/js/api/project-solve.md>) - the stateful call that keeps the baseline
- [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/js/api/types/project-data.md>) - the input snapshot
- [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/types/solve-options.md>) - the options
- [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/js/api/types/schedule-result.md>) - the returned result
- [Scheduling a Project](<https://docs.dhtmlx.com/planning-engine/js/scheduling/scheduling-a-project.md>) - one-shot scheduling vs a live project
