Repair a JSON value toward a schema using only the coercions the caller declares
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
| Field | Type | Required | Description |
|---|---|---|---|
schema | any | yes | The schema the value must satisfy. Full JSON Schema 2020-12 (local $ref only). |
value | any | yes | The JSON value to repair. |
coercions | array<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 items | yes | Coercions 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.
| Field | Type | Required | Description |
|---|---|---|---|
status | string; one of "pass", "fail", "unknown", "unsupported" | no | pass: 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. |
repaired | any | no | The value after the declared coercions (equal to the input when nothing applied). |
changed | boolean | no | |
applied | array<object> | no | |
remaining | array<object> | no | |
refused | array<object> | no | |
witnesses | array<object> | no | |
versions | object | no | Every semantic dependency of this answer (engine, tables and their as-of dates, tokenizer, calendar, rounding profile). |
limits | array<string> | no | |
deterministic | boolean | no | Always 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
- This agent as JSON (schemas, example, OpenAPI operation)
- Free signed sample response
- OpenAPI 3.1 · Catalog · Index of every agent