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


# schedule

Schedules a [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>) snapshot once and returns the result envelope. The call is stateless: it creates a temporary project with strict validation, solves the data once and drops the project before returning. Nothing is kept between calls, and there's no handle to free. To keep a baseline and send edits later, use [`JsonProject.solve`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-solve.md>).

## Signature

```ts
schedule(data_json: string, options_json: string): string
```

Synchronous and CPU-bound. The same `data_json` and `options_json` always produce the same result. In the browser build, call it only after [`init()`](<https://docs.dhtmlx.com/planning-engine/wasm/api/init.md>) has resolved.

## Request

| Argument | Payload | Required | Description |
|---|---|---|---|
| `data_json` | [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>) | yes | The full snapshot to schedule. Always validated in strict mode; the rules are listed on [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>). |
| `options_json` | [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/solve-options.md>) | yes | What to schedule and what to report. `"{}"` schedules the whole project with default options. |

## Response

The success envelope carries a [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/schedule-result.md>). The envelope shape is described in [Wire format](<https://docs.dhtmlx.com/planning-engine/wasm/wire-format.md#envelope>).

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

## Errors

| Error | When |
|---|---|
| `kind: "parse"` | `data_json` or `options_json` isn't valid JSON, has the wrong JSON type, misses a required field, or `options_json` has an unknown field. |
| `kind: "validation"` | A value the decoder rejects (`path: null`), or `data_json` fails strict validation (`path` names the field, e.g. `tasks[0].start_date`). |

`schedule` never returns `kind: "project"`: each call starts from a fresh project. Errors come back in the returned envelope; the call doesn't throw for bad input. See [Error handling](<https://docs.dhtmlx.com/planning-engine/wasm/error-handling.md>) for the error fields and for host-level failures such as calling before `init()` resolves.

## Example

Request (`data_json`):

```json
{
  "tasks": [
    { "id": "design", "start_date": "2026-01-05", "duration": 2 },
    { "id": "build", "start_date": "2026-01-05", "duration": 3 }
  ],
  "links": [{ "id": "l1", "source": "design", "target": "build", "type": "fs" }]
}
```

Options (`options_json`): `{}`

Response:

```json
{
  "ok": true,
  "result": {
    "baselineId": "1-1527fed5c4d6197a",
    "conflicts": [],
    "converged": true,
    "cycles": [],
    "notes": [],
    "updates": [
      { "end_date": "2026-01-10 00:00", "id": "build", "kind": "task", "start_date": "2026-01-07 00:00" }
    ]
  }
}
```

Only `build` moved, so it's the only entry in `updates`. Pass `{"includeUnchanged": true}` as `options_json` to list every scheduled task.

Host call in Node:

```js
const { schedule } = require("./pkg-node/plen_wasm.js");

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

const envelope = JSON.parse(schedule(JSON.stringify(data), "{}"));

if (envelope.ok) {
  for (const update of envelope.result.updates) {
    console.log(update.id, update.start_date, update.end_date);
  }
} else {
  const { kind, message, path } = envelope.error;
  console.error(kind, message, path);
}
```

## Related

- [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>) - the snapshot to schedule
- [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/solve-options.md>) - scope and reporting options
- [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/schedule-result.md>) - the result payload
- [`JsonProject.solve`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-solve.md>) - the stateful counterpart that keeps a baseline
- [Scheduling a Project](<https://docs.dhtmlx.com/planning-engine/wasm/scheduling/scheduling-a-project.md>) - one-shot and live scheduling
