EN
Agent builder tools · x402

json-schema-validate

Validate LLM/agent JSON output against a JSON Schema (2020-12 subset) and auto-repair typical errors: code fences, trailing commas, numbers/booleans as strings, wrong enum case, single value instead of array, null optionals, extra or mis-cased keys, missing defaults. Returns errors, repaired JSON and fixes. POST recommended.

0.001 USDC / call · {atomic} atomic · 1000 atomic

Endpoint

GET|POST https://forge-tools.dentreprise.workers.dev/api/json-schema-validate

Parameters

NameRequiredTypeDescription
schemaRequiredobjectJSON Schema
dataRequiredstringJSON value or string to check
repairOptionalstringtrue (default) / false

Example request (unpaid — expect 402)

curl -sS -D - "https://forge-tools.dentreprise.workers.dev/api/json-schema-validate?schema=%5Bobject+Object%5D&data=%7B%22age%22%3A+%2242%22%7D"

Example 402 challenge

The same object is also sent as a base64 PAYMENT-REQUIRED header. Amounts are atomic USDC units (6 decimals).

{
  "x402Version": 2,
  "error": "Payment required",
  "resource": {
    "url": "https://forge-tools.dentreprise.workers.dev/api/json-schema-validate",
    "description": "Validate LLM/agent JSON output against a JSON Schema (2020-12 subset) and auto-repair typical errors: code fences, trailing commas, numbers/booleans as strings, wrong enum case, single value instead of array, null optionals, extra or mis-cased keys, missing defaults. Returns errors, repaired JSON and fixes. POST recommended.",
    "mimeType": "application/json"
  },
  "accepts": [
    {
      "scheme": "exact",
      "network": "eip155:8453",
      "amount": "1000",
      "asset": "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      "payTo": "0x7B8bf45ac6AcbA6D4CFB626b57D3f5fF3C9C89F7",
      "maxTimeoutSeconds": 120,
      "extra": {
        "name": "USD Coin",
        "version": "2"
      }
    }
  ]
}

Retry with payment

curl -sS "https://forge-tools.dentreprise.workers.dev/api/json-schema-validate?schema=%5Bobject+Object%5D&data=%7B%22age%22%3A+%2242%22%7D" \
  -H "PAYMENT-SIGNATURE: $PAYMENT"

Example response

{
  "valid": false,
  "errors": [
    {
      "path": "$.age",
      "msg": "expected integer, got string"
    }
  ],
  "repaired": {
    "age": 42
  },
  "repaired_valid": true
}

Related endpoints