Append Document Blocks
library_blocks_append · Tools · Documents
Insert blocks into a Library document after a block id, or at the end
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
after_block_id | string | No | A block's `id`, as library_get returns it: 10 letters and digits. A blockquote's child blocks have ids too. The blocks go right after it; omit to add them at the end. |
blocks | object[] | Yes | The blocks to insert, in order. |
identifier | string | Yes | The item's id (ULID) or slug, as library_list, library_search and library_get return them. |
Append Document Blocks Tool#
library_blocks_append inserts blocks into a Library document: right after a block, or at the end.
When to Use#
The agent uses it to add content to an existing document without rewriting it. Block ids come from library_get.
Parameters#
| Parameter | Type | Required | Description |
|---|---|---|---|
identifier |
string | Yes | The item's id (ULID) or slug, as library_list, library_search and library_get return them |
blocks |
array | Yes | The blocks to insert, in order; at least one |
after_block_id |
string | No | A block's id (10 letters and digits). The blocks go right after it, inside its blockquote when it is a blockquote child; omit to add them at the end |
A block is BlockNode JSON: an object whose type names the block, with an optional id (10 letters and digits). A block keeps the id it states when the document holds no block with it, blockquote children included; a missing, malformed or taken id is replaced by a fresh one. The result returns the ids stored.
load_skill("library-documents") gives every block type with its fields, and get_docs("documents") says what a document can contain, including pages drawn from HTML or SVG. The agent reads get_docs("documents") before writing to a document the first time. A malformed block is refused with a message naming what is wrong.
Returns#
| Field | Type | Description |
|---|---|---|
item |
object | The item: id, slug, name, kind (document, folder or file), path (folder slugs; null when unfiled), path_names, icon, color, ai_access_policy, revision, created_at, updated_at, url; a file adds object_id, media_kind, content_type, filename, size_bytes |
blocks |
array | The inserted blocks as stored, each with the id it was stored under |
url is the item's link. The agent gives it to the user when it reports the change, labelled with the item's name rather than its folder path.
Example Scenario#
{
"identifier": "q1-research-notes-ab12cd",
"after_block_id": "AbCdE12345",
"blocks": [{ "type": "paragraph", "content": [{ "type": "text", "text": "Follow-up due Friday." }] }]
}
Notes#
- Each call is one read-modify-write of the document's current content, so it never overwrites an edit made since the agent read it. The result is stored as the document's new version and bumps its
revision; within 5 minutes of the current version, the write replaces that version instead of adding another. - An empty
blocksarray is refused; an unknownafter_block_idis refused withBlock not found: <id> - A folder or file is refused: it has no blocks
- An unknown or trashed identifier is refused with
Library item not found: <identifier> - Refused when the item's AI access policy denies reads or writes:
AI access denied: this resource is not writable by AI tools.(ornot readable) - Risk: write