---
related_nodes: ["library_get", "library_list", "library_tools", "read_media", "upload_media", "telegram_download", "ai"]
---

# Library

Creates, retrieves, updates, and deletes Library documents from workflows, files images, and creates folders.

## Operations

Configure `operation.op`:

- `create_text` — create a block document from Markdown text or a block tree.
- `upload_image` — file an image from workflow binary data or an existing media object.
- `create_folder` — create a folder under an existing parent, or return the folder already there.
- `get` — retrieve a Library item by slug or ULID.
- `update` — replace a document's body, rename an item, or both.
- `delete` — move an item to the trash by slug or ULID.

```json
{ "library": { "operation": { "op": "get", "format": "json_block" } } }
```

## Inputs

All operations use the canonical `input` socket.

Folders are not created on the way. Use an existing folder or run **Create Folder** before filing an item.

### create_text

```json
{
  "name": "Weekly Briefing",
  "content": "# Summary\n\nMarkdown is converted to blocks.",
  "path": ["reports-folder-slug"],
  "agent_visible": false
}
```

`operation.format` says what `content` is: `markdown` (default) is parsed into blocks; `json_block` takes the block tree verbatim, which is lossless. `operation.agent_visible` is the default when the input omits `agent_visible`.

`path` is required: folder slugs or ids, `[]` for the root. A folder that does not exist fails the node.

### upload_image

Pass an object with `binary` or `body` containing binary data, or with an `object_id` from Upload Media, Read Media, a media API, or an object descriptor. The object can also carry `name`.

`path` is required: folder slugs or ids, `[]` for the root. A folder that does not exist fails the node.

Example from a Telegram image:

```text
Telegram Message Trigger → Telegram Download → JavaScript (build an object with the image and path) → Library (Upload Image Document)
```

The node creates a Library file item (`kind: "file"`) whose `object_id` is the stored image, not just an anonymous workflow media object. The object is re-owned to the item, and file items are never agent-visible. An object a Library item already owns returns that item instead of a new one.

### create_folder

Pass `path`, the existing parent's folder slugs or ids from the Library root (`[]` for the root), and `name`, the new folder's name. If the parent already contains a folder with that exact name, the node returns it.

Run **Create Folder** before filing items into a folder per channel or month. The folder's output `path` is its parent path; append the returned `slug` to it to file inside the folder.

### get

Input may be a slug/ULID string or `{ "document_id": "..." }`. Any active item can be read: filed or unfiled, a document, a folder, or a file.

`operation.format` is `markdown` (default) for content plus metadata, or `json_block` to also include the structured `blocks`.

### update

```json
{
  "document_id": "weekly-briefing-a1b2c3",
  "content": "# Summary\n\nThe new body, as Markdown.",
  "name": "Weekly Briefing (revised)"
}
```

`document_id` takes a slug or ULID. Give `content`, `name`, or both; an input with neither fails.

- `content` replaces the whole body. It is Markdown, converted to blocks as in `create_text`.
- `name` renames the item and gives it a new slug. The old slug keeps resolving to it.

Folders and files can be renamed but have no body to replace: `content` on one fails the
node before anything is written. A document locked against AI writes (its AI access setting) fails
the node too, because a workflow can be built and run by an agent.

### delete

Input may be a slug/ULID string or `{ "document_id": "..." }`, the same shapes `get` accepts.

Deleting a folder deletes everything inside it. This is the soft delete the Library UI performs,
so the item moves to the trash rather than being destroyed, and one deletion is one restorable
batch.

## Output

The node emits one `output` object.

Create Text Document, Upload Image Document, Create Folder, and Update Document return item metadata:

```json
{
  "id": "01J...",
  "document_id": "01J...",
  "slug": "weekly-briefing-a1b2c3",
  "name": "Weekly Briefing",
  "path": ["reports-folder-slug"],
  "kind": "document",
  "object_id": null
}
```

- `path` is the folder slugs outermost first; `[]` is the root and `null` is an unfiled item (the Library's Other folder).
- `kind` is `document`, `folder`, or `file`.
- `object_id` is a file's stored object, `null` otherwise. `upload_image` also includes the `media` object descriptor.
- `already_there` is present only for `create_folder`: `true` when the folder already existed and `false` when the node created it.

Update returns this metadata after the change: the new `name` and `slug` when renamed. It does not return the content.

Get returns `id`, `slug`, `name`, `path`, `kind`, `object_id`, and `content` (Markdown; `null` for a folder or file). With `format: "json_block"` it also includes `blocks` (`null` for a folder or file). A file adds its `media` descriptor.

Delete returns `{ "id", "document_id", "deleted": true }`. An item that cannot be resolved fails the node rather than reporting a delete that did not happen.

For image files, connect `Library(get)` to `Read Media`. The output includes `object_id` so Read Media can load bytes for AI image/file sockets.

## Limits

Reading has **no character limit**. `get` returns the whole document however long it is, with no truncation and no ceiling of its own.

Writing is bounded by the 5 MB document size limit. A `create_text`, `upload_image`, or `update` above it fails.

When the workspace embeds documents (Settings → Models → Document Embeddings), `create_text` and `update` embed the content before writing it. If the selected model cannot embed it, the node fails and nothing is written.

A `get` output above the workflow offload threshold is written to an execution artifact and read back by the next node with no node-visible difference — the content arrives as the same string. Above the execution-history inline ceiling, history records a placeholder instead of the content.
