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


# API reference

The `plen-wasm` package builds Planning Engine into a WebAssembly module. This reference covers its raw exports: every call takes JSON text and returns JSON text. For the `Project` class with typed errors, see [JavaScript usage](<https://docs.dhtmlx.com/planning-engine/wasm/javascript.md>).

## How the API is organized

The module has two exports that do work:

- [`schedule`](<https://docs.dhtmlx.com/planning-engine/wasm/api/schedule.md>) - a function that schedules one snapshot and keeps nothing.
- [`JsonProject`](<https://docs.dhtmlx.com/planning-engine/wasm/api/json-project.md>) - a handle to a project held in wasm memory. It's created with `new JsonProject(options_json)`, copied with `clone()` and released with `free()`. Each method has its own page, listed below.

[`init`](<https://docs.dhtmlx.com/planning-engine/wasm/api/init.md>) loads the module in the browser build. Payload types shared by several calls are under [Types](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/overview.md>).

The package's `exports` map points only to the JS glue, so the raw bindings are loaded by path:

```js
// Browser / ES module host
import init, { JsonProject, schedule } from "./pkg/plen_wasm.js";

await init();
```

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

Build targets and loading options are in [Module and handles](<https://docs.dhtmlx.com/planning-engine/wasm/module-and-handles.md>).

Only module loading is asynchronous: `init()` returns a promise. Every export is synchronous and runs on the calling thread. Each method returns an envelope string, `{"ok": true, "result": ...}` or `{"ok": false, "error": ...}`, and doesn't throw on bad input. The `JsonProject` constructor is the exception: it throws the error envelope as a string. Envelope rules are in [Wire format](<https://docs.dhtmlx.com/planning-engine/wasm/wire-format.md>), error kinds and codes in [Error handling](<https://docs.dhtmlx.com/planning-engine/wasm/error-handling.md>).

## Calls by task

| To | Call | Request | Response |
|---|---|---|---|
| Schedule a snapshot once | [`schedule`](<https://docs.dhtmlx.com/planning-engine/wasm/api/schedule.md>) | [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>), [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/solve-options.md>) | [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/schedule-result.md>) |
| Load a live project or reschedule its edits | [`JsonProject#solve`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-solve.md>) | [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>) (optional), [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/solve-options.md>) | [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/schedule-result.md>) |
| See what an edit would do | [`JsonProject#preview`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-preview.md>) | [`SchedulingChanges`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/scheduling-changes.md>), [`PreviewOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-preview.md#previewoptions>) | [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/schedule-result.md>) |
| Get critical path and slack without scheduling | [`JsonProject#analyze`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-analyze.md>) | [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>) (optional), [`AnalyzeOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-analyze.md#analyzeoptions>) | [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/schedule-result.md>) |
| Commit an edit | [`JsonProject#apply`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-apply.md>) | [`SchedulingChanges`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/scheduling-changes.md>) | [`ApplyReport`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-apply.md#applyreport>) |
| Resolve resource overallocation | [`JsonProject#level`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-level.md>) | [`LevelingOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/leveling-options.md>) | [`LevelingResult`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-level.md#levelingresult>) |
| Read resource load over a date range | [`JsonProject#loadProfile`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-load-profile.md>) | [`LoadProfileOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-load-profile.md#loadprofileoptions>) | [`LoadProfile`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/load-profile.md>) |
| Compare alternative edits | [`JsonProject#evaluate`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-evaluate.md>) | [`Candidate`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-evaluate.md#candidate>)`[]`, [`EvaluateOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-evaluate.md#evaluateoptions>) | [`EvaluateResult`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-evaluate.md#evaluateresult>) |
| Pick resources for open positions | [`JsonProject#suggestAssignments`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-suggest-assignments.md>) | [`Slot`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/slot.md>)`[]`, [`SuggestOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-suggest-assignments.md#suggestoptions>) | [`SuggestResult`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-suggest-assignments.md#suggestresult>) |
| Build slots from skills and requirements | [`JsonProject#slots`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-slots.md>) | [`Pool`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-slots.md#pool>), [`Requirement`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-slots.md#requirement>)`[]` | [`Slot`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/slot.md>)`[]` |

`preview`, `loadProfile`, `evaluate`, `suggestAssignments` and `slots` need a solved project. `apply` leaves the project unsolved, so call `solve` again after it. Constructor, `clone` and `free` are on the [`JsonProject`](<https://docs.dhtmlx.com/planning-engine/wasm/api/json-project.md>) page.
