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


# API reference

The JavaScript API of Planning Engine ships as one package, `plen-js`. It schedules, edits, levels and scores projects, and builds slots from skills for auto-assignment. Inputs and results are plain JS objects.

## How the API is organized

Almost every operation is a method of the [`Project`](<https://docs.dhtmlx.com/planning-engine/js/api/project.md>) class. The package also exports [`schedule`](<https://docs.dhtmlx.com/planning-engine/js/api/schedule.md>) for a one-shot solve, the [`InputError` and `ProjectError`](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>) classes, a default [`init`](<https://docs.dhtmlx.com/planning-engine/js/api/init.md>) export, and every data, option and result type. Nothing else is public.

- [`Project`](<https://docs.dhtmlx.com/planning-engine/js/api/project.md>) - creating a project, `clone`, `dispose`, and the list of operations.
- One page per operation (`api/project-*.md`) - parameters, behavior, result and errors of one call. Option and result shapes used by a single operation are documented on that operation's page.
- [Types](<https://docs.dhtmlx.com/planning-engine/js/api/types/overview.md>) - data, change, option and result shapes shared by several operations, plus [errors](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>) and [common types](<https://docs.dhtmlx.com/planning-engine/js/api/types/common.md>).

```bash
npm install plen-js
```

```js
import { Project, schedule, InputError, ProjectError } from "plen-js";
```

The package has ESM and CommonJS builds with bundled `.d.ts` files, and runs in Node 18 or later and in browsers. In CommonJS, the named exports are direct (`require("plen-js").Project`) and `init` is `.default`.

Every `Project` method and `schedule` is synchronous. Only `init` returns a `Promise`. Invalid input throws [`InputError`](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>), and a call that doesn't fit the project's state throws [`ProjectError`](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>). Cycles, conflicts and rejected edits come back as data in the result. See [Error handling](<https://docs.dhtmlx.com/planning-engine/js/error-handling.md>) for which failures throw and which don't.

:::note
`init()` isn't needed before `new Project()`; it loads nothing and resolves immediately.
:::

## Calls by task

| To | Call | Options | Returns |
|---|---|---|---|
| Schedule a snapshot once | [`schedule`](<https://docs.dhtmlx.com/planning-engine/js/api/schedule.md>) | [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/types/solve-options.md>) | [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/js/api/types/schedule-result.md>) |
| Keep code written for the WASM package working | [`init`](<https://docs.dhtmlx.com/planning-engine/js/api/init.md>) | - | `Promise<unknown>` |
| Load a live project or reschedule its edits | [`Project#solve`](<https://docs.dhtmlx.com/planning-engine/js/api/project-solve.md>) | [`SolveOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/types/solve-options.md>) | [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/js/api/types/schedule-result.md>) |
| See what an edit would do | [`Project#preview`](<https://docs.dhtmlx.com/planning-engine/js/api/project-preview.md>) | [`PreviewOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/project-preview.md#previewoptions>) | [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/js/api/types/schedule-result.md>) |
| Get critical path and slack without scheduling | [`Project#analyze`](<https://docs.dhtmlx.com/planning-engine/js/api/project-analyze.md>) | [`AnalyzeOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/project-analyze.md#analyzeoptions>) | [`ScheduleResult`](<https://docs.dhtmlx.com/planning-engine/js/api/types/schedule-result.md>) |
| Commit an edit | [`Project#apply`](<https://docs.dhtmlx.com/planning-engine/js/api/project-apply.md>) | [`SchedulingChanges`](<https://docs.dhtmlx.com/planning-engine/js/api/types/scheduling-changes.md>) | [`ApplyReport`](<https://docs.dhtmlx.com/planning-engine/js/api/project-apply.md#applyreport>) |
| Resolve resource overallocation | [`Project#level`](<https://docs.dhtmlx.com/planning-engine/js/api/project-level.md>) | [`LevelingOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/types/leveling-options.md>) | [`LevelingResult`](<https://docs.dhtmlx.com/planning-engine/js/api/project-level.md#levelingresult>) |
| Read resource load per hour or day | [`Project#loadProfile`](<https://docs.dhtmlx.com/planning-engine/js/api/project-load-profile.md>) | [`LoadProfileOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/project-load-profile.md#loadprofileoptions>) | [`LoadProfile`](<https://docs.dhtmlx.com/planning-engine/js/api/types/load-profile.md>) |
| Compare alternative edits | [`Project#evaluate`](<https://docs.dhtmlx.com/planning-engine/js/api/project-evaluate.md>) | [`EvaluateOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/project-evaluate.md#evaluateoptions>) | [`EvaluateResult`](<https://docs.dhtmlx.com/planning-engine/js/api/project-evaluate.md#evaluateresult>) |
| Pick resources for open positions | [`Project#suggestAssignments`](<https://docs.dhtmlx.com/planning-engine/js/api/project-suggest-assignments.md>) | [`SuggestOptions`](<https://docs.dhtmlx.com/planning-engine/js/api/project-suggest-assignments.md#suggestoptions>) | [`SuggestResult`](<https://docs.dhtmlx.com/planning-engine/js/api/project-suggest-assignments.md#suggestresult>) |
| Build slots from skills and requirements | [`Project#slots`](<https://docs.dhtmlx.com/planning-engine/js/api/project-slots.md>) | [`Pool`](<https://docs.dhtmlx.com/planning-engine/js/api/project-slots.md#pool>), [`Requirement`](<https://docs.dhtmlx.com/planning-engine/js/api/project-slots.md#requirement>) | [`Slot`](<https://docs.dhtmlx.com/planning-engine/js/api/types/slot.md>)`[]` |

`preview`, `loadProfile`, `evaluate`, `suggestAssignments` and `slots` need a solved project. Creating a project, `clone` and `dispose` are on the [`Project`](<https://docs.dhtmlx.com/planning-engine/js/api/project.md>) page.
