edit_document
Preferred way to change an existing document. Unfurl applies exact search/replace edits to the current HTML on the server and stores a new version. The share URL does not change. Use this instead ofpublish_document for small or targeted HTML changes. Maps to POST /api/v1/documents/:id/edit.
Workflow
- Call
get_documentonce withinclude_html: true(defaultversioniscurrent). - For each change, pick the smallest unique snippet of that HTML as
old_string. - Call
edit_documentwith those pairs. Edits apply in order. The batch is atomic — if one edit fails, nothing is saved.
Parameters
Matching is literal (no regex, no whitespace normalisation) against the raw stored HTML.
Returns
JSON includingdocument_id, version_id, share_url, and a summary (edits_applied, replacements, bytes_before, bytes_after, sanitizer_warning).