{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/valinvo-bmk-hub-com/json-schema/valinvo-bmk-hub-com-create-invoice-request-schema.json",
  "title": "CreateInvoiceRequest",
  "x-generated": "2026-12-02",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/valinvo-bmk-hub-com-openapi.json#/components/schemas/CreateInvoiceRequest",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "format",
    "invoice"
  ],
  "properties": {
    "format": {
      "type": "string",
      "enum": [
        "xrechnung-ubl",
        "xrechnung-cii",
        "peppol-bis-ubl",
        "zugferd-en16931",
        "factur-x-fr",
        "cii-fr",
        "ubl-fr"
      ],
      "description": "Format ID from `GET /v1/formats`. `zugferd-en16931` returns a PDF/A-3 with the CII XML embedded (ZUGFeRD 2.5.2 / Factur-X 1.09.2, EN 16931 profile)."
    },
    "invoice": {
      "$ref": "#/$defs/Invoice"
    }
  },
  "$defs": {
    "Address": {
      "type": "object",
      "additionalProperties": false,
      "description": "BG-5 / BG-8 Postal address.",
      "required": [
        "countryCode"
      ],
      "properties": {
        "line1": {
          "type": "string",
          "description": "BT-35 / BT-50"
        },
        "line2": {
          "type": "string",
          "description": "BT-36 / BT-51"
        },
        "line3": {
          "type": "string",
          "description": "BT-162 / BT-163"
        },
        "city": {
          "type": "string",
          "description": "BT-37 / BT-52"
        },
        "postalCode": {
          "type": "string",
          "description": "BT-38 / BT-53"
        },
        "region": {
          "type": "string",
          "description": "BT-39 / BT-54"
        },
        "countryCode": {
          "type": "string",
          "description": "BT-40 / BT-55, ISO 3166-1 alpha-2."
        }
      }
    },
    "CodedNote": {
      "type": "object",
      "additionalProperties": false,
      "description": "BG-1 An invoice note with its subject code.",
      "required": [
        "code",
        "text"
      ],
      "properties": {
        "code": {
          "type": "string",
          "description": "BT-21 UNTDID 4451 subject code, e.g. PMT, PMD, AAB, REG."
        },
        "text": {
          "type": "string",
          "description": "BT-22"
        }
      }
    },
    "Contact": {
      "type": "object",
      "additionalProperties": false,
      "description": "BG-6 / BG-9 Contact.",
      "properties": {
        "name": {
          "type": "string",
          "description": "BT-41 / BT-56"
        },
        "phone": {
          "type": "string",
          "description": "BT-42 / BT-57"
        },
        "email": {
          "type": "string",
          "description": "BT-43 / BT-58"
        }
      }
    },
    "Decimal": {
      "type": "string",
      "pattern": "^-?\\d+(\\.\\d+)?$",
      "description": "Money, quantity or rate as a JSON string in plain decimal notation, e.g. `\"19.99\"`. No exponent, thousands separator or leading `+`."
    },
    "Delivery": {
      "type": "object",
      "additionalProperties": false,
      "description": "BG-13 Delivery information.",
      "properties": {
        "date": {
          "$ref": "#/$defs/IsoDate"
        }
      }
    },
    "DocumentAllowanceCharge": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "amount",
        "vat"
      ],
      "properties": {
        "amount": {
          "$ref": "#/$defs/Decimal"
        },
        "reason": {
          "type": "string",
          "description": "BT-97 / BT-104"
        },
        "reasonCode": {
          "type": "string",
          "description": "BT-98 / BT-105"
        },
        "vat": {
          "$ref": "#/$defs/VatInfo"
        }
      }
    },
    "ElectronicAddress": {
      "type": "object",
      "additionalProperties": false,
      "description": "BT-34 / BT-49 Electronic address. XRechnung accepts email (`EM`); Peppol needs a Peppol scheme.",
      "required": [
        "scheme",
        "value"
      ],
      "properties": {
        "scheme": {
          "type": "string",
          "description": "EAS code, e.g. `EM` (email), `0208` (BE enterprise number), `9930` (DE VAT)."
        },
        "value": {
          "type": "string"
        }
      }
    },
    "Identifier": {
      "type": "object",
      "additionalProperties": false,
      "description": "BT-30 / BT-47 Legal registration identifier.",
      "required": [
        "id"
      ],
      "properties": {
        "id": {
          "type": "string"
        },
        "scheme": {
          "type": "string",
          "description": "ISO 6523 ICD, e.g. `0208`."
        }
      }
    },
    "Invoice": {
      "type": "object",
      "additionalProperties": false,
      "description": "The canonical invoice. Every field maps to an EN 16931 business term (BT) or group (BG). Unknown fields are rejected.",
      "required": [
        "number",
        "issueDate",
        "currency",
        "seller",
        "buyer",
        "lines"
      ],
      "properties": {
        "number": {
          "type": "string",
          "description": "BT-1 Invoice number."
        },
        "type": {
          "$ref": "#/$defs/InvoiceType"
        },
        "issueDate": {
          "$ref": "#/$defs/IsoDate"
        },
        "dueDate": {
          "$ref": "#/$defs/IsoDate"
        },
        "taxPointDate": {
          "$ref": "#/$defs/IsoDate"
        },
        "currency": {
          "type": "string",
          "description": "BT-5 Invoice currency, ISO 4217, e.g. `EUR`."
        },
        "buyerReference": {
          "type": "string",
          "description": "BT-10 Buyer reference; the Leitweg-ID for German public buyers."
        },
        "orderReference": {
          "type": "string",
          "description": "BT-13 Purchase order reference."
        },
        "contractReference": {
          "type": "string",
          "description": "BT-12 Contract reference."
        },
        "precedingInvoice": {
          "$ref": "#/$defs/InvoiceReference"
        },
        "notes": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "BT-22 Invoice notes."
        },
        "codedNotes": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/CodedNote"
          },
          "description": "BG-1 notes with a subject code (BT-21 + BT-22). French invoices need PMT, PMD and AAB."
        },
        "billingFrame": {
          "type": "string",
          "description": "BT-23 for formats that let you set it (`factur-x-fr`): the French cadre de facturation B1 (goods), S1 (services), M1 (mixed), B2/S2/M2 (the same, already paid). Other formats reject it."
        },
        "delivery": {
          "$ref": "#/$defs/Delivery"
        },
        "billingPeriod": {
          "$ref": "#/$defs/Period"
        },
        "seller": {
          "$ref": "#/$defs/Party"
        },
        "buyer": {
          "$ref": "#/$defs/Party"
        },
        "payment": {
          "$ref": "#/$defs/Payment"
        },
        "lines": {
          "type": "array",
          "minItems": 1,
          "maxItems": 2000,
          "items": {
            "$ref": "#/$defs/InvoiceLine"
          },
          "description": "BG-25 Invoice lines."
        },
        "allowances": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DocumentAllowanceCharge"
          },
          "description": "BG-20 Document level allowances."
        },
        "charges": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DocumentAllowanceCharge"
          },
          "description": "BG-21 Document level charges."
        },
        "vatExemptions": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/VatExemption"
          },
          "description": "BT-120 / BT-121, one entry per exempt VAT category used."
        },
        "prepaidAmount": {
          "$ref": "#/$defs/Decimal"
        },
        "taxCurrency": {
          "$ref": "#/$defs/TaxCurrency"
        },
        "totals": {
          "$ref": "#/$defs/Totals"
        }
      }
    },
    "InvoiceLine": {
      "type": "object",
      "additionalProperties": false,
      "description": "BG-25 Invoice line. Line totals are calculated by us.",
      "required": [
        "id",
        "name",
        "quantity",
        "unitCode",
        "unitPrice",
        "vat"
      ],
      "properties": {
        "id": {
          "type": "string",
          "description": "BT-126"
        },
        "name": {
          "type": "string",
          "description": "BT-153 Item name."
        },
        "description": {
          "type": "string",
          "description": "BT-154"
        },
        "sellerItemId": {
          "type": "string",
          "description": "BT-155"
        },
        "note": {
          "type": "string",
          "description": "BT-127"
        },
        "quantity": {
          "$ref": "#/$defs/Decimal"
        },
        "unitCode": {
          "type": "string",
          "description": "BT-130, UN/ECE Rec 20, e.g. `C62` piece, `HUR` hour."
        },
        "unitPrice": {
          "$ref": "#/$defs/Decimal"
        },
        "priceBaseQuantity": {
          "$ref": "#/$defs/Decimal"
        },
        "vat": {
          "$ref": "#/$defs/VatInfo"
        },
        "allowances": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/LineAllowanceCharge"
          },
          "description": "BG-27"
        },
        "charges": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/LineAllowanceCharge"
          },
          "description": "BG-28"
        },
        "period": {
          "$ref": "#/$defs/Period"
        }
      }
    },
    "InvoiceReference": {
      "type": "object",
      "additionalProperties": false,
      "description": "BG-3 Preceding invoice reference.",
      "required": [
        "number"
      ],
      "properties": {
        "number": {
          "type": "string",
          "description": "BT-25"
        },
        "issueDate": {
          "$ref": "#/$defs/IsoDate"
        }
      }
    },
    "InvoiceType": {
      "type": "string",
      "enum": [
        "invoice",
        "credit_note",
        "prepayment_invoice"
      ],
      "default": "invoice",
      "description": "BT-3: `invoice` (380), `credit_note` (381) or `prepayment_invoice` (386, down payment; every format except XRechnung, which forbids it: BR-DE-17)."
    },
    "IsoDate": {
      "type": "string",
      "format": "date",
      "description": "Calendar date `YYYY-MM-DD`."
    },
    "LineAllowanceCharge": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "amount"
      ],
      "properties": {
        "amount": {
          "$ref": "#/$defs/Decimal"
        },
        "reason": {
          "type": "string",
          "description": "BT-139 / BT-144"
        },
        "reasonCode": {
          "type": "string",
          "description": "BT-140 / BT-145"
        }
      }
    },
    "Party": {
      "type": "object",
      "additionalProperties": false,
      "description": "Seller (BG-4) or buyer (BG-7).",
      "required": [
        "name",
        "address"
      ],
      "properties": {
        "name": {
          "type": "string",
          "description": "BT-27 / BT-44"
        },
        "tradingName": {
          "type": "string",
          "description": "BT-28 / BT-45"
        },
        "legalRegistrationId": {
          "$ref": "#/$defs/Identifier"
        },
        "vatId": {
          "type": "string",
          "description": "BT-31 / BT-48 VAT identifier with country prefix."
        },
        "taxRegistrationId": {
          "type": "string",
          "description": "BT-32, seller only."
        },
        "additionalLegalInfo": {
          "type": "string",
          "description": "BT-33, seller only, e.g. legal form and share capital."
        },
        "electronicAddress": {
          "$ref": "#/$defs/ElectronicAddress"
        },
        "address": {
          "$ref": "#/$defs/Address"
        },
        "contact": {
          "$ref": "#/$defs/Contact"
        }
      }
    },
    "Payment": {
      "type": "object",
      "additionalProperties": false,
      "description": "BG-16 Payment instructions and BT-20 payment terms.",
      "required": [
        "meansCode"
      ],
      "properties": {
        "meansCode": {
          "type": "string",
          "description": "BT-81, UNTDID 4461, e.g. `58` SEPA credit transfer."
        },
        "meansText": {
          "type": "string",
          "description": "BT-82"
        },
        "remittanceInformation": {
          "type": "string",
          "description": "BT-83"
        },
        "iban": {
          "type": "string",
          "description": "BT-84"
        },
        "accountName": {
          "type": "string",
          "description": "BT-85"
        },
        "bic": {
          "type": "string",
          "description": "BT-86"
        },
        "terms": {
          "type": "string",
          "description": "BT-20 Payment terms."
        }
      }
    },
    "Period": {
      "type": "object",
      "additionalProperties": false,
      "description": "BG-14 invoicing period or BG-26 line period.",
      "properties": {
        "start": {
          "$ref": "#/$defs/IsoDate"
        },
        "end": {
          "$ref": "#/$defs/IsoDate"
        }
      }
    },
    "TaxCurrency": {
      "type": "object",
      "additionalProperties": false,
      "description": "BT-6 + BT-111: the VAT total in the VAT accounting currency, as your accounting converted it (we never choose an exchange rate). France requires EUR when the invoice currency isn't EUR.",
      "required": [
        "code",
        "vatTotal"
      ],
      "properties": {
        "code": {
          "type": "string",
          "description": "BT-6 ISO 4217"
        },
        "vatTotal": {
          "$ref": "#/$defs/Decimal"
        }
      }
    },
    "Totals": {
      "type": "object",
      "additionalProperties": false,
      "description": "BG-22, optional. We calculate the totals; every value you send must match our calculation.",
      "properties": {
        "lineTotal": {
          "$ref": "#/$defs/Decimal"
        },
        "allowanceTotal": {
          "$ref": "#/$defs/Decimal"
        },
        "chargeTotal": {
          "$ref": "#/$defs/Decimal"
        },
        "taxExclusive": {
          "$ref": "#/$defs/Decimal"
        },
        "vatTotal": {
          "$ref": "#/$defs/Decimal"
        },
        "taxInclusive": {
          "$ref": "#/$defs/Decimal"
        },
        "amountDue": {
          "$ref": "#/$defs/Decimal"
        }
      }
    },
    "VatCategory": {
      "type": "string",
      "enum": [
        "S",
        "Z",
        "E",
        "AE",
        "K",
        "G",
        "O",
        "L",
        "M"
      ],
      "description": "UNTDID 5305: `S` standard, `Z` zero rated, `E` exempt, `AE` reverse charge, `K` intra-community supply, `G` export outside the EU, `O` not subject to VAT, `L` Canary Islands IGIC, `M` Ceuta and Melilla IPSI."
    },
    "VatExemption": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "category"
      ],
      "properties": {
        "category": {
          "$ref": "#/$defs/VatCategory"
        },
        "reason": {
          "type": "string",
          "description": "BT-120"
        },
        "reasonCode": {
          "type": "string",
          "description": "BT-121, VATEX code."
        }
      }
    },
    "VatInfo": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "category"
      ],
      "properties": {
        "category": {
          "$ref": "#/$defs/VatCategory"
        },
        "rate": {
          "$ref": "#/$defs/Decimal"
        }
      }
    }
  }
}