Skip to main content
Read a JSON Patch operations array from a file and apply it to the current draft of a page in the active workspace. The patch creates a new draft version; the live site is unchanged until you run gavai publish. This guide covers the synopsis, the input file format, and the exit codes you should branch on in CI.

Synopsis

gavai patch <id> --ops <patches.json>

Arguments

Flags

Run gavai patch --help for the authoritative flag list. The CLI is the source of truth.

Behavior

The command reads the file you pass to --ops, validates it as a JSON Patch array, and sends PATCH /v1/workspaces/{slug}/pages/{id} with the operations as the request body. Each operation follows RFC 6902 — an op (e.g. replace, add, remove), a JSON Pointer path into the page document, and (where applicable) a value. The server applies operations atomically. If any operation fails — invalid pointer, schema violation, conflict with a concurrent edit — the entire patch is rejected with exit code 6 and the draft is left unchanged.

Example

A patches.json that retitles a hero headline and toggles a feature flag:
patches.json
[
  {
    "op": "replace",
    "path": "/tree/children/0/props/headline",
    "value": "Welcome to Acme"
  },
  {
    "op": "add",
    "path": "/metadata/flags/show_pricing",
    "value": true
  }
]
Apply it:
gavai patch page_01HXR8K2M4 --ops patches.json
Run gavai get <id> > page.json first to inspect the block tree and compute the right JSON Pointer paths before writing the ops file. Pointer mistakes are the most common cause of a rejected patch.

Exit codes

See CLI overview — exit codes for the full table.