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


# JsonProject.loadProfile

Reads per-bucket load and capacity of resources on the solved baseline of a [`JsonProject`](<https://docs.dhtmlx.com/planning-engine/wasm/api/json-project.md>). The project isn't modified. Needs a solved project with no edits applied since the last [`solve`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-solve.md>) or [`level`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-level.md>). For the load of hypothetical dates, use [`preview`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-preview.md>) with a `profile` query instead.

## Signature

```ts
loadProfile(options_json: string): string
```

Synchronous and read-only. Bad input comes back as an error envelope. The call doesn't throw.

## Request

| Argument | Payload | Required | Description |
|---|---|---|---|
| `options_json` | [`LoadProfileOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-load-profile.md#loadprofileoptions>) | yes | Range, resources, bucket size, task lists and an optional baseline check |

### LoadProfileOptions

The options object for `loadProfile`. All fields sit at the top level. `from` and `to` are required, every other field can be omitted. Unknown fields are rejected with a `parse` error.

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `from` | [`DateValue`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#datevalue>) | yes | - | Start of the range. A bucket is included when its start is at or after `from` |
| `to` | [`DateValue`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#datevalue>) | yes | - | End of the range, exclusive. Must be after `from` |
| `resources` | [`Id`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#id>)`[]` | no | all resources, in input order | Resource ids to measure, in the order given |
| `basis` | `"hour"` \| `"day"` | no | derived from `config.duration_unit` | Bucket size: `"hour"` or `"day"` |
| `tasks` | string | no | `"none"` | Task ids per bucket: `"none"` (no `tasks` field), `"overallocated"` (ids only in buckets with `load > capacity`, `[]` elsewhere) or `"all"` (every booked task) |
| `baselineId` | string | no | absent (not checked) | Must name the current baseline, or the call fails with `stale-baseline` |

`null` on any optional field reads as its default. Dates follow the [wire format](<https://docs.dhtmlx.com/planning-engine/wasm/wire-format.md#dates>).

`preview` takes the same fields as its `profile` query, a [`ProfileQuery`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#profilequery>), except `baselineId`.

## Response

The success envelope carries a [`LoadProfile`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/load-profile.md>): the `basis` used and one entry per resource with its buckets. Envelope shape: [Wire format](<https://docs.dhtmlx.com/planning-engine/wasm/wire-format.md#envelope>).

## Errors

| Kind | Code | When |
|---|---|---|
| `project` | `no-baseline` | The project has never been solved, or `apply` ran since the last solve |
| `project` | `stale-baseline` | `baselineId` doesn't name the current baseline |
| `validation` | `null` | `to` isn't after `from`, or the range has more than 100 000 buckets per resource (path `to`); an unknown resource id (path `resources`); a `tasks` or `basis` value outside its list, or an invalid date (path `null`) |
| `parse` | `null` | Malformed JSON, a missing `from` or `to`, or an unknown field |

## Example

Print the overloaded days of a resource that works on two tasks at once, with the tasks that fill them.

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

const data = {
  config: { use_calendars: false },
  tasks: [
    { id: "a", start_date: "2026-01-01", duration: 2 },
    { id: "b", start_date: "2026-01-02", duration: 2 },
  ],
  resources: [{ id: "dev" }],
  assignments: [
    { task: "a", resource: "dev", value: 1 },
    { task: "b", resource: "dev", value: 1 },
  ],
};

const project = new JsonProject("{}");
try {
  const solved = JSON.parse(project.solve(JSON.stringify(data), "{}")).result;

  const options = {
    baselineId: solved.baselineId,
    from: "2026-01-01",
    to: "2026-01-05",
    tasks: "overallocated",
  };
  const response = JSON.parse(project.loadProfile(JSON.stringify(options)));

  if (response.ok) {
    for (const { resource, buckets } of response.result.resources) {
      for (const bucket of buckets.filter((b) => b.load > b.capacity)) {
        console.log(`${resource} at ${bucket.start}: ${bucket.load} of ${bucket.capacity}`, bucket.tasks);
      }
    }
    // dev at 2026-01-02 00:00: 2 of 1 [ 'a', 'b' ]
  } else {
    const { kind, code, message, path } = response.error;
    console.error(kind, code, message, path);
  }
} finally {
  project.free();
}
```

`options_json` (the token comes from the `solve` result):

```json
{ "baselineId": "1-b0605af8cba3d7c9", "from": "2026-01-01", "to": "2026-01-05", "tasks": "overallocated" }
```

Response:

```json
{
  "ok": true,
  "result": {
    "basis": "day",
    "resources": [
      {
        "buckets": [
          { "capacity": 1, "load": 1, "start": "2026-01-01 00:00", "tasks": [] },
          { "capacity": 1, "load": 2, "start": "2026-01-02 00:00", "tasks": ["a", "b"] },
          { "capacity": 1, "load": 1, "start": "2026-01-03 00:00", "tasks": [] },
          { "capacity": 1, "load": 0, "start": "2026-01-04 00:00", "tasks": [] }
        ],
        "capacityMode": "flat",
        "resource": "dev"
      }
    ]
  }
}
```

## Related

- [`LoadProfile`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/load-profile.md>) - the result payload
- [`ProfileQuery`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#profilequery>) - the same query as the `profile` option of `preview`
- [`JsonProject.preview`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-preview.md>) - the load of hypothetical dates
- [`Overallocation`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/overallocation.md>) - overload windows in scheduling results
- [Resource Load](<https://docs.dhtmlx.com/planning-engine/wasm/resources-and-assignment/resource-load.md>) - capacity modes and how load is counted
