Knowledge Centre · Technical
e-Invoice API, JSON & XML Basics
Definition: The MyInvois API is the technical interface LHDN provides for submitting e-Invoices as structured data — in JSON or XML format — rather than as a PDF or image. Software providers like TxBilling connect to this API so business owners don't need to touch it directly.
You don't need to be technical to run a compliant business, but a plain-English understanding of what's happening "under the hood" helps demystify why e-Invoice feels more involved than just emailing a PDF.
Why not just submit a PDF?
A PDF is essentially a picture of text — a computer can't reliably extract the invoice amount, buyer's TIN, or item codes from it without error-prone processing. JSON and XML are structured formats: every piece of data has a clearly labelled field (e.g. "totalAmount": 150.00), so LHDN's MyInvois system can validate it automatically, at scale, in near real-time.
JSON vs XML — do I need to know the difference?
Not really, unless you're a developer. Both are ways of structuring the same underlying invoice data; MyInvois supports both formats for submissions. If you're using software like TxBilling, this is entirely handled for you — you fill in a normal-looking invoice form, and the software converts and submits it correctly behind the scenes.
What "the API" actually does
- Your billing software packages your invoice data into the correct structured format.
- It authenticates with LHDN's MyInvois API (see our related guide on digital signatures).
- It submits the data for validation.
- LHDN's system validates the fields (correct TIN format, valid amounts, etc.) and returns a validated e-Invoice with a unique identifier and QR code, or an error if something's wrong.
- Your software receives that response and shows you the validated e-Invoice, ready to send to your customer.
When this matters directly to you
- Choosing software — knowing that "API integration" means direct, automatic submission (vs manually re-typing into the MyInvois Portal) helps you evaluate why automation saves time.
- Custom/ERP integrations — if you're integrating your own system (e.g. a custom POS or ERP) directly with MyInvois, your developer will need to work with these JSON/XML specifications and LHDN's SDK/documentation directly.
- Troubleshooting errors — if an e-Invoice fails validation, the error usually points to a specific structured field (like an invalid TIN format) rather than a vague "something's wrong."
FAQ
Why is an e-Invoice submitted as JSON or XML instead of a PDF?
JSON and XML are structured formats computers can validate automatically. A PDF is just an image of text, which doesn't support automated, real-time validation of individual fields like amounts and TIN.
Do I need to understand JSON/XML to use e-Invoice?
No — not if you use compliant software or the MyInvois Portal. It becomes relevant mainly if you're building a custom, direct integration.
Can TxBilling connect to my own systems via API?
Yes — TxBilling offers a REST API and middleware for POS/ERP integrations, alongside its own e-Invoice submission to LHDN MyInvois.
Related reading