{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/jithox-com/json-schema/jithox-com-verify-response-schema.json",
  "title": "VerifyResponse",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/jithox-com-openapi.json#/components/schemas/VerifyResponse",
  "type": "object",
  "properties": {
    "ok": {
      "const": true
    },
    "result": {
      "type": "object",
      "properties": {
        "ok": {
          "const": true
        },
        "schema_version": {
          "const": "jx.vat-list-check/v1"
        },
        "registerTier": {
          "type": "boolean",
          "description": "Whether VIES was asked for this request. False when no row was well-formed."
        },
        "rows": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/VatRow"
          }
        },
        "totals": {
          "$ref": "#/$defs/VatTotals"
        },
        "answeredRows": {
          "type": "integer",
          "minimum": 0,
          "description": "valid + invalid: the rows VIES answered. This is what is billed."
        },
        "retry": {
          "type": "object",
          "description": "The rows worth sending again (VIES gave no answer).",
          "properties": {
            "indexes": {
              "type": "array",
              "items": {
                "type": "integer",
                "minimum": 0
              }
            },
            "advice": {
              "type": "string"
            }
          },
          "required": [
            "indexes",
            "advice"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "ok",
        "schema_version",
        "registerTier",
        "rows",
        "totals",
        "answeredRows",
        "retry"
      ],
      "additionalProperties": false
    },
    "source": {
      "type": "object",
      "properties": {
        "register": {
          "const": "EU VIES"
        }
      },
      "required": [
        "register"
      ],
      "additionalProperties": false
    },
    "consultation": {
      "$ref": "#/$defs/Consultation"
    },
    "billing": {
      "$ref": "#/$defs/Billing"
    },
    "pricing": {
      "$ref": "#/$defs/Pricing"
    },
    "limits": {
      "$ref": "#/$defs/Limits"
    }
  },
  "required": [
    "ok",
    "result",
    "source",
    "consultation",
    "billing",
    "pricing",
    "limits"
  ],
  "additionalProperties": false,
  "$defs": {
    "Billing": {
      "type": "object",
      "properties": {
        "charged": {
          "type": "boolean",
          "description": "Whether this request moved credits."
        },
        "credits": {
          "type": "integer",
          "minimum": 0,
          "description": "Credits this delivery cost (1 credit = EUR 0.01)."
        },
        "units": {
          "type": "integer",
          "minimum": 0,
          "description": "Rows VIES answered — what `credits` was computed from."
        },
        "pricePerUnitCredits": {
          "type": "integer",
          "minimum": 0
        },
        "reason": {
          "type": "string"
        },
        "receiptRunId": {
          "type": "string",
          "description": "The id of the credit-ledger booking for this delivery. A reference, not a signed receipt: this route returns no signed or hash-bound receipt, and /plan lists the booking without this id."
        },
        "balanceAfter": {
          "type": "integer",
          "description": "The workspace's credit balance after this charge (the trial credit left, when funding is trial_credit)."
        },
        "funding": {
          "enum": [
            "trial_credit"
          ],
          "description": "Present only when the workspace's one-time free trial credit paid for this delivery. Absent: the prepaid credits paid."
        }
      },
      "required": [
        "charged",
        "credits",
        "units",
        "pricePerUnitCredits",
        "reason"
      ],
      "additionalProperties": false
    },
    "Consultation": {
      "type": "object",
      "description": "Said once per answer, so an absent consultationNumber is never left to be guessed at. The number is the Commission's record of the lookup, not a signed receipt.",
      "properties": {
        "available": {
          "type": "boolean",
          "description": "Whether a `valid` row CAN carry a consultationNumber on this call."
        },
        "reason": {
          "enum": [
            "not_requested",
            "requester_rejected",
            "malformed",
            "not_a_requester_state"
          ],
          "description": "Why not, when not; absent when available. not_requested: no requesterVatId was sent (and none is configured). requester_rejected: the European Commission refused the requesterVatId sent with this call. malformed / not_a_requester_state: the deployment's configured fallback requester cannot be sent."
        },
        "note": {
          "type": "string",
          "description": "One sentence saying exactly what the consultation number is and is not."
        }
      },
      "required": [
        "available",
        "note"
      ],
      "additionalProperties": false
    },
    "Limits": {
      "type": "object",
      "description": "The limits every answer repeats.",
      "properties": {
        "maxRowsPerCall": {
          "type": "integer",
          "minimum": 0
        },
        "maxReferenceChars": {
          "type": "integer",
          "minimum": 0
        },
        "maxVatIdChars": {
          "type": "integer",
          "minimum": 0
        },
        "deadlineMs": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "maxRowsPerCall",
        "maxReferenceChars",
        "maxVatIdChars",
        "deadlineMs"
      ],
      "additionalProperties": false
    },
    "Pricing": {
      "type": "object",
      "properties": {
        "localChecks": {
          "const": "included"
        },
        "registerCheck": {
          "type": "string"
        },
        "unit": {
          "const": "answered_row"
        },
        "pricePerUnitCredits": {
          "type": "integer",
          "minimum": 0
        },
        "pricePerUnitEur": {
          "type": "string"
        },
        "maxCreditsPerCall": {
          "type": "integer",
          "minimum": 0
        },
        "chargedWhen": {
          "type": "string"
        },
        "neverCharged": {
          "type": "string"
        }
      },
      "required": [
        "localChecks",
        "registerCheck",
        "unit",
        "pricePerUnitCredits",
        "pricePerUnitEur",
        "maxCreditsPerCall",
        "chargedWhen",
        "neverCharged"
      ],
      "additionalProperties": false
    },
    "VatRow": {
      "type": "object",
      "properties": {
        "index": {
          "type": "integer",
          "minimum": 0,
          "description": "Position in the request, from 0. Output row i is input row i."
        },
        "reference": {
          "type": [
            "string",
            "null"
          ],
          "description": "Your own label for the row, echoed."
        },
        "input": {
          "type": "string",
          "description": "The number as sent."
        },
        "normalized": {
          "type": [
            "string",
            "null"
          ],
          "description": "Upper case, separators removed; Greek numbers under VIES's prefix EL."
        },
        "countryCode": {
          "type": [
            "string",
            "null"
          ],
          "description": "ISO 3166-1 alpha-2 of the issuing member state."
        },
        "local": {
          "enum": [
            "well_formed",
            "empty",
            "malformed",
            "not_covered",
            "duplicate"
          ],
          "description": "What the free local check found."
        },
        "duplicateOf": {
          "type": "integer",
          "minimum": 0,
          "description": "For a duplicate: the index of the earlier row that carries the answer."
        },
        "register": {
          "enum": [
            "valid",
            "invalid",
            "unknown",
            "not_run"
          ],
          "description": "What the EU register (VIES) said. `unknown` = no answer; never folded into `invalid`."
        },
        "verdict": {
          "enum": [
            "valid",
            "invalid",
            "unavailable",
            "not_checked"
          ],
          "description": "The one word to branch on. valid / invalid: VIES answered (charged). unavailable: VIES was asked and gave no answer — outage, rate limit, time ran out; free; the row is in result.retry.indexes. not_checked: VIES was not asked for this row (malformed, empty, not covered, duplicate); free."
        },
        "registeredName": {
          "type": "string",
          "description": "The name VIES returned. Often absent: several member states never share it."
        },
        "unknownReason": {
          "enum": [
            "rate_limited",
            "no_answer",
            "not_reached",
            "not_authorised",
            "requester_rejected"
          ],
          "description": "Why `unknown`. requester_rejected: the European Commission refused the requesterVatId sent with this call — a refusal about who asked, not about this number; send the row again without requesterVatId."
        },
        "detail": {
          "type": "string",
          "description": "One sentence a bookkeeper can act on."
        },
        "checkedAt": {
          "type": "string",
          "format": "date-time",
          "description": "When VIES answered. Only on valid and invalid."
        },
        "consultationNumber": {
          "type": "string",
          "description": "The European Commission's own consultation number (requestIdentifier) for this lookup. Only on a `valid` row, and only when a requester reached VIES (requesterVatId on this call). It is the Commission's record that this consultation took place at that moment, on the requester's name — not a signed Jithox receipt, and nothing more about the company."
        },
        "consultationRequester": {
          "type": "string",
          "description": "The requester VAT number the Commission recorded this consultation against. Only alongside consultationNumber."
        },
        "consultationAt": {
          "type": "string",
          "format": "date-time",
          "description": "The Commission's own requestDate for the consultation, never our clock. Only alongside consultationNumber, and only when VIES gave one."
        }
      },
      "required": [
        "index",
        "reference",
        "input",
        "normalized",
        "countryCode",
        "local",
        "register",
        "verdict",
        "detail"
      ],
      "additionalProperties": false
    },
    "VatTotals": {
      "type": "object",
      "properties": {
        "rows": {
          "type": "integer",
          "minimum": 0
        },
        "wellFormed": {
          "type": "integer",
          "minimum": 0
        },
        "empty": {
          "type": "integer",
          "minimum": 0
        },
        "malformed": {
          "type": "integer",
          "minimum": 0
        },
        "notCovered": {
          "type": "integer",
          "minimum": 0
        },
        "duplicate": {
          "type": "integer",
          "minimum": 0
        },
        "valid": {
          "type": "integer",
          "minimum": 0
        },
        "invalid": {
          "type": "integer",
          "minimum": 0
        },
        "unknown": {
          "type": "integer",
          "minimum": 0
        },
        "notRun": {
          "type": "integer",
          "minimum": 0
        }
      },
      "required": [
        "rows",
        "wellFormed",
        "empty",
        "malformed",
        "notCovered",
        "duplicate",
        "valid",
        "invalid",
        "unknown",
        "notRun"
      ],
      "additionalProperties": false
    }
  }
}