# Patch Guard JSON Repair & Canonicalization

> Patch Guard JSON Repair & Canonicalization is a paid API for AI agents from patch-guard-api.me-e51.workers.dev, paid per call via x402, $0.001/call, status unknown (last checked 2026-09-15).

Accepts malformed or valid JSON text and returns repaired JSON, canonicalized (sorted-key) JSON, and a SHA-256 fingerprint of the canonical form.

## Facts

- Endpoint: POST https://patch-guard-api.me-e51.workers.dev/v1/json-repair
- Price: $0.001/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/patch-guard-json-repair-canonicalization-1174d962
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_CyaE867puetPqmW-3HWYC

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability patch-guard-json-repair-canonicalization-1174d962 -d '<json body>'
```

Example prompt: Can you repair and canonicalize this JSON for me? It came from an LLM and might be malformed: '{"name":"Ada","active":true,"score":}'  — I need the fixed version with keys sorted alphabetically and a SHA-256 fingerprint of the canonical form.

## When to prefer this

Choose this endpoint when you need deterministic JSON normalization, deduplication via stable hashing, or repair of LLM-generated or user-supplied malformed JSON. It is purpose-built for agent pipelines that need to canonicalize JSON for cache keys, fingerprint documents, or sanitize untrusted JSON input before parsing. Prefer it over generic JSON validators when you need both repair AND canonical key ordering in a single atomic call.

## Known failure modes

- Input JSON is so severely malformed it cannot be repaired — returns an error or best-effort partial result
- Input exceeds 48 KiB limit — returns a validation error
- Empty string input — rejected by minLength:1 constraint
- Non-string input body — schema validation error
- Payment not included or insufficient — 402 Payment Required response

## How this service works

Four x402-paid agent utilities: safe JSON Patch evaluation, multi-source crypto price consensus, normalized Polymarket movers, and deterministic JSON repair/canonicalization.

## Output

Returns an object containing: the repaired JSON string (repairApplied flag indicates whether changes were made), a canonicalized JSON string with keys sorted deterministically, a SHA-256 hash of the canonical form for fingerprinting, whether the input was already valid JSON, and byte counts for the input, repaired, and canonical forms.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "text": {
   "type": "string",
   "maxLength": 49152,
   "minLength": 1,
   "description": "Valid or repairable JSON text, up to 48 KiB UTF-8."
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "bytes": {
   "input": 28,
   "repaired": 28,
   "canonical": 28
  },
  "repairedJson": "{\"name\":\"Ada\",\"active\":true}",
  "wasValidJson": false,
  "canonicalJson": "{\"active\":true,\"name\":\"Ada\"}",
  "repairApplied": true,
  "canonicalSha256": "sha256:..."
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/patch-guard-json-repair-canonicalization-1174d962/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from patch-guard-api.me-e51.workers.dev](https://www.zero.xyz/host/patch-guard-api.me-e51.workers.dev/llms.txt)
