Skip to main content
Create, read and rewrite HTML page artifacts under a required version check. Every page renders with the workspace’s design.md css — read it first with read_theme and use its classes.

create_page

Scope: documents:write (step-up) · Kind: write · Annotations: readOnlyHint: false, destructiveHint: false, idempotentHint: false, openWorldHint: false
Create an HTML page artifact in the person’s library with a scope: user (private, the default) or org, optionally filed into a folder (folder_id). The HTML source is stored verbatim, but pages render inert: <script>/<iframe>/<object>/<embed>, every on* event-handler attribute and every javascript:/vbscript:/data:text/html URL are removed at render, in a sandboxed frame with no scripts and a default-src 'none' CSP. A script_stripped warning tells you when that will happen. Returns — url is the link to share with people, version what write_page requires.

Parameters

Pass a scope, optionally with folder_id.
string
required
string
The page’s HTML, stored verbatim. Must be non-empty. Required unless upload_id is given.
string
Instead of html: the id from request_upload_url (format html) after the file was uploaded. Use it for a file already on disk or anything over about 8 KB. Never pass both.
'user' | 'org'
default:"user"
Where the page lives.
string
With a scope: file the page straight into this folder (from list_folders). You must be its owner or a participant.

Returns

string
The artifact id. Use it as page_id for read_page and write_page, and as document_id for comments and export.
string
The web-app link the page opens at (https://sidecars.ai/artifacts/<page_id>) — share this one, never a guessed path.
string
number
The version write_page must pass as expected_version.
number
string[]
["script_stripped"] when the HTML contains anything the renderer removes: <script>, <iframe>, <object> or <embed> elements, on* event-handler attributes (onload, onerror, onfocus, onmouseover, … on any element, SVG included), or javascript:, vbscript: and data:text/html URLs in URL attributes (href, src, srcdoc, action, formaction, xlink:href, …), entity- or whitespace-encoded or not. They stay in the stored source but are removed when the page is viewed, so its interactivity will not run.
Text: Created page "<title>" (page_id: <id>, version <n>) — <url>. plus Note: its scripts, embedded elements, event handlers and script URLs will be removed when viewed. when applicable.

Permissions and side effects

  • Needs documents:write.
  • The access gate runs inside the create transaction: with folder_id you must be the folder’s owner or a participant.
  • The caller becomes the owner; nothing is posted anywhere.

Errors

Limitations

  • No idempotency key on this tool; a retried create makes a second page.
  • Pages run no code. The viewer and the downloadable rendition are both the stripped page (see warnings above), shown in a sandboxed iframe without allow-scripts, under a default-src 'none' Content-Security-Policy that permits only inline styles and data:/same-origin images and fonts. Style with inline CSS; there is no way to run JavaScript in a page.

Example

Request
Response (structuredContent)

read_page

Scope: documents:read (step-up) · Kind: read-only · Annotations: readOnlyHint: true, destructiveHint: false, openWorldHint: false
Read a page’s stored HTML source and its version — the token write_page’s expected_version is checked against. This is the source as written, not what viewers get: pages render with scripts, event handlers, javascript:/vbscript:/data:text/html URLs and iframe/object/embed removed, in a sandboxed script-less frame.

Parameters

string
required
The page’s artifact id.

Returns

string
string
string
The stored source as written, scripts and handlers included. Viewers never receive it: the rendered page has them removed (see create_page warnings).
number
Pass as expected_version to write_page.
Text: # <title> (version <n>) followed by the HTML.

Permissions and side effects

  • Needs documents:read and any role on the page. The access check and the source read happen in one transaction.
  • Reads only. Recorded in the agent activity history.

Errors

Example

Request
Response (structuredContent)

write_page

Scope: documents:write (step-up) · Kind: write, destructive · Annotations: readOnlyHint: false, destructiveHint: true, idempotentHint: false, openWorldHint: false
Replace a page’s HTML wholesale. expected_version is REQUIRED — the version read_page (or create_page) returned. If the page moved since your read, the write refuses with the current version and a line-level diff of what changed, so you can merge and retry; there is no force flag, by design. The source is stored verbatim; at render, scripts, on* handlers, javascript:/vbscript:/data:text/html URLs and iframe/object/embed are removed and the page runs in a sandboxed, script-less, CSP-locked frame.

Parameters

string
required
string
The complete new HTML. Must be non-empty. Required unless upload_id is given.
string
Instead of html: the id from request_upload_url (format html) after the file was uploaded. Use it for a file already on disk or anything over about 8 KB. Never pass both.
number
required
The version read_page or create_page returned. Must be a non-negative integer.

Returns

string
number
number
string[]
["script_stripped"] when the HTML carries anything the renderer removes (same rule as create_page).
Text: Wrote the page; it is now at version <n> (<bytes> bytes).

Permissions and side effects

  • Needs documents:write and the editor or owner role. The role is re-checked inside the write transaction.
  • Replaces the whole page. The previous source is kept as a checkpoint.
  • Attributed to you via the host.

Errors

There is deliberately no way to overwrite a newer version without reading it first.

Example

Request
Response (structuredContent)
Conflict response (structuredContent)