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


# LinkData

A dependency between two tasks: which end of the source task drives which end of the target task, and the working time between them. `LinkData` records go in the `links` array of [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>). Links added or edited on a live project use the `links` bucket of [`SchedulingChanges`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/scheduling-changes.md>) instead.

```ts
type LinkData = {
  id: Id;
  source: Id;
  target: Id;
  type?: "fs" | "ss" | "ff" | "sf" | 0 | 1 | 2 | 3 | "0" | "1" | "2" | "3";
  lag?: number | null;
  lag_unit?: TimeUnit | null;
};
```

## Fields

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `id` | [`Id`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#id>) | yes | | Link id, unique among the project's links. Results refer to the link by this id, for example in `dropped-link` notes, cycles and the critical path. |
| `source` | [`Id`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#id>) | yes | | Id of the predecessor task. |
| `target` | [`Id`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#id>) | yes | | Id of the successor task. |
| `type` | `string` \| `number`, see [link type](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#link-type>) | no | `"fs"` | Which end of `source` drives which end of `target`: `"fs"` (finish-to-start), `"ss"` (start-to-start), `"ff"` (finish-to-finish), `"sf"` (start-to-finish). Case-insensitive. The numbers `0`-`3` and the strings `"0"`-`"3"` are accepted in the same order. |
| `lag` | number \| `null` | no | `0` | Working time between the source end and the target end, in `lag_unit`. Fractions are allowed. A negative value lets the target overlap the source. `null` reads as `0`. |
| `lag_unit` | [`TimeUnit`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#timeunit>) \| `null` | no | `config.duration_unit` | Unit of `lag`: `"minute"`, `"hour"` or `"day"`. Omitted or `null` uses [`duration_unit`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/scheduling-config.md>) of the project config. |

The wire name of the link type is `type`. Unknown fields are ignored. Shared rules for ids, numbers and `null` are on [Wire format](<https://docs.dhtmlx.com/planning-engine/wasm/wire-format.md>).

A `source` or `target` that names no task, or an unscheduled task, doesn't fail the call. The scheduler drops the link and reports a `dropped-link` note. See [Links that get dropped](<https://docs.dhtmlx.com/planning-engine/wasm/scheduling/links-constraints-summaries.md#links-that-get-dropped>) for every case.

:::note
A link without `lag_unit` reads lag in `config.duration_unit`.
:::

## Validation

A link record fails the whole call with an error envelope when:

| Error | When |
|---|---|
| `validation`, path `links[i].id` | `id` repeats the id of an earlier link. With `validation: "repair"` in [`ProjectOptions`](<https://docs.dhtmlx.com/planning-engine/wasm/api/json-project.md#projectoptions>), the duplicate is removed instead (the last record wins) and reported as a `repaired` note. |
| `validation`, path `null` | `type` isn't a known link type, or `lag_unit` isn't a known unit. |
| `parse` | `id`, `source` or `target` is missing; `lag` isn't a number or `null` (for example, the string `"2"`); the record isn't a JSON object. |

## Used by

- [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>) `links`, passed to [`schedule`](<https://docs.dhtmlx.com/planning-engine/wasm/api/schedule.md>), [`JsonProject#solve`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-solve.md>) and [`JsonProject#analyze`](<https://docs.dhtmlx.com/planning-engine/wasm/api/project-analyze.md>)

## Example

Task `2` starts when task `1` finishes. Task `3` starts four working hours after task `2` starts, while the project counts durations in days:

```json
{
  "links": [
    { "id": "a", "source": 1, "target": 2 },
    { "id": "b", "source": 2, "target": 3, "type": "ss", "lag": 4, "lag_unit": "hour" }
  ]
}
```

## Related

- [`ProjectData`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/project-data.md>) - the `links` array
- [`LinkAdd`](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/scheduling-changes.md#linkadd>) - links added to a live project
- [Link type](<https://docs.dhtmlx.com/planning-engine/wasm/api/types/common.md#link-type>) - accepted `type` values
- [Links, constraints and summaries](<https://docs.dhtmlx.com/planning-engine/wasm/scheduling/links-constraints-summaries.md>) - how link types and lag place tasks
