Skip to main content

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 of publish_document for small or targeted HTML changes. Maps to POST /api/v1/documents/:id/edit.

Workflow

  1. Call get_document once with include_html: true (default version is current).
  2. For each change, pick the smallest unique snippet of that HTML as old_string.
  3. Call edit_document with 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 including document_id, version_id, share_url, and a summary (edits_applied, replacements, bytes_before, bytes_after, sanitizer_warning).

Example

Errors

Do not use update_document for HTML changes — that tool only updates title and description.

Updating a document

REST POST /edit