{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/medianfi-com/json-schema/medianfi-com-accountant-document-unmatch-response-schema.json",
  "title": "AccountantDocumentUnmatchResponse",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/medianfi-com-accountant-documents-api-openapi.yml#/components/schemas/AccountantDocumentUnmatchResponse",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "success",
    "data"
  ],
  "properties": {
    "success": {
      "type": "boolean"
    },
    "data": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "match",
        "document",
        "replacementJeId",
        "voidedJeId",
        "affectedTransactionIds"
      ],
      "properties": {
        "match": {
          "$ref": "#/$defs/AccountantDocumentMatch"
        },
        "document": {
          "oneOf": [
            {
              "$ref": "#/$defs/Document"
            },
            {
              "type": "null"
            }
          ]
        },
        "replacementJeId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "voidedJeId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "affectedTransactionIds": {
          "type": "array",
          "items": {
            "type": "string",
            "format": "uuid"
          }
        }
      }
    }
  },
  "$defs": {
    "AccountantDocumentMatch": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "documentId",
        "transactionId",
        "status",
        "method",
        "confidence",
        "amountCents",
        "currency",
        "minorUnitExponent"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "documentId": {
          "type": "string",
          "format": "uuid"
        },
        "transactionId": {
          "type": "string",
          "format": "uuid"
        },
        "status": {
          "type": "string",
          "enum": [
            "proposed",
            "applied",
            "rejected"
          ]
        },
        "method": {
          "type": [
            "string",
            "null"
          ]
        },
        "confidence": {
          "type": [
            "number",
            "null"
          ]
        },
        "amountCents": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 1,
          "maximum": 9007199254740991
        },
        "currency": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[A-Z]{3}$"
        },
        "minorUnitExponent": {
          "type": [
            "integer",
            "null"
          ],
          "enum": [
            2,
            null
          ]
        }
      },
      "oneOf": [
        {
          "properties": {
            "amountCents": {
              "type": "integer",
              "minimum": 1,
              "maximum": 9007199254740991
            },
            "currency": {
              "type": "string",
              "pattern": "^[A-Z]{3}$"
            },
            "minorUnitExponent": {
              "type": "integer",
              "const": 2
            }
          }
        },
        {
          "properties": {
            "status": {
              "type": "string",
              "enum": [
                "proposed",
                "rejected"
              ]
            },
            "amountCents": {
              "type": "null"
            },
            "currency": {
              "type": "null"
            },
            "minorUnitExponent": {
              "type": "null"
            }
          }
        }
      ]
    },
    "Document": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "id",
        "entityId",
        "type",
        "status",
        "name",
        "vendorName",
        "customerName",
        "invoiceNumber",
        "amountCents",
        "amountPaidCents",
        "outstandingAmountCents",
        "currency",
        "minorUnitExponent",
        "uploadedAt",
        "dueDate",
        "sizeBytes",
        "transactionId",
        "category",
        "docDate",
        "paymentStatus",
        "sourceProvider",
        "sourceRefs",
        "externalViewUrl",
        "hasProposedMatch",
        "possibleDuplicateOf"
      ],
      "properties": {
        "id": {
          "type": "string",
          "format": "uuid"
        },
        "entityId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "type": {
          "type": "string",
          "enum": [
            "invoice",
            "bill",
            "receipt",
            "contract",
            "statement"
          ]
        },
        "status": {
          "type": "string",
          "enum": [
            "needs_review",
            "reviewed",
            "processed",
            "archived"
          ]
        },
        "name": {
          "type": "string"
        },
        "vendorName": {
          "type": [
            "string",
            "null"
          ]
        },
        "customerName": {
          "type": [
            "string",
            "null"
          ]
        },
        "invoiceNumber": {
          "type": [
            "string",
            "null"
          ]
        },
        "amountCents": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Document total in the persisted currency's authoritative minor units; null only for true-empty intake."
        },
        "amountPaidCents": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Server-owned sum of applied, same-entity, same-currency payment matches; null with a true-empty document amount."
        },
        "outstandingAmountCents": {
          "type": [
            "integer",
            "null"
          ],
          "minimum": 0,
          "maximum": 9007199254740991,
          "description": "Exact amountCents minus amountPaidCents; null with a true-empty document amount."
        },
        "currency": {
          "type": [
            "string",
            "null"
          ],
          "pattern": "^[A-Z]{3}$",
          "description": "Certified ISO 4217 currency; null only for true-empty document money."
        },
        "minorUnitExponent": {
          "type": [
            "integer",
            "null"
          ],
          "enum": [
            2,
            null
          ],
          "description": "Public scale authority for every non-null document amount."
        },
        "paymentStatus": {
          "type": [
            "string",
            "null"
          ],
          "enum": [
            "open",
            "partial",
            "paid",
            null
          ],
          "description": "Server-owned bill rollup status; null for non-bills."
        },
        "uploadedAt": {
          "type": "string",
          "format": "date-time"
        },
        "dueDate": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "sizeBytes": {
          "type": [
            "integer",
            "null"
          ]
        },
        "transactionId": {
          "type": [
            "string",
            "null"
          ],
          "format": "uuid"
        },
        "category": {
          "type": [
            "string",
            "null"
          ]
        },
        "docDate": {
          "type": [
            "string",
            "null"
          ],
          "format": "date"
        },
        "sourceProvider": {
          "type": [
            "string",
            "null"
          ]
        },
        "sourceRefs": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "type",
              "id",
              "label"
            ],
            "properties": {
              "type": {
                "type": "string"
              },
              "id": {
                "type": "string"
              },
              "label": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        },
        "externalViewUrl": {
          "type": [
            "string",
            "null"
          ]
        },
        "hasProposedMatch": {
          "type": "boolean",
          "description": "Derived. True when the engine has a proposed (not yet applied) match for this document. Drives the feed's \"Review match\" call-to-action."
        },
        "possibleDuplicateOf": {
          "type": [
            "object",
            "null"
          ],
          "additionalProperties": false,
          "required": [
            "id",
            "name"
          ],
          "description": "Derived on the documents list only; null on every other response. The earliest-created live document of the same company, entity and type with the same counterparty (vendor, or customer when there is no vendor), invoice number, document date and amount. Null when this document is that earliest one, has no such twin, or is missing any of the four fields. A marker only: both documents stay listed.",
          "properties": {
            "id": {
              "type": "string",
              "format": "uuid"
            },
            "name": {
              "type": "string"
            }
          }
        },
        "downloadUrl": {
          "type": "string",
          "description": "Optional short-lived signed download authority when a file is available to the authenticated actor."
        }
      }
    }
  }
}