{
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "request_id": {
      "type": "string",
      "pattern": "^[A-Za-z0-9._:-]{1,128}$"
    },
    "invoice": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
        },
        "supplier_id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$",
          "description": "Caller-declared currency code; this API does not validate legal currency/tax eligibility."
        },
        "minor_digits": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4
        },
        "beneficiary_ref": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "Opaque SHA-256 reference supplied by caller. No bank ownership verification."
        },
        "lines": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "pattern": "^[A-Za-z0-9._:-]{1,128}$"
              },
              "item_ref": {
                "type": "string",
                "pattern": "^[A-Za-z0-9._:-]{1,128}$"
              },
              "quantity": {
                "type": "integer",
                "minimum": 1,
                "maximum": 1000000
              },
              "unit_price_minor": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1000000000000
              },
              "discount_minor": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1000000000000
              },
              "tax_minor": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1000000000000
              }
            },
            "required": [
              "id",
              "item_ref",
              "quantity",
              "unit_price_minor",
              "tax_minor"
            ]
          },
          "minItems": 1,
          "maxItems": 100
        },
        "total_minor": {
          "type": "integer",
          "minimum": 0,
          "maximum": 1000000000000
        }
      },
      "required": [
        "id",
        "supplier_id",
        "currency",
        "minor_digits",
        "lines",
        "total_minor"
      ]
    },
    "purchase_order": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
        },
        "supplier_id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
        },
        "currency": {
          "type": "string",
          "pattern": "^[A-Z]{3}$",
          "description": "Caller-declared currency code; this API does not validate legal currency/tax eligibility."
        },
        "minor_digits": {
          "type": "integer",
          "minimum": 0,
          "maximum": 4
        },
        "lines": {
          "type": "array",
          "items": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "item_ref": {
                "type": "string",
                "pattern": "^[A-Za-z0-9._:-]{1,128}$"
              },
              "quantity": {
                "type": "integer",
                "minimum": 1,
                "maximum": 1000000
              },
              "unit_price_minor": {
                "type": "integer",
                "minimum": 0,
                "maximum": 1000000000000
              }
            },
            "required": [
              "item_ref",
              "quantity",
              "unit_price_minor"
            ]
          },
          "minItems": 0,
          "maxItems": 100
        }
      },
      "required": [
        "id",
        "supplier_id",
        "currency",
        "minor_digits",
        "lines"
      ]
    },
    "receipts": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._:-]{1,128}$"
          },
          "po_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._:-]{1,128}$"
          },
          "supplier_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._:-]{1,128}$"
          },
          "lines": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "properties": {
                "item_ref": {
                  "type": "string",
                  "pattern": "^[A-Za-z0-9._:-]{1,128}$"
                },
                "quantity": {
                  "type": "integer",
                  "minimum": 1,
                  "maximum": 1000000
                }
              },
              "required": [
                "item_ref",
                "quantity"
              ]
            },
            "minItems": 0,
            "maxItems": 100
          }
        },
        "required": [
          "id",
          "po_id",
          "supplier_id",
          "lines"
        ]
      },
      "minItems": 0,
      "maxItems": 20
    },
    "payments": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._:-]{1,128}$"
          },
          "invoice_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._:-]{1,128}$"
          },
          "supplier_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._:-]{1,128}$"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "description": "Caller-declared currency code; this API does not validate legal currency/tax eligibility."
          },
          "minor_digits": {
            "type": "integer",
            "minimum": 0,
            "maximum": 4
          },
          "amount_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "beneficiary_ref": {
            "type": "string",
            "pattern": "^[a-f0-9]{64}$",
            "description": "Opaque SHA-256 reference supplied by caller. No bank ownership verification."
          }
        },
        "required": [
          "id",
          "invoice_id",
          "supplier_id",
          "currency",
          "minor_digits",
          "amount_minor"
        ]
      },
      "minItems": 0,
      "maxItems": 20
    },
    "history": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "invoice_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._:-]{1,128}$"
          },
          "supplier_id": {
            "type": "string",
            "pattern": "^[A-Za-z0-9._:-]{1,128}$"
          },
          "currency": {
            "type": "string",
            "pattern": "^[A-Z]{3}$",
            "description": "Caller-declared currency code; this API does not validate legal currency/tax eligibility."
          },
          "total_minor": {
            "type": "integer",
            "minimum": 0,
            "maximum": 1000000000000
          },
          "minor_digits": {
            "type": "integer",
            "minimum": 0,
            "maximum": 4
          }
        },
        "required": [
          "invoice_id",
          "supplier_id",
          "currency",
          "total_minor",
          "minor_digits"
        ]
      },
      "minItems": 0,
      "maxItems": 100
    },
    "supplier_profile": {
      "type": "object",
      "additionalProperties": false,
      "properties": {
        "supplier_id": {
          "type": "string",
          "pattern": "^[A-Za-z0-9._:-]{1,128}$"
        },
        "approved_beneficiary_ref": {
          "type": "string",
          "pattern": "^[a-f0-9]{64}$",
          "description": "Opaque SHA-256 reference supplied by caller. No bank ownership verification."
        }
      },
      "required": [
        "supplier_id",
        "approved_beneficiary_ref"
      ]
    }
  },
  "required": [
    "request_id",
    "invoice"
  ],
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://xynthera-ai.toasty-seal-8877.chatgpt.site/schemas/invoice-reconcile-request.json",
  "title": "Xynthera Invoice Reconciliation request",
  "description": "64 KiB maximum complete JSON body; nesting depth 20; 4000 input nodes; 100 receipt lines in total across supplied receipts. Those aggregate limits are additionally enforced by core."
}
