pagehive

patch_page

Find-and-replace in the draft.

Draft contentChanges dataAll plansUpdated

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. A template or page_css edit may name its own page with path, so one call (at most 40 edits) changes several pages. 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 for template and page_css edits that name none. Top level, next to edits. An edit may name its own page with path instead, so one call can patch several pages. A template or page_css edit with neither 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.
draftstringOptional name of your own draft of this site (lowercase letters, digits and dashes, at most 40), such as "pricing-redesign". Each agent has its own drafts, so other agents' work never mixes into yours; give a name when you might work on this site from more than one chat at once, and use the same name on every read, write and publish of that piece of work. Without it you use your default draft.
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