pagehive

patch_page

Find-and-replace in the draft.

Draft contentChanges dataAll plans

What it does

Find-and-replace in the draft. Edits apply in order, each to one file: template, page_css, css, global_css, script or partial. If any edit fails, nothing is written. By default each find must match exactly once after the earlier edits: no match is find_not_found, more than one is find_ambiguous, and a count other than expect_count is count_mismatch. These errors give the edit index and, when only line endings, whitespace or one space differ, a hint that names match loose. Visitors see the edit after a publish; publish true publishes that draft in the same call, and the response then adds visibility, published_at, last_published_at and, on a private site's first publish, its one-time link (view_link, or review_link when review is on). Each applied edit reports replaced and snippets of a few lines around each replacement (omitted counts those past the cap). files and pages list only what changed (change: created, replaced, or deleted), with draft totals; verbose true lists the whole draft. Page and template reference: https://pagehive.io/docs/bot-guide.md (section Pages and partials).

Plans

Works on every plan: Free, Basic, Pro and Ultra.

Parameters

NameTypeAbout
site_idrequiredstringThe id of the site. list_sites gives the ids of your sites.
pathstringThe page. Top level, next to edits. Required when an edit targets template or page_css; a path on an edit is dropped and the call fails with validation_failed reason path_required.
messagestringA short note for the version history, like a commit message.
verbosebooleantrue lists every file and page of the draft. Otherwise the response lists only what this call changed, plus draft totals.
base_versionintegerWhen set, must equal the current draft version, or the call fails with validation_failed reason version_conflict and the current version.
publishbooleantrue publishes the draft once the edits apply, even with no text change (a new version; last_published_at updates). A failed edit does not publish.
editsrequiredarray of objectsThe find-and-replace edits, applied in order. Each names file, find and replace; a script or partial edit also names it.
idempotency_keystringAny unique string (1-200 printable ASCII). A retry with the same key and arguments returns the first call's result instead of running again. Same as the Idempotency-Key header.

Example

Call patch_page with these arguments:

{
  "site_id": "01a1…",
  "path": "/",
  "edits": [
    {
      "file": "template",
      "find": "<h1>Welcome</h1>",
      "replace": "<h1>Welcome back</h1>"
    }
  ]
}

Ids like 01a1… stand for your own. list_sites and list_tables give you the real ones.

Related guides