HTML Render Endpoints

Render an HTML card to a video or a still frame, and write or version a card’s HTML body. All renders run on the same on-device Chromium virtual-time engine the app uses everywhere.

Render HTML to video

POST /api/html/render
{
  "html": "<!DOCTYPE html>…",
  "width": 1920,
  "height": 1080,
  "fps": 60,
  "duration": 6,
  "format": "mp4" | "webm",
  "title": "Hero scene",
  "board_id": "…"
}

Returns:

{
  "type": "video",
  "filename": "html_render_…​.mp4",
  "url": "/media/…",
  "proxy_url": "/media/…",
  "thumbnail_url": "/media/…"
}

The renderer steps the page’s clock with virtual time, so the output is identical on any machine for the same HTML. Animated cards sample the first, current, and last frame. proxy_url and thumbnail_url are present when the engine produces them.

Render a single frame

POST /api/html/render-frame
{
  "html": "<!DOCTYPE html>…",
  "width": 1920,
  "height": 1080,
  "fps": 60,
  "frame": 0,
  "title": "Poster",
  "board_id": "…"
}

Returns:

{
  "type": "image",
  "filename": "html_frame_…​.png",
  "url": "/media/…"
}

Captures one frame as a PNG. frame selects which frame to sample (omit for the viewport / first frame); fps is used to resolve the frame index for animated cards.

Write a card’s HTML body

PUT /api/moodboards/{board_id}/elements/{element_id}/html
{
  "html": "<!DOCTYPE html>…"
}

Returns:

{
  "htmlUrl": "/media/…",
  "htmlVersion": 4,
  "element": { "id": "…", "type": "html", … }
}

Writes the HTML to the card’s backing file and bumps its version. The element’s data.htmlUrl and data.htmlVersion update to match.

Mark a card’s HTML as changed

POST /api/moodboards/{board_id}/elements/{element_id}/html-changed

Bumps the card’s data.htmlVersion after the HTML file on disk has been edited directly, so the canvas preview re-reads the file.

Board Agent edits

The Board Agent rewrites a card’s HTML through its update_element_html action rather than calling these endpoints directly. The action is applied via POST /api/agents/apply-action with the payload:

{ "element_id": "…", "html": "<!DOCTYPE html>…" }

The agent supplies a full HTML document; the backend writes it to the card’s file and bumps the version, the same as the PUT …/html endpoint above.

Where to go next

Was this helpful?

0

Updated

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *