Which oneOf / anyOf branch a JSON value matches, or why several or none do

$0.005 USDC per call · Developer and security · POST /api/v1/union-branch · Id union-branch

Evaluates a JSON value against every branch of a oneOf or anyOf in a caller-supplied JSON Schema 2020-12 (or OpenAPI schema converted to it) and reports which branches match, the exact errors of each branch that fails with the JSON pointer of each offending value, the closest branch, and which branch an OpenAPI `discriminator` points to. For agents debugging why a tool or API payload is rejected with 'matches more than one' or 'matches none'. Local $ref only; patterns that risk catastrophic backtracking and unknown keywords are reported as unsupported, never as a match. It does not repair the value.

What you get

A oneOf failure message rarely says which branch you were closest to. Up to 25 branches per $0.005 call.

Call it

Send the JSON body below to https://agents.writerslogic.com/api/v1/union-branch. 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/union-branch \
  -H 'content-type: application/json' \
  -d '{"schema":{"oneOf":[{"type":"object","required":["card"],"properties":{"card":{"type":"string"}}},{"type":"object","required":["iban"],"properties":{"iban":{"type":"string"}}}]},"value":{"card":"4111","iban":"DE89"}}'

Input

FieldTypeRequiredDescription
schemaanyyesThe root schema; $ref targets are resolved inside it. Full JSON Schema 2020-12 (local $ref only).
valueanyyesThe JSON value to classify.
atstring; length 0..500noJSON pointer to the subschema holding the union ("" for the root, "/properties/pet" for a nested one).
keywordstring; one of "oneOf", "anyOf"noRequired only when the subschema has both.

Example request body

{
  "schema": {
    "oneOf": [
      {
        "type": "object",
        "required": [
          "card"
        ],
        "properties": {
          "card": {
            "type": "string"
          }
        }
      },
      {
        "type": "object",
        "required": [
          "iban"
        ],
        "properties": {
          "iban": {
            "type": "string"
          }
        }
      }
    ]
  },
  "value": {
    "card": "4111",
    "iban": "DE89"
  }
}

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.
keywordstringno
atstringno
branchesarray<object>no
matchedIndexesarray<integer>no
closestBranchone ofno
discriminatorone ofno
siblingsstring; one of "match", "no-match", "unknown", "none"noResult of the keywords next to the union (everything except the union keyword).
explanationstringno
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