So, you've heard the news—Malaysia is going full swing with e-Invoicing through LHDN's MyInvois system. Whether you run your own invoicing platform, have a custom ERP, or just prefer building your own tools (because off-the-shelf ones are boring), this guide is for you.
Here's how to hook up your system to talk to LHDN like a pro, get your invoices approved, and keep everything nice and compliant.
Step 1: Get the Basics in Place
First, let's make sure you're eligible (spoiler: you probably are if you run a business in Malaysia). You'll need:
Step 2: Register for API Access
Once you're in the MyInvois portal:
That's your key to the kingdom.
Step 3: Talk to the API (Authentication Time)
LHDN uses OAuth 2.0, so the first thing your system must do is ask nicely for an access token. Here's how (in plain English and code):
Send this:
POST /api/token Host: sandbox.myinvois.hasil.gov.my Content-Type: application/x-www-form-urlencoded client_id=yourClientID&client_secret=yourClientSecret&grant_type=client_credentials
Get this:
"access_token": "abc123xyz...superlongtoken...",
"expires_in": 3600,
"token_type": "Bearer"
}
Cool. You now have permission to send invoices.
Step 4: Prepare Your Invoice JSON
Your self-developed system now needs to generate invoices in LHDN's specific format. Here's a super-simplified example:
{ "invoiceNumber": "INV-20250311-0001", "invoiceDate": "2025-03-11", "seller": { "tin": "12345678901", "name": "My Cool Company Sdn Bhd" }, "buyer": { "tin": "98765432109", "name": "Awesome Client Berhad" }, "items": [ { "description": "Web Development Services", "quantity": 1, "unitPrice": 2000, "taxAmount": 120 } ], "totalAmount": 2120 }
Important: Make sure your system can generate this JSON from whatever database or form you're using internally.
Step 5: Send It to LHDN
Alright, now let's post that JSON using your access token. Request:
POST /api/v1/e-invoice Authorization: Bearer abc123xyz... Content-Type: application/json
Body: The JSON you created above.
"uuid": "a1b2c3d4-5678-90ef-1234-ghijklmnopqr",
"status": "APPROVED",
"qrCode": "https://myinvois.hasil.gov.my/api/qrcode/a1b2c3d4..."
}
Boom. You've got:
Step 6: Save & Serve
Now, in your system:
If your system handles returns or cancellations, you'll also need to support:
(LHDN has separate API endpoints for those—don't worry, the structure is similar.)
Test First, Go Live Later
Before going live, test in Sandbox mode. LHDN will provide dummy TINs and sample data for you to experiment with. When you're ready, request Production access, switch the URLs and credentials, and you're good to go.
Tech Stack? Your Choice.
Whether your backend is written in:
…as long as it can make HTTP requests and speak JSON, you're golden.
What If You're Not Ready to Code APIs?
LHDN also offers the MyInvois Portal, a web interface for small businesses to manually enter invoices. It's free—but not ideal if you're processing lots of invoices daily.
Wrapping Up
Integrating Malaysia's e-Invoice API isn't rocket science—but it does need careful planning, especially for data structure and error handling. With a bit of work, your system will be fully automated, LHDN-friendly, and future-proof. Need sample code, Postman collections, or JSON templates to get started? Just shout. Let's make tax digital—without the headache.
Need a Hand with the Coding?
Still need help to do programming on this e-Invoice integration? Contact us and we'll help assist you with the development — at a very minimal price, like a freelancer but with the skills of a pro. Whether it's building the API layer, formatting JSON, or handling the LHDN authentication flow, we've got your back. Let's get it done, the smart (and affordable) way.
Comments