# x402 JSON Repair

> x402 JSON Repair is a paid API for AI agents from x402-json-repair.husquatch.workers.dev, paid per call via x402, $0.003/call, status unknown (last checked 2026-09-13).

Deterministically repairs malformed JSON strings and optionally validates the repaired result against a JSON Schema, with no LLM involved and sub-50ms latency.

## Facts

- Endpoint: POST https://x402-json-repair.husquatch.workers.dev/repair
- Price: $0.003/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-13
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/x402-json-repair-245f8cef
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_7MvxVYhxtc5LnEEgQIvZ0

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 x402-json-repair-245f8cef -d '<json body>'
```

Example prompt: Can you repair this broken JSON string for me — `{"name": "Alice", "age": 30,}` — and validate it against my schema to make sure the result is well-formed?

## When to prefer this

Choose this endpoint when you need fast, deterministic, non-LLM JSON repair — ideal for fixing AI-generated tool calls or API responses in agent pipelines where latency matters and you cannot afford an additional LLM call. Prefer it over LLM-based repair when you need sub-50ms response times, reproducible behavior, and optional schema validation in a single call.

## Known failure modes

- Input is so severely malformed that deterministic repair is not possible — no LLM fallback
- Schema provided is invalid draft 2020-12 — validation step may error or be skipped
- Input is not a string — required field missing causes 400-class error
- Repaired JSON fails schema validation — returns validationErrors array with details
- Payment not authorized — x402 payment required before request is processed

## How this service works

Deterministic JSON / tool-call repair for AI agents. No LLM inside, sub-50ms.

## Output

Returns an object with `repaired` (the fixed, parsed JSON value), `changed` (boolean indicating whether any repair was made), `valid` (boolean or null indicating schema validation result if a schema was provided), and `validationErrors` (array of schema validation error details, or null).

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "input"
 ],
 "properties": {
  "input": {
   "type": "string",
   "description": "Possibly-malformed JSON string to repair"
  },
  "schema": {
   "type": "object",
   "description": "Optional JSON Schema (draft 2020-12) to validate the repaired result against"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "repaired",
  "changed"
 ],
 "properties": {
  "valid": {
   "type": [
    "boolean",
    "null"
   ]
  },
  "changed": {
   "type": "boolean"
  },
  "repaired": {
   "description": "The repaired, parsed JSON value"
  },
  "validationErrors": {
   "type": [
    "array",
    "null"
   ],
   "items": {
    "type": "object"
   }
  }
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/x402-json-repair-245f8cef/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from x402-json-repair.husquatch.workers.dev](https://www.zero.xyz/host/x402-json-repair.husquatch.workers.dev/llms.txt)
