{
  "openapi": "3.1.0",
  "info": {
    "title": "InvokeXML API",
    "version": "1.0.0",
    "description": "Convert invoice JSON to e-invoice XML or base X12 810 004010 EDI; validate XML or supported base-profile EDI. Profiles: Peppol BIS Billing 3.0, XRechnung, ZUGFeRD/Factur-X, FatturaPA, PINT-SG (Singapore), JP PINT (Japan) and DBNAlliance UBL 2.3 and base X12 810 004010 (USA). X12 checks are not trading-partner certification.\n\nEvery plan includes the API. Free: 1 key, 10 requests/min, 5 conversions/month. Starter: 2 keys, 60 requests/min, 1,000 conversions/month. Pro: 10 keys, 300 requests/min, 10,000 conversions/month. Create keys in the dashboard after confirming your email and turning on two-factor authentication. Validation never uses quota, and invalid input (422) is not counted.\n\nBefore your first request: sign up → verify your email → create an API key. You can create an API key only after verifying your email. Two-factor authentication is recommended. The API and website share the same 5 free conversions each month. Only valid conversion results count. After the monthly allowance, prepaid credits are used. Validate calls do not use the conversion quota; they are rate-limited only. Free includes 1 API key and 10 requests per minute per key."
  },
  "externalDocs": {
    "description": "API documentation",
    "url": "https://www.invokexml.com/docs"
  },
  "servers": [
    {
      "url": "https://www.invokexml.com"
    }
  ],
  "security": [
    {
      "apiKey": []
    },
    {
      "bearer": []
    }
  ],
  "tags": [
    {
      "name": "Invoices",
      "description": "Convert and validate e-invoices"
    }
  ],
  "paths": {
    "/api/v1/convert": {
      "post": {
        "operationId": "convertInvoice",
        "tags": [
          "Invoices"
        ],
        "summary": "Convert invoice JSON to e-invoice XML",
        "description": "Only successful conversions count towards the monthly quota; prepaid credits are used after the quota. Base X12 810 004010: profile x12-810, one USD invoice with US addresses, S/Z tax groups and x12 interchange settings. Output uses format x12 and edi, not xml. Unsupported fields fail before quota use. No partner certification, EDI-to-JSON import, PDF, delivery or acknowledgement. See https://www.invokexml.com/usa/docs#x12-810. Before your first request: sign up → verify your email → create an API key. You can create an API key only after verifying your email. Two-factor authentication is recommended. The API and website share the same 5 free conversions each month. Only valid conversion results count. After the monthly allowance, prepaid credits are used. Validate calls do not use the conversion quota; they are rate-limited only. Free includes 1 API key and 10 requests per minute per key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Invoice"
              },
              "examples": {
                "eu_peppol": {
                  "summary": "EU: Peppol BIS Billing 3.0",
                  "value": {
                    "profile": "peppol",
                    "number": "INV-2026-001",
                    "issueDate": "2026-10-01",
                    "dueDate": "2026-10-31",
                    "currency": "EUR",
                    "buyerReference": "PO-1001",
                    "seller": {
                      "name": "Example B.V.",
                      "vatId": "NL123456789B01",
                      "legalId": "12345678",
                      "legalIdScheme": "0106",
                      "endpointId": "NL123456789B01",
                      "endpointScheme": "9944",
                      "address": {
                        "street": "Examplestraat 1",
                        "city": "Amsterdam",
                        "postalCode": "1011 AA",
                        "countryCode": "NL"
                      }
                    },
                    "buyer": {
                      "name": "Example Customer B.V.",
                      "vatId": "NL987654321B01",
                      "endpointId": "NL987654321B01",
                      "endpointScheme": "9944",
                      "address": {
                        "street": "Voorbeeldweg 10",
                        "city": "Rotterdam",
                        "postalCode": "3011 AD",
                        "countryCode": "NL"
                      }
                    },
                    "lines": [
                      {
                        "name": "Consulting",
                        "quantity": 4,
                        "unitCode": "HUR",
                        "unitPrice": 100,
                        "vatCategory": "S",
                        "vatRate": 21
                      }
                    ],
                    "payment": {
                      "meansCode": "58",
                      "iban": "NL91ABNA0417164300"
                    }
                  }
                },
                "us_dbna": {
                  "summary": "USA: DBNAlliance UBL 2.3",
                  "value": {
                    "profile": "us",
                    "number": "INV-2026-001",
                    "issueDate": "2026-10-01",
                    "dueDate": "2026-10-31",
                    "currency": "USD",
                    "seller": {
                      "name": "Liberty Consulting LLC",
                      "legalId": "12-3456789",
                      "address": {
                        "street": "100 Main Street",
                        "city": "Austin",
                        "postalCode": "78701",
                        "countryCode": "US"
                      }
                    },
                    "buyer": {
                      "name": "Hudson Trading Inc.",
                      "address": {
                        "street": "350 Fifth Avenue",
                        "city": "New York",
                        "postalCode": "10118",
                        "countryCode": "US"
                      }
                    },
                    "lines": [
                      {
                        "name": "Consulting",
                        "quantity": 10,
                        "unitCode": "HUR",
                        "unitPrice": 150,
                        "vatCategory": "O"
                      },
                      {
                        "name": "Office supplies",
                        "quantity": 4,
                        "unitCode": "C62",
                        "unitPrice": 25,
                        "vatCategory": "S",
                        "vatRate": 8.25
                      }
                    ],
                    "payment": {
                      "meansCode": "30",
                      "iban": "000123456789"
                    }
                  }
                },
                "sg_pint": {
                  "summary": "Singapore: PINT-SG",
                  "value": {
                    "profile": "pint-sg",
                    "number": "INV-2026-001",
                    "issueDate": "2026-10-01",
                    "dueDate": "2026-10-31",
                    "currency": "SGD",
                    "buyerReference": "PO-778",
                    "seller": {
                      "name": "Lion Consulting Pte. Ltd.",
                      "vatId": "M90312345A",
                      "legalId": "201912345K",
                      "address": {
                        "street": "1 Raffles Place",
                        "city": "Singapore",
                        "postalCode": "048616",
                        "countryCode": "SG"
                      }
                    },
                    "buyer": {
                      "name": "Merlion Trading Pte. Ltd.",
                      "legalId": "201812345M",
                      "address": {
                        "street": "10 Anson Road",
                        "city": "Singapore",
                        "postalCode": "079903",
                        "countryCode": "SG"
                      }
                    },
                    "lines": [
                      {
                        "name": "Consulting",
                        "quantity": 10,
                        "unitCode": "HUR",
                        "unitPrice": 150,
                        "vatCategory": "SR",
                        "vatRate": 9
                      },
                      {
                        "name": "Export freight",
                        "quantity": 1,
                        "unitCode": "C62",
                        "unitPrice": 200,
                        "vatCategory": "ZR",
                        "vatRate": 0
                      }
                    ],
                    "payment": {
                      "meansCode": "30",
                      "iban": "0123456789"
                    }
                  }
                },
                "jp_pint": {
                  "summary": "Japan: JP PINT",
                  "value": {
                    "profile": "jp-pint",
                    "number": "JP-2026-001",
                    "issueDate": "2026-10-01",
                    "dueDate": "2026-10-31",
                    "currency": "JPY",
                    "buyerReference": "PO-4410",
                    "seller": {
                      "name": "Sakura Shoji K.K.",
                      "vatId": "T1234567890123",
                      "address": {
                        "street": "1-1 Marunouchi",
                        "city": "Chiyoda-ku, Tokyo",
                        "postalCode": "100-0005",
                        "countryCode": "JP"
                      }
                    },
                    "buyer": {
                      "name": "Fuji Foods K.K.",
                      "vatId": "T9876543210987",
                      "address": {
                        "street": "2-2 Umeda",
                        "city": "Osaka",
                        "postalCode": "530-0001",
                        "countryCode": "JP"
                      }
                    },
                    "lines": [
                      {
                        "name": "Office supplies",
                        "quantity": 10,
                        "unitCode": "C62",
                        "unitPrice": 1000,
                        "vatCategory": "S",
                        "vatRate": 10
                      },
                      {
                        "name": "Food delivery",
                        "quantity": 5,
                        "unitCode": "C62",
                        "unitPrice": 800,
                        "vatCategory": "AA",
                        "vatRate": 8
                      }
                    ],
                    "payment": {
                      "meansCode": "30",
                      "iban": "0123456789"
                    }
                  }
                },
                "x12": {
                  "summary": "X12 810 004010 base profile (test mode)",
                  "value": {
                    "profile": "x12-810",
                    "number": "INV-X12-001",
                    "issueDate": "2026-11-03",
                    "dueDate": "2026-12-03",
                    "currency": "USD",
                    "orderReference": "PO-40",
                    "x12": {
                      "senderId": "SAMPLE-SENDER",
                      "receiverId": "SAMPLE-RECEIVER",
                      "senderQualifier": "ZZ",
                      "receiverQualifier": "ZZ",
                      "controlNumber": "000000001",
                      "usageIndicator": "T"
                    },
                    "seller": {
                      "name": "Liberty Consulting LLC",
                      "address": {
                        "street": "100 Main Street",
                        "city": "Austin",
                        "postalCode": "78701",
                        "subdivision": "TX",
                        "countryCode": "US"
                      }
                    },
                    "buyer": {
                      "name": "Hudson Trading Inc.",
                      "address": {
                        "street": "350 Fifth Avenue",
                        "city": "New York",
                        "postalCode": "10118",
                        "subdivision": "NY",
                        "countryCode": "US"
                      }
                    },
                    "lines": [
                      {
                        "name": "Consulting",
                        "quantity": "10",
                        "unitCode": "HUR",
                        "unitPrice": "150",
                        "vatCategory": "S",
                        "vatRate": "8.25"
                      }
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Converted",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConvertResult"
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_api_key",
                    "message": "This API key is invalid or has been revoked."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Account needs a confirmed email address (email_unverified)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "Missing or invalid fields (error invalid_input), or the invoice failed the business rules (valid false with a report). Not counted.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/Error"
                    },
                    {
                      "$ref": "#/components/schemas/InvalidInvoice"
                    }
                  ]
                },
                "example": {
                  "error": {
                    "code": "invalid_input",
                    "message": "The invoice data has missing or invalid fields.",
                    "issues": [
                      {
                        "field": "lines.0.unitPrice",
                        "message": "Required"
                      }
                    ]
                  }
                }
              }
            }
          },
          "429": {
            "description": "Per-key rate limit reached (rate_limited) or monthly quota and credits used up (quota_exceeded, convert only)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit is 10 requests per minute per API key."
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/validate": {
      "post": {
        "operationId": "validateXml",
        "tags": [
          "Invoices"
        ],
        "summary": "Validate existing UBL invoice XML",
        "description": "Free: does not use quota. Send raw XML or base X12 810 004010 EDI (max 1 MB), or JSON with xml/edi. X12 checks cover only the supported segments, envelopes, controls and arithmetic, not full-standard or trading-partner certification. Before your first request: sign up → verify your email → create an API key. You can create an API key only after verifying your email. Two-factor authentication is recommended. Validate calls do not consume the shared API/website conversion quota. Free: 1 key, 10 requests per minute per key.",
        "requestBody": {
          "required": true,
          "content": {
            "application/xml": {
              "schema": {
                "type": "string"
              }
            },
            "text/xml": {
              "schema": {
                "type": "string"
              }
            },
            "text/plain": {
              "schema": {
                "type": "string"
              }
            },
            "application/json": {
              "schema": {
                "type": "object",
                "anyOf": [
                  {
                    "required": [
                      "xml"
                    ]
                  },
                  {
                    "required": [
                      "edi"
                    ]
                  }
                ],
                "properties": {
                  "xml": {
                    "type": "string"
                  },
                  "edi": {
                    "type": "string"
                  }
                }
              }
            },
            "application/edi-x12": {
              "schema": {
                "type": "string"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Validation report; check valid and report.findings",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidateResult"
                }
              }
            }
          },
          "400": {
            "description": "No XML in the request body",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_request",
                    "message": "Send the invoice XML as the request body (Content-Type: application/xml) or as {\"xml\": \"...\"}."
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing, invalid or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "invalid_api_key",
                    "message": "This API key is invalid or has been revoked."
                  }
                }
              }
            }
          },
          "403": {
            "description": "Account needs a confirmed email address (email_unverified)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "422": {
            "description": "The XML could not be parsed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidateResult"
                }
              }
            }
          },
          "429": {
            "description": "Per-key rate limit reached (rate_limited). Validation does not consume the conversion quota.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "code": "rate_limited",
                    "message": "Rate limit is 10 requests per minute per API key."
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "API key starting with ixk_. Before your first request: sign up → verify your email → create an API key. You can create an API key only after verifying your email. Two-factor authentication is recommended."
      },
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "Authorization: Bearer ixk_..."
      }
    },
    "schemas": {
      "Address": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "street": {
            "type": "string",
            "maxLength": 200
          },
          "additionalStreet": {
            "type": "string",
            "maxLength": 200
          },
          "city": {
            "type": "string",
            "maxLength": 100
          },
          "postalCode": {
            "type": "string",
            "maxLength": 20
          },
          "subdivision": {
            "type": "string",
            "maxLength": 100
          },
          "countryCode": {
            "type": "string",
            "maxLength": 2,
            "description": "ISO 3166-1 alpha-2"
          }
        }
      },
      "Contact": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 200
          },
          "phone": {
            "type": "string",
            "maxLength": 50
          },
          "email": {
            "type": "string",
            "maxLength": 254
          }
        }
      },
      "Party": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 200
          },
          "tradingName": {
            "type": "string",
            "maxLength": 200
          },
          "vatId": {
            "type": "string",
            "maxLength": 30
          },
          "legalId": {
            "type": "string",
            "maxLength": 100
          },
          "legalIdScheme": {
            "type": "string",
            "maxLength": 10
          },
          "endpointId": {
            "type": "string",
            "maxLength": 100
          },
          "endpointScheme": {
            "type": "string",
            "maxLength": 10
          },
          "address": {
            "$ref": "#/components/schemas/Address"
          },
          "contact": {
            "$ref": "#/components/schemas/Contact"
          }
        }
      },
      "TaxCategory": {
        "type": "string",
        "enum": [
          "S",
          "Z",
          "E",
          "AE",
          "K",
          "G",
          "O",
          "SR",
          "ZR",
          "ES33",
          "ESN33",
          "DS",
          "OS",
          "NG",
          "SRCA-S",
          "SRCA-C",
          "AA"
        ],
        "description": "S, Z, E, AE, K, G, O (EN 16931); SR, ZR, ES33, ESN33, DS, OS, NG, SRCA-S, SRCA-C (PINT-SG); AA (JP PINT reduced rate)."
      },
      "Line": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "maxLength": 50
          },
          "name": {
            "type": "string",
            "maxLength": 200
          },
          "description": {
            "type": "string",
            "maxLength": 1000
          },
          "note": {
            "type": "string",
            "maxLength": 1000
          },
          "sellerItemId": {
            "type": "string",
            "maxLength": 100
          },
          "quantity": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string",
                "pattern": "^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)$"
              }
            ],
            "description": "Decimal as a number or numeric string, at most 6 decimals, absolute value below 1e12."
          },
          "unitCode": {
            "type": "string",
            "maxLength": 3,
            "default": "C62"
          },
          "unitPrice": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string",
                "pattern": "^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)$"
              }
            ],
            "description": "Decimal as a number or numeric string, at most 6 decimals, absolute value below 1e12."
          },
          "baseQuantity": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string",
                "pattern": "^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)$"
              }
            ],
            "description": "Decimal as a number or numeric string, at most 6 decimals, absolute value below 1e12."
          },
          "vatCategory": {
            "allOf": [
              {
                "$ref": "#/components/schemas/TaxCategory"
              }
            ],
            "default": "S"
          },
          "vatRate": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string",
                "pattern": "^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)$"
              }
            ],
            "description": "Decimal as a number or numeric string, at most 6 decimals, absolute value below 1e12."
          }
        },
        "required": [
          "quantity",
          "unitPrice"
        ]
      },
      "VatExemption": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "category": {
            "$ref": "#/components/schemas/TaxCategory"
          },
          "reason": {
            "type": "string",
            "maxLength": 500
          },
          "reasonCode": {
            "type": "string",
            "maxLength": 30
          }
        },
        "required": [
          "category"
        ]
      },
      "Payment": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "meansCode": {
            "type": "string",
            "maxLength": 3,
            "default": "30"
          },
          "iban": {
            "type": "string",
            "maxLength": 40,
            "description": "IBAN or bank account number"
          },
          "bic": {
            "type": "string",
            "maxLength": 11
          },
          "accountName": {
            "type": "string",
            "maxLength": 200
          },
          "paymentReference": {
            "type": "string",
            "maxLength": 140
          }
        }
      },
      "Italy": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "codiceDestinatario": {
            "type": "string",
            "maxLength": 7
          },
          "pec": {
            "type": "string",
            "maxLength": 254
          },
          "regimeFiscale": {
            "type": "string",
            "maxLength": 4
          },
          "progressivoInvio": {
            "type": "string",
            "maxLength": 10
          }
        }
      },
      "Invoice": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "profile": {
            "type": "string",
            "enum": [
              "peppol",
              "xrechnung",
              "facturx",
              "fatturapa",
              "pint-sg",
              "jp-pint",
              "us",
              "x12-810"
            ],
            "default": "peppol",
            "description": "peppol = Peppol BIS Billing 3.0, xrechnung = XRechnung UBL, facturx = ZUGFeRD/Factur-X (CII XML + PDF/A-3), fatturapa = FatturaPA 1.2, pint-sg = Singapore PINT-SG, jp-pint = Japan JP PINT, us = DBNAlliance UBL 2.3."
          },
          "italy": {
            "$ref": "#/components/schemas/Italy"
          },
          "number": {
            "type": "string",
            "maxLength": 100
          },
          "issueDate": {
            "type": "string",
            "maxLength": 10,
            "format": "date",
            "description": "YYYY-MM-DD"
          },
          "dueDate": {
            "type": "string",
            "maxLength": 10,
            "format": "date",
            "description": "YYYY-MM-DD"
          },
          "typeCode": {
            "type": "string",
            "maxLength": 3,
            "default": "380"
          },
          "currency": {
            "type": "string",
            "maxLength": 3,
            "default": "EUR"
          },
          "note": {
            "type": "string",
            "maxLength": 2000
          },
          "buyerReference": {
            "type": "string",
            "maxLength": 200
          },
          "orderReference": {
            "type": "string",
            "maxLength": 200
          },
          "precedingInvoiceNumber": {
            "type": "string",
            "maxLength": 200
          },
          "periodStart": {
            "type": "string",
            "maxLength": 10,
            "format": "date",
            "description": "YYYY-MM-DD"
          },
          "periodEnd": {
            "type": "string",
            "maxLength": 10,
            "format": "date",
            "description": "YYYY-MM-DD"
          },
          "deliveryDate": {
            "type": "string",
            "maxLength": 10,
            "format": "date",
            "description": "YYYY-MM-DD"
          },
          "deliveryCountryCode": {
            "type": "string",
            "maxLength": 2
          },
          "seller": {
            "$ref": "#/components/schemas/Party"
          },
          "buyer": {
            "$ref": "#/components/schemas/Party"
          },
          "lines": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1000,
            "items": {
              "$ref": "#/components/schemas/Line"
            }
          },
          "vatExemptions": {
            "type": "array",
            "maxItems": 10,
            "items": {
              "$ref": "#/components/schemas/VatExemption"
            }
          },
          "payment": {
            "$ref": "#/components/schemas/Payment"
          },
          "paymentTerms": {
            "type": "string",
            "maxLength": 1000
          },
          "prepaidAmount": {
            "oneOf": [
              {
                "type": "number"
              },
              {
                "type": "string",
                "pattern": "^[+-]?(\\d+(\\.\\d*)?|\\.\\d+)$"
              }
            ],
            "description": "Decimal as a number or numeric string, at most 6 decimals, absolute value below 1e12."
          },
          "x12": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "senderId",
              "receiverId",
              "controlNumber"
            ],
            "properties": {
              "senderId": {
                "type": "string",
                "minLength": 2,
                "maxLength": 15
              },
              "receiverId": {
                "type": "string",
                "minLength": 2,
                "maxLength": 15
              },
              "senderQualifier": {
                "type": "string",
                "pattern": "^[A-Z0-9]{2}$",
                "default": "ZZ"
              },
              "receiverQualifier": {
                "type": "string",
                "pattern": "^[A-Z0-9]{2}$",
                "default": "ZZ"
              },
              "controlNumber": {
                "type": "string",
                "pattern": "^(?!000000000)\\d{9}$",
                "description": "Unique nonzero interchange control number; preserve leading zeros."
              },
              "usageIndicator": {
                "type": "string",
                "enum": [
                  "T",
                  "P"
                ],
                "default": "T"
              }
            }
          }
        },
        "required": [
          "seller",
          "buyer",
          "lines"
        ],
        "allOf": [
          {
            "if": {
              "required": [
                "profile"
              ],
              "properties": {
                "profile": {
                  "const": "x12-810"
                }
              }
            },
            "then": {
              "required": [
                "x12"
              ]
            }
          }
        ]
      },
      "Finding": {
        "type": "object",
        "properties": {
          "rule": {
            "type": "string"
          },
          "severity": {
            "type": "string",
            "enum": [
              "error",
              "warning"
            ]
          },
          "field": {
            "type": "string"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "Report": {
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean"
          },
          "errors": {
            "type": "integer"
          },
          "warnings": {
            "type": "integer"
          },
          "findings": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Finding"
            }
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "month": {
            "type": "string",
            "examples": [
              "2026-10"
            ]
          },
          "used": {
            "type": "integer"
          },
          "limit": {
            "type": "integer"
          },
          "credits": {
            "type": "integer"
          }
        }
      },
      "ConvertResult": {
        "type": "object",
        "properties": {
          "valid": {
            "const": true
          },
          "format": {
            "type": "string",
            "enum": [
              "ubl",
              "facturx",
              "fatturapa",
              "x12"
            ]
          },
          "xml": {
            "type": "string"
          },
          "pdf": {
            "type": "string",
            "contentEncoding": "base64",
            "description": "Factur-X PDF/A-3 with the XML embedded; only for profile facturx."
          },
          "totals": {
            "type": "object",
            "properties": {
              "taxExclusive": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "tax": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "payable": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          },
          "report": {
            "$ref": "#/components/schemas/Report"
          },
          "notices": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "edi": {
            "type": "string",
            "description": "X12 810 004010 EDI, only for profile x12-810; replaces xml. Download as .edi (application/edi-x12). Base checks only; not partner certification."
          }
        },
        "required": [
          "valid",
          "totals",
          "report"
        ],
        "oneOf": [
          {
            "required": [
              "xml"
            ],
            "properties": {
              "format": {
                "enum": [
                  "ubl",
                  "facturx",
                  "fatturapa"
                ]
              }
            },
            "not": {
              "required": [
                "edi"
              ]
            }
          },
          {
            "required": [
              "format",
              "edi"
            ],
            "properties": {
              "format": {
                "const": "x12"
              }
            },
            "not": {
              "required": [
                "xml"
              ]
            }
          }
        ]
      },
      "InvalidInvoice": {
        "type": "object",
        "description": "The input parsed but failed the business rules. Not counted against the quota.",
        "properties": {
          "valid": {
            "const": false
          },
          "report": {
            "$ref": "#/components/schemas/Report"
          },
          "notices": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ValidateResult": {
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean"
          },
          "report": {
            "$ref": "#/components/schemas/Report"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string",
                "examples": [
                  "invalid_api_key",
                  "email_unverified",
                  "rate_limited",
                  "quota_exceeded",
                  "invalid_input",
                  "invalid_request"
                ]
              },
              "message": {
                "type": "string"
              },
              "issues": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "field": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
