Edit a doc (snippet patch)
patch_docEdit an existing hosted doc by replacing a snippet of its HTML. DEFAULT TOOL for ANY edit to a doc the user already has — typo, copy change, restyle, new section, anything. ~50 tokens instead of ~7000 for re-hosting. Workflow: (1) if you don't have the current HTML in context, call get_doc_html first to read it. (2) construct before_snippet as a unique chunk of the existing HTML and after_snippet as its replacement. Pass EITHER doc_name (easiest) OR slug. Ambiguous match → fails with context for each candidate. Preserves share link, password, view counts, comments. Patching sends only the changed snippet, so it costs far less than re-sending a whole doc. For several edits at once ("fix the typo AND change the CTA AND update the date") pass a patches array instead of before/after: all of them land atomically or none do, each validated after the previous one applied.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | No | Share-link slug or full URL. Alternative to doc_name. | |
| account | No | Email address of the farm to act on. Omit for the signed-in farm. Only a connected account is accepted; call list_accounts to see which. | |
| patches | No | Several edits applied atomically. Use this OR before_snippet/after_snippet. | |
| doc_name | No | Name of the doc to edit (same name you passed to host_html_content). Use this if you don't have the slug. | |
| after_snippet | No | Replacement text. For a single edit. | |
| before_snippet | No | Exact text to find (must be unique unless occurrence_index given). For a single edit. | |
| occurrence_index | No | 0-based index of which match to replace when before_snippet isn't unique |