{"uid":"cap_Tk1mEidwUTQxRDLcMPRT9","slug":"patch-guard-safe-json-patch-evaluation-e06bcd9a","name":"Patch Guard – Safe JSON Patch Evaluation","description":"Four x402-paid agent utilities: safe JSON Patch evaluation, multi-source crypto price consensus, normalized Polymarket movers, and deterministic JSON repair/canonicalization.","url":"https://patch-guard-api.me-e51.workers.dev/v1/patch-guard","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"patch":{"type":"array","items":{"type":"object","required":["op","path"],"properties":{"op":{"enum":["add","remove","replace","move","copy","test"],"type":"string"},"from":{"type":"string","description":"Source pointer for move or copy."},"path":{"type":"string","description":"RFC 6901 JSON Pointer."},"value":{"description":"Value for add, replace, or test."}}},"maxItems":100,"description":"RFC 6902 operations, applied atomically to an isolated clone."},"schema":{"oneOf":[{"type":"object"},{"type":"boolean"}],"description":"Optional bounded JSON Schema subset evaluated against the patched result. References, regex-bearing, combinator, conditional, and unbounded-uniqueness keywords are rejected before billing."},"document":{"description":"The JSON value to patch. Maximum total request size is 64 KiB."},"schemaDraft":{"enum":["4","7","2019-09","2020-12"],"type":"string","default":"2020-12"},"protectedPaths":{"type":"array","items":{"type":"string"},"maxItems":100,"description":"Pointers that the patch may not mutate. Ancestor replacement is blocked too."}}},"responseSchema":{"type":"json","example":{"atomic":true,"limits":{"protectedPaths":1,"patchOperations":3,"schemaErrorsReturned":0},"result":{"profile":{"name":"Ada","role":"writer"},"revision":8},"verdict":"allow","patchValid":true,"violations":[],"schemaValid":true,"inversePatch":[{"op":"test","path":"/revision","value":8},{"op":"replace","path":"/revision","value":7},{"op":"test","path":"/profile/role","value":"writer"},{"op":"replace","path":"/profile/role","value":"reader"}],"resultSha256":"sha256:...","normalizedDiff":[{"op":"test","path":"/revision","value":7},{"op":"replace","path":"/revision","value":8},{"op":"test","path":"/profile/role","value":"reader"},{"op":"replace","path":"/profile/role","value":"writer"}],"originalSha256":"sha256:...","artifactsComplete":true}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.01","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.01/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.01","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_Wkzpl9MykimRnTkrjqEKw","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.01","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Atomically applies RFC 6902 JSON Patch operations to a document, validates the result against an optional JSON Schema, enforces protected-path constraints, and returns a verdict, inverse patch, normalized diff, and SHA-256 hashes.","exampleAgentPrompt":"Apply these three JSON Patch operations — replace /profile/role from 'reader' to 'writer' and increment /revision from 7 to 8 — to this user document, make sure /id and /createdAt are protected and can't be touched, validate the result against this JSON Schema draft 2020-12, and tell me whether to allow or deny the patch plus give me the inverse patch to roll it back.","exampleUseCases":[{"title":"Guard immutable fields during document update","prompt":"I have a config document and a set of JSON Patch operations coming from an untrusted source — can you apply them atomically, but block any patch that tries to touch /tenantId or /createdAt, and tell me if the result is still valid against my schema?"},{"title":"Generate rollback patch before committing change","prompt":"Before we commit this JSON Patch to our database, apply it to the current document and give me the inverse patch so we can roll back instantly if something goes wrong, plus a sha256 of the resulting state."},{"title":"Audit proposed patch for schema compliance","prompt":"A third-party agent wants to mutate our API config object with these RFC 6902 operations — can you run them against the current document using draft 2019-09 schema validation and tell me every violation before we decide whether to allow it?"}],"resultDescription":"Returns a JSON object containing: a verdict ('allow' or 'deny'), patchValid and schemaValid booleans, a violations array listing any protected-path or schema breaches, the patched result document, an inversePatch array to undo the change, a normalizedDiff array, SHA-256 hashes of the original and patched documents, and a limits summary showing operation counts and schema errors.","failureModes":["Request body exceeds 64 KiB — rejected before billing","Patch contains more than 100 operations — rejected","Protected paths list exceeds 100 entries — rejected","Schema uses disallowed keywords (regex, $ref, combinators, conditionals) — rejected before billing","Malformed RFC 6901 JSON Pointer in path or from fields — validation error","Invalid op value outside allowed enum — schema rejection","Test operation fails mid-patch — atomic rollback, patchValid: false returned","Payment not included or insufficient USDC — x402 payment required response"],"whenToPreferThis":"Choose this endpoint when you need to safely evaluate RFC 6902 JSON Patch operations without touching your real data store — especially when protected fields must be enforced, schema conformance of the result must be verified, or you need an automatic inverse patch for rollback. It is preferable to a plain patch library when atomicity guarantees, path protection, and audit artifacts (sha256, normalized diff) are required in a single call.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-14T12:35:35.793Z","isFirstParty":false}