---
title: "Patch a page (surgical find/replace)"
method: PATCH
path: "/papi/project/{projectId}/pages/{pageSlug}"
tags: ["Pages"]
---

# Patch a page (surgical find/replace)

`PATCH /papi/project/{projectId}/pages/{pageSlug}`

## Request

- Base URL: `https://api.websitepublisher.ai`
- URL: `https://api.websitepublisher.ai/papi/project/{projectId}/pages/{pageSlug}`
- Auth: OAuth 2 (authorization code, authorization URL `https://api.websitepublisher.ai/dapi/oauth/authorize`, token URL `https://api.websitepublisher.ai/dapi/oauth/token`, scopes: `read`, `write`)

Apply targeted find/replace patches without sending full page content. Uses optimistic locking via base_version_hash to prevent conflicts. More efficient than updatePage for small edits.

## Path parameters

- `projectId` integer, required
- `pageSlug` string, required

## Request body

- PagePatch
  - `base_version_hash` string: Optional. Version hash from getPage response. If provided and mismatched, returns 409. If omitted, find/replace handles conflicts naturally.
  - `patches` PatchOperation[], required: Array of patch operations to apply sequentially
    - `operation` 'replace' | 'delete', required: Operation type: 'replace' swaps text, 'delete' removes it
    - `find` string, required: Exact string to find in the page content (must match exactly once)
    - `replace` string: Replacement string (required for replace operation, omit for delete)
  - `patch_summary` string: Brief description of what was changed (stored in version history)

## Response `200`

Patches applied successfully. Returns new version number, version_hash, and count of patches applied.

## Other responses

- `409`: Version conflict — page was modified since base_version_hash. Fetch latest content and retry.
- `422`: Patch failed — find string not found or ambiguous (multiple matches).

---

[API](https://skmtc.dev/websitepublisher/apis/websitepublisher-ai-api.md) · [All operations](https://skmtc.dev/websitepublisher/apis/websitepublisher-ai-api/llms.txt) · [OpenAPI document](https://skmtc.dev/websitepublisher/apis/websitepublisher-ai-api/revisions/e9df1ef10551?raw)
