document_write
tools/call
Write a shared document's body in Markdown or plain text, replacing it or appending to it, without building editor steps. The server reads Markdown as the editor reads a Markdown paste, so the document is the one a person pasting the same Markdown gets. Markdown holds headings # to ###, paragraphs, bullet, numbered and checkbox (- [ ]) lists, > quotes, fenced code blocks with a language, --- rules, tables, links (https, http or mailto), **bold**, *italic*, ~~strikethrough~~ and `inline code`, plus the :::specify-callout and :::specify-toggle blocks the editor's Markdown export writes. HTML, images and other media, other links, #### or deeper headings, reference-style links and footnotes (write each link inline), links or formatting around `inline code` or a mention, table rows with more cells than the header row, and NUL characters or unpaired surrogates, escaped inside a :::specify-node block's JSON included, are refused with what was found, and nothing is written. Pass base, the document epoch and version you read (project_page_get, or documents_execute open): if the document changed since, the call answers DOCUMENT_CONFLICT and changes nothing, so read it again and retry. A write that would leave the document past its bounds (512 KB stored, 2000 blocks, 20 levels of nesting, tables of 50 rows, 20 columns and 1000 cells), on top of the body for an append, answers DOCUMENT_TOO_LARGE and changes nothing. Writing needs the access a documents_execute append needs.
Scopes
It takes the document checks of a documents_execute append: a project, task or page document needs read:projects and write:projects on its project; a Memory document follows the Memory scopes.
Inputs
- documentIdstringRequired
- Document ID (document.id from project_page_get, or a documents_execute open)
- contentstringRequired
- The body to write in format, at most 100,000 characters, with no NUL or unpaired surrogate
- format"text" | "markdown"
- text (default): each line becomes a paragraph, written as is. markdown: read as the editor reads a Markdown paste
- mode"replace" | "append"
- replace (default) swaps the whole body; append adds the blocks after the last one
- baseobjectRequired
- The document epoch and version as you last read them
- idempotencyKeystringRequired
- Unique retry key
Returns
The document's id, epoch and version after the write, and whether it was a replay. A call returns content[0].text with the JSON result and structuredContent.result with the same value.
Listed when
The key has read:projects.