> ## Documentation Index
> Fetch the complete documentation index at: https://rendermate.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 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. 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 `/`, and `common={{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"`).
- 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`. `<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"}}} />`
- 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"}}} />`. `geometry` can also be `{type: "rect", rect: {x, y, width, height}}` or `{type: "oval", rect: {...}}`.
- 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 inside `destination`; `sourceIn` is where in the file it starts, in seconds.
- Sound: `<audio id="music" common={{start: 0, duration: 6}} assetId="intro" gain={0.3} />`
- Animation: a number becomes keyframes, `Doc.keys([seconds, value], ...)` timed from the node's start, such as `opacity: Doc.keys([0, 0], [0.5, 1])` in `common` or `radius: Doc.keys([0, 20], [3, 120])`.
- A field the format doesn't have is refused with jsx.unreadable, whose message says what that place takes.

MCP tool: [`edit_document`](/mcp/tools/documents#edit_document).



## OpenAPI

````yaml /api/openapi.json post /v1/documents/{document_id}/versions
openapi: 3.1.0
info:
  title: Rendermate API
  version: v1
servers:
  - url: https://api.rendermate.com
security:
  - api_key: []
tags:
  - name: Account
  - name: Workspaces
  - name: Projects
  - name: Documents
  - name: Links
  - name: Exports
  - name: Assets
  - name: Generations
  - name: Persons
  - name: Help
paths:
  /v1/documents/{document_id}/versions:
    post:
      tags:
        - Documents
      summary: Edit document
      description: >-
        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. 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 `/`, and
        `common={{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"`).

        - 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`. `<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"}}} />`

        - 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"}}}
        />`. `geometry` can also be `{type: "rect", rect: {x, y, width,
        height}}` or `{type: "oval", rect: {...}}`.

        - 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 inside
        `destination`; `sourceIn` is where in the file it starts, in seconds.

        - Sound: `<audio id="music" common={{start: 0, duration: 6}}
        assetId="intro" gain={0.3} />`

        - Animation: a number becomes keyframes, `Doc.keys([seconds, value],
        ...)` timed from the node's start, such as `opacity: Doc.keys([0, 0],
        [0.5, 1])` in `common` or `radius: Doc.keys([0, 20], [3, 120])`.

        - A field the format doesn't have is refused with jsx.unreadable, whose
        message says what that place takes.


        MCP tool: [`edit_document`](/mcp/tools/documents#edit_document).
      operationId: edit_document
      parameters:
        - in: path
          name: document_id
          required: true
          schema:
            type: string
      requestBody:
        content:
          application/json:
            schema:
              properties:
                base_version:
                  description: >-
                    The version the edit was made on, as get_document returned
                    it: the edit is committed only

                    if that's still the newest version.
                  format: uint64
                  minimum: 0
                  type: integer
                commit_id:
                  description: >-
                    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.
                  type:
                    - string
                    - 'null'
                edits:
                  description: >-
                    Replacements in the JSX of `base_version`, made in order.
                    Give these or `jsx`.
                  items:
                    $ref: '#/components/schemas/TextEdit'
                  type: array
                jsx:
                  description: >-
                    The whole document as edited JSX, in place of `edits`. Every
                    node it keeps keeps its `id`.
                  type:
                    - string
                    - 'null'
                message:
                  description: >-
                    Why the document changes, in one line, like a git commit
                    message: "Shorten the intro

                    to 4 seconds", not "update document".
                  type: string
              required:
                - base_version
                - message
              type: object
        required: true
      responses:
        '201':
          content:
            application/json:
              example:
                author:
                  id: api_key_01JF3Q1C5E7G9J2M4N6Q8S0T2W
                  name: ci
                  via: api
                commit_id: 0193f2a4-c1d8-7b2e-9f3a-6c5d4e8b7a10
                committed_at: '2026-12-03T10:15:00Z'
                id: doc_01JF3QZ8X6N2V7K4M9P5R1T3WY
                message: Shorten the intro
                sha256: >-
                  9f2c4e1a7b3d5f8e0c6a2b4d8f1e3c5a7b9d0f2e4c6a8b1d3f5e7c9a0b2d4f6e
                version: 12
              schema:
                properties:
                  author:
                    anyOf:
                      - $ref: '#/components/schemas/AuthorView'
                      - type: 'null'
                    description: The API key, or the member, that made it.
                  commit_id:
                    description: The commit that made the version.
                    type: string
                  committed_at:
                    description: RFC 3339.
                    type:
                      - string
                      - 'null'
                  id:
                    description: The document, `doc_…`.
                    type: string
                  jsx:
                    description: >-
                      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`.
                    type:
                      - string
                      - 'null'
                  message:
                    description: What the commit changes and why.
                    type:
                      - string
                      - 'null'
                  sha256:
                    description: SHA-256 of the document as canonical JSON.
                    type: string
                  version:
                    description: >-
                      The version's number: 1 for the document as created, one
                      more for each commit.
                    format: uint64
                    minimum: 0
                    type: integer
                required:
                  - id
                  - version
                  - commit_id
                  - sha256
                type: object
          description: Created
        '400':
          content:
            application/json:
              examples:
                document.invalid:
                  summary: document.invalid
                  value:
                    error:
                      code: document.invalid
                      diagnostics:
                        - code: version.missing
                          message: schemaVersion must be an unsigned integer
                          pointer: /schemaVersion
                      doc_url: https://rendermate.com/docs/errors#document.invalid
                      message: >-
                        the document isn't a valid Rendermate document:
                        version.missing: schemaVersion must be an unsigned
                        integer (/schemaVersion)
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
                invalid_request:
                  summary: invalid_request
                  value:
                    error:
                      code: invalid_request
                      doc_url: https://rendermate.com/docs/errors#invalid_request
                      message: >-
                        give either edits, replacements in the document's JSX,
                        or jsx, the whole edited document, one of the two
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
                jsx.cut:
                  summary: jsx.cut
                  value:
                    error:
                      code: jsx.cut
                      doc_url: https://rendermate.com/docs/errors#jsx.cut
                      message: >-
                        Doc.cut("a…", …) is not the string that was here: it
                        stands for a value the view cut, which is only known
                        where the view printed it: write the whole value, or
                        leave it where it was
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
                jsx.edit.unmatched:
                  summary: jsx.edit.unmatched
                  value:
                    error:
                      code: jsx.edit.unmatched
                      doc_url: https://rendermate.com/docs/errors#jsx.edit.unmatched
                      message: >-
                        edits[0].old_text occurs 0 times in the document's JSX,
                        as the edits before it left it; it must occur once, so
                        read the document again or include more of the text
                        around it
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
                jsx.timebase:
                  summary: jsx.timebase
                  value:
                    error:
                      code: jsx.timebase
                      doc_url: https://rendermate.com/docs/errors#jsx.timebase
                      message: >-
                        canvas.ticksPerSecond cannot be edited: every time is
                        stored in it
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
                jsx.unreadable:
                  summary: jsx.unreadable
                  value:
                    error:
                      code: jsx.unreadable
                      doc_url: https://rendermate.com/docs/errors#jsx.unreadable
                      message: |-
                        line 46, column 7: Unexpected token
                          46 | common={{duration: 2, order: "a0", start: 0}}
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
                message.required:
                  summary: message.required
                  value:
                    error:
                      code: message.required
                      doc_url: https://rendermate.com/docs/errors#message.required
                      message: >-
                        give the commit a message: what it changes and why, in a
                        line
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            - `invalid_request`: give either edits, replacements in the
            document's JSX, or jsx, the whole edited document, one of the two

            - `message.required`: give the commit a message: what it changes and
            why, in a line

            - `jsx.edit.unmatched`: edits[0].old_text occurs 0 times in the
            document's JSX, as the edits before it left it; it must occur once,
            so read the document again or include more of the text around it

            - `jsx.unreadable`: line 46, column 7: Unexpected token   46 \|
            common=\{\{duration: 2, order: "a0", start: 0}}

            - `jsx.cut`: Doc.cut("a…", …) is not the string that was here: it
            stands for a value the view cut, which is only known where the view
            printed it: write the whole value, or leave it where it was

            - `jsx.timebase`: canvas.ticksPerSecond cannot be edited: every time
            is stored in it

            - `document.invalid`: the document isn't a valid Rendermate
            document: version.missing: schemaVersion must be an unsigned integer
            (/schemaVersion)
        '401':
          content:
            application/json:
              examples:
                unauthorized:
                  summary: unauthorized
                  value:
                    error:
                      code: unauthorized
                      doc_url: https://rendermate.com/docs/errors#unauthorized
                      message: 'provide a valid API key: Authorization: Bearer sk_…'
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            - `unauthorized`: provide a valid API key: Authorization: Bearer
            sk_…
        '403':
          content:
            application/json:
              examples:
                key_without_workspace:
                  summary: key_without_workspace
                  value:
                    error:
                      code: key_without_workspace
                      doc_url: https://rendermate.com/docs/errors#key_without_workspace
                      message: >-
                        this API key has no workspace: create a key in the
                        dashboard, under api keys in the workspace it should act
                        in
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            - `key_without_workspace`: this API key has no workspace: create a
            key in the dashboard, under api keys in the workspace it should act
            in
        '404':
          content:
            application/json:
              examples:
                document.not_found:
                  summary: document.not_found
                  value:
                    error:
                      code: document.not_found
                      doc_url: https://rendermate.com/docs/errors#document.not_found
                      message: no such document
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: '- `document.not_found`: no such document'
        '409':
          content:
            application/json:
              examples:
                commit_id.reused:
                  summary: commit_id.reused
                  value:
                    error:
                      code: commit_id.reused
                      doc_url: https://rendermate.com/docs/errors#commit_id.reused
                      message: the commit id was used for another change
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
                version.conflict:
                  summary: version.conflict
                  value:
                    error:
                      code: version.conflict
                      doc_url: https://rendermate.com/docs/errors#version.conflict
                      message: >-
                        base_version is not the newest version, 12: read that
                        and commit onto it
                      newest_version: 12
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            - `version.conflict`: base_version is not the newest version, 12:
            read that and commit onto it

            - `commit_id.reused`: the commit id was used for another change
        '500':
          content:
            application/json:
              examples:
                internal:
                  summary: internal
                  value:
                    error:
                      code: internal
                      doc_url: https://rendermate.com/docs/errors#internal
                      message: internal error
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: '- `internal`: internal error'
        '503':
          content:
            application/json:
              examples:
                commit.unknown:
                  summary: commit.unknown
                  value:
                    error:
                      code: commit.unknown
                      commit_id: 0193f2a4-c1d8-7b2e-9f3a-6c5d4e8b7a10
                      doc_url: https://rendermate.com/docs/errors#commit.unknown
                      message: >-
                        the document store failed before the commit could be
                        confirmed: send the same request again with commit_id
                        0193f2a4-c1d8-7b2e-9f3a-6c5d4e8b7a10 to learn whether it
                        was made
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
                document.contended:
                  summary: document.contended
                  value:
                    error:
                      code: document.contended
                      doc_url: https://rendermate.com/docs/errors#document.contended
                      message: >-
                        other writers kept changing the document, and nothing
                        was written: send the request again
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
                documents.unavailable:
                  summary: documents.unavailable
                  value:
                    error:
                      code: documents.unavailable
                      doc_url: https://rendermate.com/docs/errors#unavailable
                      message: this deployment does not store documents yet
                      request_id: req_0193f2a4c1d87b2e9f3a6c5d4e8b7a10
              schema:
                $ref: '#/components/schemas/Error'
          description: >-
            - `document.contended`: other writers kept changing the document,
            and nothing was written: send the request again

            - `commit.unknown`: the document store failed before the commit
            could be confirmed: send the same request again with commit_id
            0193f2a4-c1d8-7b2e-9f3a-6c5d4e8b7a10 to learn whether it was made

            - `documents.unavailable`: this deployment does not store documents
            yet
components:
  schemas:
    TextEdit:
      additionalProperties: false
      description: One replacement in a document's JSX.
      properties:
        new_text:
          description: What replaces it.
          type: string
        old_text:
          description: >-
            Text that occurs exactly once in the JSX, as the edits before this
            one left it: include

            a node's `id="…"` or enough of the lines around it to make it
            unique.
          type: string
      required:
        - old_text
        - new_text
      type: object
    AuthorView:
      description: Who made a version.
      properties:
        client:
          description: >-
            The program that sent it, from its User-Agent, such as
            `claude-code`.
          type:
            - string
            - 'null'
        id:
          description: The API key (`api_key_…`) or the member (`user_…`).
          type: string
        name:
          description: The API key's name, or the member's, when it made the version.
          type:
            - string
            - 'null'
        via:
          description: 'How the change came in: `api`, `dashboard` or `mcp`.'
          type:
            - string
            - 'null'
      required:
        - id
      type: object
    Error:
      properties:
        error:
          properties:
            code:
              description: Stable, such as `asset.name_taken` or `not_available`.
              type: string
            doc_url:
              description: The code's entry on the Errors page.
              type: string
            message:
              description: What went wrong and what to do next.
              type: string
            request_id:
              description: >-
                The request's ID, also in its `x-request-id` header. Quote it
                when you contact support.
              type: string
          required:
            - code
            - message
            - doc_url
            - request_id
          type: object
      required:
        - error
      type: object
  securitySchemes:
    api_key:
      description: >-
        An API key from the dashboard, such as `sk_live_…`. It acts in its
        workspace.
      scheme: bearer
      type: http

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.