edit_document
Change a document by committing an edit on base_version, which makes a new version. Give edits, exact replacements in the JSX get_document returned for base_version: each old_text must occur exactly once, spaces and line breaks included (copy it from that JSX, and include the node's id="..." to make it unique), and they apply in order. Or give jsx, the whole edited document: do that to add the first nodes to an empty document, whose <timeline ... /> closes itself. A document's JSX is laid out its own way, not as it was sent: each attribute on its own line and object keys sorted. So after every commit, call get_document before writing old_text. Long strings and arrays the JSX cut (Doc.cut, ...Doc.more) stay as they are when left in place. If another commit landed after base_version, this fails with version.conflict: read the document again and redo the edit.
How to write what most videos need (https://rendermate.com/docs/documents has the rest):
Every node has an
id="...", unique and without/, andcommon={{start: 0, duration: 3, order: "a1"}}: its window in seconds, which may not reach past the canvas's duration, and its paint order among its siblings ("a0"is under"a1"). An order key's first letter sets how many digits follow it:aone,btwo,cthree, and so on, each digit 0-9, A-Z or a-z. So count"a0"to"az", then"b00"to"bzz";"n001"is refused becausenneeds 14 digits. To put a node between"a1"and"a2", add a digit:"a1V".Files are declared before
export default, each with an id that nodes use and a workspace asset, uploaded with upload_asset or imported with import_asset first:export const assets = {fonts: [{id: "inter", family: "Inter", weight: 700, style: "normal", source: {type: "uri", uri: "asset://brand/Inter-Bold.ttf"}}], images: [{id: "logo", source: {type: "uri", uri: "asset://brand/logo.png"}}], media: [{id: "intro", source: {type: "uri", uri: "asset://launch/intro.mp4"}}]};Text needs a font: a .ttf or .otf asset declared in
fonts, which import_asset can fetch, such as https://github.com/google/fonts/raw/main/ofl/poppins/Poppins-Bold.ttf.<text id="title" common={{start: 0, duration: 3, order: "a3"}} content={{type: "paragraph", text: "Hello world", position: {x: 120, y: 860}, width: 1680, align: "left", style: {fontId: "inter", fontSize: 96, color: "#ffffff"}}} />. Fonts that share afamily(such as Poppins Bold and Poppins Italic) are told apart by the style'sfontWeightandfontStyle, which default to 400 and"normal": give each style the weight and style of its font.positionis the top-left corner of the text's box,widthwide, thatalign(left,center,right) places each line in; the first line's baseline sits about one font size belowposition.y. To centre text vertically, give the box aheightandverticalAlign: "center"(or"bottom"):position: {x: 0, y: 0}, width: 1920, height: 1080centres it on the whole canvas. To reveal it word by word, addanimators: [{unit: "word", stagger: 400, opacity: Doc.keys([0, 0], [0.3, 1])}]tocontent: each word fades in over 0.3 seconds, one every 400 ticks (0.4 seconds at 1000 ticks a second), in place, the first at the node's start (an animator'sfillColoris channels,{r: 1, g: 0.85, b: 0.3, a: 1}, each 0 to 1 and each a number or keyframes);delays, one per word in ticks, times them to speech instead (https://rendermate.com/docs/documents#how-do-i-add-captions-timed-to-speech).A background colour:
<fill id="bg" common={{order: "a0"}} paint={{style: "fill", source: {type: "solid", color: "#10233f"}}} />A shape:
<shape id="dot" common={{start: 0, duration: 3, order: "a2"}} geometry={{type: "circle", center: {x: 960, y: 540}, radius: 100}} paint={{style: "fill", source: {type: "solid", color: "#ffd84d"}}} />.geometrycan also be{type: "rect", rect: {x, y, width, height}},{type: "oval", rect: {...}}, or a rectangle with rounded corners, such as a button:{type: "roundedRect", rect: {rect: {x: 760, y: 480, width: 400, height: 120}, topLeft: {x: 60, y: 60}, topRight: {x: 60, y: 60}, bottomRight: {x: 60, y: 60}, bottomLeft: {x: 60, y: 60}}}, each corner's radii in pixels.A line or any outline: a path in SVG path syntax, painted as a stroke:
<shape id="tick" common={{start: 0, duration: 3, order: "a5"}} geometry={{type: "path", fillType: "winding", path: "M 100 100 L 300 300 L 500 100"}} paint={{style: "stroke", strokeWidth: 12, strokeCap: "round", source: {type: "solid", color: "#ffffff"}}} />.styleisfill,strokeorstrokeAndFill;strokeWidthis in pixels;strokeCapisbutt(the default),roundorsquare, andstrokeJoinmiter(the default),roundorbevel.fillTypesays what's inside a path that crosses itself:windingfills every region it loops around,evenOddleaves every second one empty, andinverseWindingandinverseEvenOddfill the outside instead. One path's data may be up to 1 MiB.Moving, scaling and turning any node, media and text included:
transformincommon, aboutorigin, which is the canvas's top-left corner (0, 0) unless set, so set it to the node's centre to scale or turn it in place:<shape id="card" common={{start: 0, duration: 3, order: "a6", origin: {x: 960, y: 540}, transform: {translateX: Doc.keys([0, -200, "easeOutCubic"], [1, 0]), translateY: 0, scaleX: 1.2, scaleY: 1.2, rotate: {value: 15, unit: "degrees"}}}} geometry={{type: "rect", rect: {x: 760, y: 440, width: 400, height: 200}}} paint={{style: "fill", source: {type: "solid", color: "#ff3366"}}} />.translateXandtranslateYare pixels,scaleXandscaleYfactors (1 is the node's size), androtatean angle indegreesorradians.skewXandskewYare angles too. Any of them can be keyframes, such asrotate: {value: Doc.keys([0, 0], [1, 90]), unit: "degrees"}.A gradient, in any paint's
source:<fill id="sky" common={{order: "a4"}} paint={{style: "fill", source: {type: "gradient", gradient: {type: "linear", start: {x: 0, y: 0}, end: {x: 1920, y: 1080}, stops: [{offset: 0, color: "#10233f"}, {offset: 1, color: "#6a2c91"}], tileMode: "clamp"}}}} />. Aradialgradient takescenterandradiusin place ofstartandend;tileModeisclamp,repeat,mirrorordecal.A group holds nodes:
<group id="cards" common={{start: 1, duration: 3, order: "a7", opacity: 0.9}}><shape id="pip" common={{start: 1, duration: 2, order: "a0"}} geometry={{type: "circle", center: {x: 200, y: 200}, radius: 40}} paint={{style: "fill", source: {type: "solid", color: "#ffffff"}}} /></group>. Itsopacityandtransformapply to all of its children, which show only inside its window. A child'sstartis on the same clock as the group's, not counted from it, so this circle shows from 1 s to 3 s.A flat node tilted in depth, like CSS 3D, with no camera or lights:
perspective(the viewer's distance in pixels),rotateX,rotateYandtranslateZ(pixels toward the viewer) intransform, aboutorigin:<shape id="flip" common={{start: 0, duration: 3, order: "a8", origin: {x: 960, y: 540}, transform: {perspective: 1200, rotateY: {value: Doc.keys([0, 0, "easeInOutCubic"], [2, 70]), unit: "degrees"}}}} geometry={{type: "rect", rect: {x: 760, y: 440, width: 400, height: 200}}} paint={{style: "fill", source: {type: "solid", color: "#ff3366"}}} />.A real 3D scene, with depth, extrusion, lights, shadows and a camera:
layer3din a node'scommonputs it in the scene. A scene node is placed withz(pixels away from the viewer),xRotation(positive brings the top toward the viewer),yRotation(positive brings the right edge toward the viewer) androtate, and refusesperspective,rotateX,rotateYandtranslateZ(validation.layer3d_css_transform). Solid 3D text:<text id="solid" common={{start: 0, duration: 3, order: "a9", origin: {x: 960, y: 540}, layer3d: {castsShadows: "on", extrusion: {depth: 30, bevel: {style: "convex", depth: 4}}}, transform: {xRotation: {value: Doc.keys([0, 70, "easeOutCubic"], [1.5, 0]), unit: "degrees"}}}} content={{type: "paragraph", text: "Hello world", position: {x: 360, y: 480}, width: 1200, align: "center", style: {fontId: "inter", fontSize: 140, color: "#111111"}}} />. Lights:<light id="key" common={{start: 0, duration: 3, order: "b00", transform: {translateX: 400, translateY: 0, z: -1000}}} lightType="point" intensity={1} castsShadows={true} />;lightTypeisparallel,spot,point,ambient,environment,hemisphereorrectArea. Without a light, scene nodes show their own colours, unshaded. A camera:<camera id="cam" common={{start: 0, duration: 3, order: "b01", transform: {z: -1500}}} zoom={1500} pointOfInterest={{x: 960, y: 540, z: 0}} depthOfField={{focusDistance: 1500, aperture: 40, blurLevel: 1}} />; without one the scene is filmed from the canvas's centre by a 50 mm lens.layer3d: {acceptsShadows: "only"}makes a node a shadow catcher, which shows only the shadows that fall on it. More at https://rendermate.com/docs/documents#how-do-i-make-3d.A video, or an image from
images:<media id="clip" common={{start: 0, duration: 4, order: "a1"}} assetId="intro" destination={{x: 0, y: 0, width: 1920, height: 1080}} fit="cover" sampling={{filter: "linear", mipmap: "linear"}} sourceIn={1} />.fit="contain"fits it insidedestination;sourceInis where in the file it starts, in seconds.Sound:
<audio id="music" common={{start: 0, duration: 6}} assetId="intro" sourceIn={2} gain={Doc.keys([0, 0], [1, 0.8], [4, 0.8], [6, 0])} />plays the file from 2 seconds in, fading in over 1 second and out over the last 2;gainis a plain number, such as0.3, to keep it level; it multiplies the sound's amplitude (1 leaves it as it is, 0.5 is about -6 dB). Sound files (mp3, wav, m4a) are declared inmedia, as video is. Audio takes noorder. It plays only from the node'sstartfor itsduration, so a longer file is cut off at the node's end.A crossfade: overlap two nodes by the fade's length and fade the later one in,
opacity: Doc.keys([0, 0], [0.6, 1]). A slow zoom on a photo (Ken Burns): keyframescaleXandscaleYfrom 1 to about 1.15 over the media node's whole window, withoriginat its centre.Animation: a number becomes keyframes,
Doc.keys([seconds, value], ...)timed from the node's start, such asopacity: Doc.keys([0, 0], [0.5, 1])incommonorradius: Doc.keys([0, 20], [3, 120]). A keyframe's third item eases the way to the next one:"linear"(the default),"hold", or one of"easeIn","easeOut"and"easeInOut"followed bySine,Quad,Cubic,ExpoorBack, such as"easeOutCubic";Backovershoots by about a tenth and settles, for a bounce. Times are 0 or more and strictly increasing: two keyframes at one time are refused (validation.unsorted_keyframes), so to jump at once give the earlier one"hold", which keeps its value until the next one's time. Before the first keyframe the value holds the first one's, and after the last it holds the last one's. A keyframe past the node's duration is allowed, but the node stops drawing when its window ends, so it shows the value the curve has reached by then. A curve may have any number of keyframes, within the document's 64 MiB.A long or repetitive video: never cut what it shows to make it smaller. Write what repeats once. A named curve, declared before
export default:const fadeIn = Doc.keys([0, 0, "easeOutCubic"], [0.6, 1]);, read by its name, as inopacity: fadeIn; its times count from the start of each node that reads it. A component, also beforeexport default:function Label({text = "Label", y = 0}) { return (<Composition id="label" duration={3} width={1920} height={1080}><text id="t" common={{start: 0, duration: 3, order: "a0", opacity: Doc.keys([0, 0], [0.6, 1]), transform: {translateY: y}}} content={{type: "paragraph", text: text, position: {x: 120, y: 100}, width: 1680, align: "left", style: {fontId: "inter", fontSize: 96, color: "#ffffff"}}} /></Composition>); }. Each use is a node with its own id, window and props:<Label id="first" common={{start: 0, duration: 3, order: "b02"}} text="First" y={200} />; its nodes' times count from that node's start. Then send a big document in several edits: create it, add the first nodes with jsx, and add each further batch with the edit{old_text: " </timeline>", new_text: " <Label ... />\n </timeline>"}on the version the last commit returned, with no need to read the document in between.A field the format doesn't have is refused with jsx.unreadable, whose message says what that place takes.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"document_id": "<document_id>",
"base_version": "<base_version>",
"message": "<message>"
},
"name": "edit_document"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| jsx | No | The whole document as edited JSX, in place of `edits`. Every node it keeps keeps its `id`. | |
| edits | No | Replacements in the JSX of `base_version`, made in order. Give these or `jsx`. | |
| message | Yes | Why the document changes, in one line, like a git commit message: "Shorten the intro to 4 seconds", not "update document". | |
| commit_id | No | A UUID that makes the commit safe to send again: sent again with the same one, it answers with the version it made instead of making another. The `Idempotency-Key` header does the same. | |
| document_id | Yes | The document to edit, `doc_…`. | |
| base_version | Yes | The version the edit was made on, as get_document returned it: the edit is committed only if that's still the newest version. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | The document, `doc_…`. | |
| jsx | No | The [Rendermate document](https://rendermate.com/docs/documents) at this version, written as JSX; only when it's read, not when it's created or committed. Edit it with edit_document, giving this version as `base_version`. | |
| author | No | The API key, or the member, that made it. | |
| sha256 | Yes | SHA-256 of the document as canonical JSON. | |
| message | No | What the commit changes and why. | |
| version | Yes | The version's number: 1 for the document as created, one more for each commit. | |
| commit_id | Yes | The commit that made the version. | |
| committed_at | No | RFC 3339. |