> ## Documentation Index
> Fetch the complete documentation index at: https://docs.platform.toloka.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# root

> Define the Start and End field bindings of a pipeline.

```ts theme={null}
import type { AuthoredRootNode, AuthoringIdOptions, RootAuthoringSettings } from "@toloka-platform/sdk";

declare function root(
  settings: RootAuthoringSettings,
  options?: AuthoringIdOptions,
): AuthoredRootNode;
```

## Parameters

**settings** `RootAuthoringSettings` *required*

The pipeline boundary. Unlike work-node constructors, `root` has no name argument.

**Boundary settings**

**started** `readonly (Field | \{ field: Field; optional?: boolean \})[]` *required*

Fields entering the pipeline. A bare field is required; use [`optional(field)`](https://docs.platform.toloka.ai/docs/sdk/reference/field#optional-bindings) for an optional binding.

**completed** `readonly (Field | \{ field: Field; optional?: boolean \})[]` *required*

Fields at the End boundary, with the same binding syntax.

**itemLimit** `number`

Optional cap on items selected for a run. See [Start and End nodes](https://docs.platform.toloka.ai/docs/data/reference/nodes/start-and-end.md) for selection rules and limits.

**options** `AuthoringIdOptions` (default: \{})

Optional identity override.

**Options**

**id** `string` (default: root)

Graph node ID.

## Returns

**node** `AuthoredRootNode`

Add this node to the pipeline's `nodes` array.

**Node properties**

**id** `string`

The graph node ID.

**type** `'root'`

The node type.

**settings** `object`

Compiled Start and End bindings, without a dataset ID or item filter.

**started** `OutputPort`

Connect this to the first node's input.

**completed** `InputPort`

Connect the last node's output to this.

The exported `root` function also has `root.started` and `root.completed` ports targeting the default ID `"root"`. When overriding the ID, use the returned node's ports.

## Throws

Throws a local error when `settings` is not an object. Pass `root({ started, completed })`, without a name argument.

```ts theme={null}
import { field, optional, root } from "@toloka-platform/sdk";

const prompt = field("prompt", { type: "string" });
const context = field("context", { type: "string" });
const answer = field("answer", { type: "string" });

const boundary = root({
  started: [prompt, optional(context)],
  completed: [answer],
  itemLimit: 100,
});

console.log(boundary.started, boundary.completed);
```

The returned ports' data properties:

```json theme={null}
{
  "started": { "node": "root", "handle": "started", "direction": "output" },
  "completed": { "node": "root", "handle": "completed", "direction": "input" }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.