enhancedocs
For agentsOpen Enhance
Reference / canvas.writeHtml

Enhance documentation

canvas.writeHtml

Compile safe HTML and CSS into editable canvas nodes, then render the result.

Markdown

canvas.writeHtml

mutation write

Use when the requested change exactly matches canvas.writeHtml; read the current state first when a version or identifier may have changed.

Before calling

  • Authenticate as the accountable Enhance person.
  • Use only resource identifiers returned by an earlier capability result or supplied by the person.
  • Reuse clientToken only when retrying this exact mutation input.

Input

Show complete JSON Schema
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "canvasId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "targetNodeId": {
      "type": "string",
      "minLength": 1,
      "maxLength": 200,
      "description": "Stable container id for insert-children, or subtree root id for replace."
    },
    "mode": {
      "type": "string",
      "enum": [
        "insert-children",
        "replace"
      ],
      "description": "Insert the compiled group inside the target, or replace the target subtree."
    },
    "html": {
      "type": "string",
      "minLength": 1,
      "maxLength": 1000000,
      "description": "Exactly one safe top-level HTML/CSS visual group to compile into editable nodes."
    },
    "idPrefix": {
      "description": "Optional stable namespace for the node ids generated by this import.",
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "baseVersion": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "renderOutputPath": {
      "anyOf": [
        {
          "type": "string",
          "minLength": 1
        },
        {
          "type": "null"
        }
      ],
      "description": "Local review PNG path, or null for a protected temporary artifact."
    },
    "overwriteRender": {
      "type": "boolean",
      "description": "Whether an existing renderOutputPath may be replaced."
    },
    "renderScale": {
      "type": "number",
      "minimum": 0.1,
      "maximum": 4,
      "description": "Review PNG pixels per canvas unit, from 0.1 through 4."
    },
    "renderTimeoutMs": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991,
      "description": "Local import and review-render polling deadline in milliseconds."
    }
  },
  "required": [
    "canvasId",
    "targetNodeId",
    "mode",
    "html",
    "baseVersion",
    "renderOutputPath",
    "overwriteRender",
    "renderScale",
    "renderTimeoutMs"
  ],
  "additionalProperties": false
}

Example

Show example input
{
  "canvasId": "00000000-0000-4000-8000-000000000010",
  "targetNodeId": "root",
  "mode": "insert-children",
  "html": "<div layer-name=\"Ready\" style=\"display:flex;width:320px;height:180px\"></div>",
  "idPrefix": "example",
  "baseVersion": 1,
  "renderOutputPath": null,
  "overwriteRender": false,
  "renderScale": 1,
  "renderTimeoutMs": 120000
}

Result

Returns a typed canvas.writeHtml result from the Enhance API without transport-specific prose.

Recovery

  • BAD_REQUEST: correct the named fields and call again.
  • UNAUTHORIZED: restore Enhance authentication, then retry once.
  • FORBIDDEN or NOT_FOUND: list accessible resources and choose an allowed identifier.
  • CONFLICT: read the current resource, merge the intended change, and retry with its version.
  • INTERNAL: run Enhance diagnostics, report the failure, and stop repeating the call.

Continue with

  • Read the affected canvas resource to confirm the result.

Compatibility: db9ff722fffa97aea8b06521b08acad08a91e5acc9ae467a378e86b75c387a5d.