Skip to main content
Alpha: Document API is currently alpha and subject to breaking changes.

Summary

Apply a previously computed diff payload to the current document. The document fingerprint must match the diff base fingerprint. Tracked mode governs body content only; styles, numbering, and comments are always applied directly.
  • Operation ID: diff.apply
  • API member path: editor.doc.diff.apply(...)
  • Mutates document: yes
  • Idempotency: conditional
  • Supports tracked mode: yes
  • Supports dry run: no
  • Deterministic target resolution: yes

Expected result

Returns a DiffApplyResult with applied operation count and diagnostics.

Input fields

FieldTypeRequiredDescription
diffobject(version=“sd-diff-payload/v1”)yes
diff.baseFingerprintstringyes
diff.coverageobjectyes
diff.coverage.bodytrueyesConstant: true
diff.coverage.commentsbooleanyes
diff.coverage.headerFootersfalseyesConstant: false
diff.coverage.numberingbooleanyes
diff.coverage.stylesbooleanyes
diff.engineenumyes"super-editor"
diff.payloadobjectyes
diff.summaryobjectyes
diff.summary.bodyobjectyes
diff.summary.body.hasChangesbooleanyes
diff.summary.changedComponentsenum[]yes
diff.summary.commentsobjectyes
diff.summary.comments.hasChangesbooleanyes
diff.summary.hasChangesbooleanyes
diff.summary.numberingobjectyes
diff.summary.numbering.hasChangesbooleanyes
diff.summary.stylesobjectyes
diff.summary.styles.hasChangesbooleanyes
diff.targetFingerprintstringyes
diff.version"sd-diff-payload/v1"yesConstant: "sd-diff-payload/v1"

Example request

{
  "diff": {
    "baseFingerprint": "example",
    "coverage": {
      "body": true,
      "comments": true,
      "headerFooters": false,
      "numbering": true,
      "styles": true
    },
    "engine": "super-editor",
    "payload": {},
    "summary": {
      "body": {
        "hasChanges": true
      },
      "changedComponents": [
        "body"
      ],
      "comments": {
        "hasChanges": true
      },
      "hasChanges": true,
      "numbering": {
        "hasChanges": true
      },
      "styles": {
        "hasChanges": true
      }
    },
    "targetFingerprint": "example",
    "version": "sd-diff-payload/v1"
  }
}

Output fields

FieldTypeRequiredDescription
appliedOperationsintegeryes
baseFingerprintstringyes
coverageobjectyes
coverage.bodytrueyesConstant: true
coverage.commentsbooleanyes
coverage.headerFootersfalseyesConstant: false
coverage.numberingbooleanyes
coverage.stylesbooleanyes
diagnosticsstring[]yes
summaryobjectyes
summary.bodyobjectyes
summary.body.hasChangesbooleanyes
summary.changedComponentsenum[]yes
summary.commentsobjectyes
summary.comments.hasChangesbooleanyes
summary.hasChangesbooleanyes
summary.numberingobjectyes
summary.numbering.hasChangesbooleanyes
summary.stylesobjectyes
summary.styles.hasChangesbooleanyes
targetFingerprintstringyes

Example response

{
  "appliedOperations": 1,
  "baseFingerprint": "example",
  "coverage": {
    "body": true,
    "comments": true,
    "headerFooters": false,
    "numbering": true,
    "styles": true
  },
  "diagnostics": [
    "example"
  ],
  "summary": {
    "body": {
      "hasChanges": true
    },
    "changedComponents": [
      "body"
    ],
    "comments": {
      "hasChanges": true
    },
    "hasChanges": true,
    "numbering": {
      "hasChanges": true
    },
    "styles": {
      "hasChanges": true
    }
  },
  "targetFingerprint": "example"
}

Pre-apply throws

  • INVALID_INPUT
  • CAPABILITY_UNSUPPORTED
  • PRECONDITION_FAILED
  • CAPABILITY_UNAVAILABLE

Non-applied failure codes

  • None

Raw schemas

{
  "additionalProperties": false,
  "properties": {
    "diff": {
      "additionalProperties": false,
      "properties": {
        "baseFingerprint": {
          "type": "string"
        },
        "coverage": {
          "additionalProperties": false,
          "properties": {
            "body": {
              "const": true,
              "type": "boolean"
            },
            "comments": {
              "type": "boolean"
            },
            "headerFooters": {
              "const": false,
              "type": "boolean"
            },
            "numbering": {
              "type": "boolean"
            },
            "styles": {
              "type": "boolean"
            }
          },
          "required": [
            "body",
            "comments",
            "styles",
            "numbering",
            "headerFooters"
          ],
          "type": "object"
        },
        "engine": {
          "enum": [
            "super-editor"
          ],
          "type": "string"
        },
        "payload": {
          "description": "Opaque engine-owned diff data.",
          "type": "object"
        },
        "summary": {
          "additionalProperties": false,
          "properties": {
            "body": {
              "additionalProperties": false,
              "properties": {
                "hasChanges": {
                  "type": "boolean"
                }
              },
              "required": [
                "hasChanges"
              ],
              "type": "object"
            },
            "changedComponents": {
              "items": {
                "enum": [
                  "body",
                  "comments",
                  "styles",
                  "numbering"
                ],
                "type": "string"
              },
              "type": "array"
            },
            "comments": {
              "additionalProperties": false,
              "properties": {
                "hasChanges": {
                  "type": "boolean"
                }
              },
              "required": [
                "hasChanges"
              ],
              "type": "object"
            },
            "hasChanges": {
              "type": "boolean"
            },
            "numbering": {
              "additionalProperties": false,
              "properties": {
                "hasChanges": {
                  "type": "boolean"
                }
              },
              "required": [
                "hasChanges"
              ],
              "type": "object"
            },
            "styles": {
              "additionalProperties": false,
              "properties": {
                "hasChanges": {
                  "type": "boolean"
                }
              },
              "required": [
                "hasChanges"
              ],
              "type": "object"
            }
          },
          "required": [
            "hasChanges",
            "changedComponents",
            "body",
            "comments",
            "styles",
            "numbering"
          ],
          "type": "object"
        },
        "targetFingerprint": {
          "type": "string"
        },
        "version": {
          "const": "sd-diff-payload/v1",
          "type": "string"
        }
      },
      "required": [
        "version",
        "engine",
        "baseFingerprint",
        "targetFingerprint",
        "coverage",
        "summary",
        "payload"
      ],
      "type": "object"
    }
  },
  "required": [
    "diff"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "appliedOperations": {
      "type": "integer"
    },
    "baseFingerprint": {
      "type": "string"
    },
    "coverage": {
      "additionalProperties": false,
      "properties": {
        "body": {
          "const": true,
          "type": "boolean"
        },
        "comments": {
          "type": "boolean"
        },
        "headerFooters": {
          "const": false,
          "type": "boolean"
        },
        "numbering": {
          "type": "boolean"
        },
        "styles": {
          "type": "boolean"
        }
      },
      "required": [
        "body",
        "comments",
        "styles",
        "numbering",
        "headerFooters"
      ],
      "type": "object"
    },
    "diagnostics": {
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "summary": {
      "additionalProperties": false,
      "properties": {
        "body": {
          "additionalProperties": false,
          "properties": {
            "hasChanges": {
              "type": "boolean"
            }
          },
          "required": [
            "hasChanges"
          ],
          "type": "object"
        },
        "changedComponents": {
          "items": {
            "enum": [
              "body",
              "comments",
              "styles",
              "numbering"
            ],
            "type": "string"
          },
          "type": "array"
        },
        "comments": {
          "additionalProperties": false,
          "properties": {
            "hasChanges": {
              "type": "boolean"
            }
          },
          "required": [
            "hasChanges"
          ],
          "type": "object"
        },
        "hasChanges": {
          "type": "boolean"
        },
        "numbering": {
          "additionalProperties": false,
          "properties": {
            "hasChanges": {
              "type": "boolean"
            }
          },
          "required": [
            "hasChanges"
          ],
          "type": "object"
        },
        "styles": {
          "additionalProperties": false,
          "properties": {
            "hasChanges": {
              "type": "boolean"
            }
          },
          "required": [
            "hasChanges"
          ],
          "type": "object"
        }
      },
      "required": [
        "hasChanges",
        "changedComponents",
        "body",
        "comments",
        "styles",
        "numbering"
      ],
      "type": "object"
    },
    "targetFingerprint": {
      "type": "string"
    }
  },
  "required": [
    "appliedOperations",
    "baseFingerprint",
    "targetFingerprint",
    "coverage",
    "summary",
    "diagnostics"
  ],
  "type": "object"
}
{
  "additionalProperties": false,
  "properties": {
    "appliedOperations": {
      "type": "integer"
    },
    "baseFingerprint": {
      "type": "string"
    },
    "coverage": {
      "additionalProperties": false,
      "properties": {
        "body": {
          "const": true,
          "type": "boolean"
        },
        "comments": {
          "type": "boolean"
        },
        "headerFooters": {
          "const": false,
          "type": "boolean"
        },
        "numbering": {
          "type": "boolean"
        },
        "styles": {
          "type": "boolean"
        }
      },
      "required": [
        "body",
        "comments",
        "styles",
        "numbering",
        "headerFooters"
      ],
      "type": "object"
    },
    "diagnostics": {
      "items": {
        "type": "string"
      },
      "type": "array"
    },
    "summary": {
      "additionalProperties": false,
      "properties": {
        "body": {
          "additionalProperties": false,
          "properties": {
            "hasChanges": {
              "type": "boolean"
            }
          },
          "required": [
            "hasChanges"
          ],
          "type": "object"
        },
        "changedComponents": {
          "items": {
            "enum": [
              "body",
              "comments",
              "styles",
              "numbering"
            ],
            "type": "string"
          },
          "type": "array"
        },
        "comments": {
          "additionalProperties": false,
          "properties": {
            "hasChanges": {
              "type": "boolean"
            }
          },
          "required": [
            "hasChanges"
          ],
          "type": "object"
        },
        "hasChanges": {
          "type": "boolean"
        },
        "numbering": {
          "additionalProperties": false,
          "properties": {
            "hasChanges": {
              "type": "boolean"
            }
          },
          "required": [
            "hasChanges"
          ],
          "type": "object"
        },
        "styles": {
          "additionalProperties": false,
          "properties": {
            "hasChanges": {
              "type": "boolean"
            }
          },
          "required": [
            "hasChanges"
          ],
          "type": "object"
        }
      },
      "required": [
        "hasChanges",
        "changedComponents",
        "body",
        "comments",
        "styles",
        "numbering"
      ],
      "type": "object"
    },
    "targetFingerprint": {
      "type": "string"
    }
  },
  "required": [
    "appliedOperations",
    "baseFingerprint",
    "targetFingerprint",
    "coverage",
    "summary",
    "diagnostics"
  ],
  "type": "object"
}
{
  "type": "object"
}