Repair a JSON value toward a schema using only the coercions the caller declares

$0.005 USDC per call · Developer and security · POST /api/v1/schema-repair · Id schema-repair

Validates a JSON value against a caller-supplied JSON Schema 2020-12 and applies only the coercions you list (for example string-to-integer for "42", trim-strings, enum-case, apply-defaults, drop-additional) when each one strictly reduces the number of schema errors. Every change is returned with its JSON pointer, the rule, the old and new value; every error that remains is returned with its exact path and keyword. Refuses lossy coercions: "007" stays a string, "1,000" and "0x10" are not numbers, integers above 2^53 are not converted. For agents that must fix a model's tool-call arguments without guessing. It never invents values: a missing required property without a schema default stays missing. It does not repair inside oneOf/anyOf branches.

What you get

Cheaper than a model retry and every edit is auditable: nothing is changed that you did not declare.

Call it

Send the JSON body below to https://agents.writerslogic.com/api/v1/schema-repair. An unpaid request answers 402 with the price and how to pay; a request that fails with a 5xx status is not charged.

curl -i -X POST https://agents.writerslogic.com/api/v1/schema-repair \
  -H 'content-type: application/json' \
  -d '{"schema":{"type":"object","required":["id","qty"],"properties":{"id":{"type":"string"},"qty":{"type":"integer","minimum":1},"active":{"type":"boolean"}},"additionalProperties":false},"value":{"id":"007","qty":"3","active":"TRUE"},"coercions":["string-to-integer","string-to-boolean"]}'

Input

FieldTypeRequiredDescription
schemaanyyesThe schema the value must satisfy. Full JSON Schema 2020-12 (local $ref only).
valueanyyesThe JSON value to repair.
coercionsarray<string; one of "string-to-number", "string-to-integer", "string-to-boolean", "number-to-string", "boolean-to-string", "trim-strings", "enum-case", "empty-string-to-null", "null-to-default", "apply-defaults", "drop-additional", "wrap-in-array", "unwrap-single-element-array">; max 13 itemsyesCoercions you allow. Empty means validate only.

Example request body

{
  "schema": {
    "type": "object",
    "required": [
      "id",
      "qty"
    ],
    "properties": {
      "id": {
        "type": "string"
      },
      "qty": {
        "type": "integer",
        "minimum": 1
      },
      "active": {
        "type": "boolean"
      }
    },
    "additionalProperties": false
  },
  "value": {
    "id": "007",
    "qty": "3",
    "active": "TRUE"
  },
  "coercions": [
    "string-to-integer",
    "string-to-boolean"
  ]
}

Result

The response is { "data": ..., "_provenance": ... }. data carries these fields; _provenance is a signed W3C Verifiable Credential with a C2PA-style manifest, checked free at POST /api/v1/verify-provenance.

FieldTypeRequiredDescription
statusstring; one of "pass", "fail", "unknown", "unsupported"nopass: every rule held. fail: a rule was violated (see witnesses). unknown: the input lacks the evidence to decide. unsupported: outside what this engine covers. Missing evidence is never a pass.
repairedanynoThe value after the declared coercions (equal to the input when nothing applied).
changedbooleanno
appliedarray<object>no
remainingarray<object>no
refusedarray<object>no
witnessesarray<object>no
versionsobjectnoEvery semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile).
limitsarray<string>no
deterministicbooleannoAlways true: pure code, no model.

Pay and connect

Available through: x402 (USDC on Base), MCP. MCP clients reach it through the data-contract-kit package.

Machine-readable