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


# Slot

A plain object for one requirement instance on one task: the resources eligible for it and, when filled, the assignment that fills it. [`Project#slots`](<https://docs.dhtmlx.com/planning-engine/js/api/project-slots.md>) builds slots from a worker pool and task requirements. You can also write them as object literals. [`Project#suggestAssignments`](<https://docs.dhtmlx.com/planning-engine/js/api/project-suggest-assignments.md>) takes them as input.

## Fields

| Field | Type | Default | Description |
|---|---|---|---|
| `id` | [`Id`](<https://docs.dhtmlx.com/planning-engine/js/api/types/common.md#id>) | required | Unique among the slots of a call. An assignment created for the slot gets this id, so the slot finds it again on the next run. Must not equal the id of an existing assignment, active or inactive, other than the slot's own `assignment`. |
| `task` | [`Id`](<https://docs.dhtmlx.com/planning-engine/js/api/types/common.md#id>) | required | The task the slot belongs to. Must be a scheduled leaf task: not unknown, unscheduled or a summary. |
| `allowed` | [`Id`](<https://docs.dhtmlx.com/planning-engine/js/api/types/common.md#id>)`[]` | required | Eligible resources. The order is the preference between candidates of equal cost. Each entry must name a resource of the project. |
| `value` | `number` | `1` | Rate of the assignment created when the slot is filled, in resource capacity units: `1` = 100 %. Must be finite and greater than 0. `null` reads as the default. |
| `assignment` | [`Id`](<https://docs.dhtmlx.com/planning-engine/js/api/types/common.md#id>) | absent | The active assignment that fills the slot. Absent or `null` for an empty slot. Must name an active assignment on the slot's `task`, and no other slot may name the same assignment. |

A slot's state comes from its assignment's resource: **empty** with no `assignment`, **broken** when the resource isn't in `allowed`, **valid** when it is. [`SuggestOptions.targets`](<https://docs.dhtmlx.com/planning-engine/js/api/project-suggest-assignments.md#suggestoptions>) picks which states to act on.

An invalid value throws an [`InputError`](<https://docs.dhtmlx.com/planning-engine/js/api/types/errors.md>) with `kind: "validation"` and a path under `slots[i]`: `.id`, `.task`, `.allowed[j]`, `.value` or `.assignment`. An unknown key throws an `InputError` with `kind: "parse"`.

Slots returned by `Project#slots` always carry `value`, and carry `assignment` only when they're filled.

## Used by

- [`Project#slots`](<https://docs.dhtmlx.com/planning-engine/js/api/project-slots.md>): returns `Slot[]`
- [`Project#suggestAssignments`](<https://docs.dhtmlx.com/planning-engine/js/api/project-suggest-assignments.md>): takes `Slot[]` and reports slot ids in `steps`, `unfilled` and `invalid`

## Example

```js
const slots = [
  // Empty slot: ann or bob, ann preferred on equal cost.
  { id: "be#1", task: "B", allowed: ["ann", "bob"] },
  // Filled slot at half rate, bound to assignment "be#2".
  { id: "be#2", task: "B", allowed: ["ann", "bob"], value: 0.5, assignment: "be#2" },
];
```

## Related

- [`Project#slots`](<https://docs.dhtmlx.com/planning-engine/js/api/project-slots.md>) - building slots from skills and requirements
- [`Project#suggestAssignments`](<https://docs.dhtmlx.com/planning-engine/js/api/project-suggest-assignments.md>) - filling and rebalancing slots
- [`AssignmentData`](<https://docs.dhtmlx.com/planning-engine/js/api/types/assignment-data.md>) - the assignment that fills a slot
- [Suggesting assignments](<https://docs.dhtmlx.com/planning-engine/js/resources-and-assignment/suggesting-assignments.md>) - slot categories and how picks are made
- [Skills and Requirements](<https://docs.dhtmlx.com/planning-engine/js/resources-and-assignment/skills-and-requirements.md>) - slots from workers' skills
