Laravel Developer Guide • Malaysia e-Invoice

MyInvois API Integration in Laravel

Laravel MyInvois API integration lets Malaysian businesses connect a Laravel application, ERP, POS or accounting workflow to LHDN e-Invoice services through the MySyncTax REST API. This guide focuses on a practical server-side implementation using Laravel's HTTP client, protected API credentials, structured JSON requests and clear response handling. You will see how to authenticate with MySyncTax, submit invoice data, store the returned UUID or QR information, handle HTTP errors such as 401 and 409, and extend the same integration pattern to ERP customer invoices and related e-Invoice workflows. The examples are written for developers who want a maintainable Laravel integration without repeating keywords unnaturally or exposing production credentials in application code.

✓ Laravel HTTP Client ✓ JSON API ✓ MyInvois / LHDN ✓ Updated 25 Sep 2026
app/Services/MySyncTaxService.php
// Laravel → MySyncTax → LHDN MyInvois

$response = Http::acceptJson()

    ->asJson()

    ->post(

        config('services.mysynctax.url')

        . '/v5/api/myinvois',

        [

            'mysynctax_key' => config(

                'services.mysynctax.key'

            ),

            'mysynctax_secret' => config(

                'services.mysynctax.secret'

            ),

            'invoice_no' => 'INV-1001',

            'sale_id_integrate' => 1001,

            'payment_note_term' => 'CASH',

            'items' => $items,

        ]

    );
Overview

What Is MyInvois API Integration in Laravel?

A Laravel MyInvois integration connects your application, ERP, POS, accounting platform or custom business system to an e-Invoice API. With MySyncTax, Laravel sends structured JSON to MySyncTax and receives submission results that can be stored back in your application.

Laravel Application Invoice, customer and item data
MySyncTax API Authentication, processing and integration layer
LHDN MyInvois e-Invoice submission and document result
Documentation basis: MySyncTax's developer documentation states that integration requests use mysynctax_key and mysynctax_secret in the JSON body. The standard invoice endpoint shown in the documentation is POST https://mysynctax.com/v5/api/myinvois.
Before coding

Laravel MyInvois API Integration Requirements

Keep the integration server-side and separate credentials from your application source code.

Laravel

🧩 Laravel Application

A Laravel project that can make outbound HTTPS requests using Laravel's HTTP client.

Credentials

🔑 MySyncTax API Access

Your assigned mysynctax_key and mysynctax_secret. Keep both values private.

Data

🧾 Invoice Payload

Invoice number, internal sale ID, payment term and item-level information formatted as JSON.

Storage

💾 Response Fields

Plan database fields for the MySyncTax UUID, QR URL, submission status and any returned LHDN identifiers.

Security: never place mysynctax_secret in JavaScript, a public Git repository, HTML, or a mobile app bundle. Keep the MyInvois integration on your Laravel backend.
Implementation

Laravel MyInvois Authentication and HTTP Client Setup

The examples below use Laravel's built-in HTTP client so you do not need a separate HTTP package for the basic integration.

1

Store MySyncTax credentials in .env

Keep the base URL and credentials outside your application code.

.env
MYSYNCTAX_BASE_URL=https://mysynctax.com

MYSYNCTAX_KEY=your_mysynctax_key

MYSYNCTAX_SECRET=your_mysynctax_secret
2

Add a MySyncTax entry to config/services.php

Using Laravel config keeps your service class clean and lets you use normal configuration caching in production.

config/services.php
'mysynctax' => [

    'url' => env('MYSYNCTAX_BASE_URL', 'https://mysynctax.com'),

    'key' => env('MYSYNCTAX_KEY'),

    'secret' => env('MYSYNCTAX_SECRET'),

],
3

Create a reusable Laravel service class

Centralizing API calls in a service class makes it easier to reuse the same integration in controllers, jobs and scheduled processes.

app/Services/MySyncTaxService.php
<?php



namespace App\Services;



use Illuminate\Http\Client\Response;

use Illuminate\Support\Facades\Http;



class MySyncTaxService

{

    private string $baseUrl;

    private string $key;

    private string $secret;



    public function __construct()

    {

        $this->baseUrl = rtrim(config('services.mysynctax.url'), '/');

        $this->key = (string) config('services.mysynctax.key');

        $this->secret = (string) config('services.mysynctax.secret');

    }



    public function submitInvoice(array $invoice): Response

    {

        return Http::acceptJson()

            ->asJson()

            ->timeout(30)

            ->post($this->baseUrl . '/v5/api/myinvois', [

                'mysynctax_key' => $this->key,

                'mysynctax_secret' => $this->secret,

                ...$invoice,

            ]);

    }



    public function submitErpInvoice(array $invoice): Response

    {

        return Http::acceptJson()

            ->asJson()

            ->timeout(30)

            ->post($this->baseUrl . '/v5/api/myinvois/invoice', [

                'mysynctax_key' => $this->key,

                'mysynctax_secret' => $this->secret,

                ...$invoice,

            ]);

    }

}

Laravel MyInvois API Request JSON Example

This is the MySyncTax normal invoice request body. Replace the sample transaction and credential values with your server-side data. Send it to POST https://mysynctax.com/v5/api/myinvois.

{

  "mysynctax_key": "YOUR_API_KEY",

  "mysynctax_secret": "YOUR_API_SECRET",

  "invoice_no": "INV-1001",

  "sale_id_integrate": 1001,

  "payment_note_term": "CASH",

  "items": [

    {

      "item_id": 101,

      "sorting_id": 1,

      "invoiced_quantity": 2,

      "unit_price": 30.0,

      "item_description": "USB Keyboard",

      "price_discount": 0,

      "tax_amount": 3.6

    }

  ]

}

See the MySyncTax developer documentation for the endpoint contract. Direct LHDN submissions use a different document structure.

Standard invoice

Submit e-Invoice to LHDN from Laravel

For the normal invoice with receipt QR flow, MySyncTax documents POST https://mysynctax.com/v5/api/myinvois. The JSON includes your credentials plus invoice and item data.

Request

📤 Laravel invoice payload

Controller or Job
$payload = [

    'invoice_no' => 'INV-1001',

    'sale_id_integrate' => 1001,

    'payment_note_term' => 'CASH',

    'items' => [

        [

            'item_id' => 12,

            'sorting_id' => 1,

            'invoiced_quantity' => 2,

            'unit_price' => 60.00,

            'item_description' => 'Premium Nasi Ayam Set',

            'price_discount' => 20,

            'tax_amount' => 10.00,

        ],

        [

            'item_id' => 13,

            'sorting_id' => 2,

            'invoiced_quantity' => 1,

            'unit_price' => 90.00,

            'item_description' => 'Iced Coffee Latte',

            'price_discount' => 10,

            'tax_amount' => 8.00,

        ],

    ],

];



$response = app(\App\Services\MySyncTaxService::class)

    ->submitInvoice($payload);
Response

📥 Store UUID and QR URL

Laravel response handling
if ($response->successful()) {

    $data = $response->json();



    $invoice->update([

        'mysynctax_uuid' => $data['mysynctax_uuid'] ?? null,

        'mysynctax_qr_url' => $data['qr_url'] ?? null,

        'mysynctax_status' => $data['status'] ?? null,

    ]);



    return response()->json([

        'message' => 'Invoice submitted',

        'data' => $data,

    ]);

}

The standard success example in the MySyncTax documentation returns status, mysynctax_uuid and qr_url.

Payload rules from the API documentation: numerical amounts should be sent as numbers, and documented date fields use the format YYYY-MM-DD HH:MM:SS. MySyncTax also documents duplicate payload detection using HTTP 409.
ERP / Accounting

Laravel ERP MyInvois Integration with Customer Data

For ERP or accounting systems that manage customer master data, MySyncTax documents a dedicated invoice endpoint. This request can include customer TIN, registration name, identification details and address information.

POST https://mysynctax.com/v5/api/myinvois/invoice
Laravel ERP invoice example
$payload = [

    'isAutoToLHDN' => 1,

    'invoice_no' => 'INV-322',

    'sale_id_integrate' => 3312,

    'payment_note_term' => 'CASH',

    'customer' => [

        'tin_no' => 'IG25461820000',

        'registration_name' => 'ABC Trading Sdn Bhd',

        'identification_no' => '930105045119',

        'identification_type' => 'NRIC',

        'sst_registration' => 'SST123456',

        'phone' => '0123456789',

        'email' => 'finance@abctrading.com',

        'address_line_1' => 'No 10, Jalan Teknologi',

        'address_line_2' => 'Taman Teknologi',

        'address_line_3' => 'Seksyen 7',

        'city_name' => 'Shah Alam',

        'postal_zone' => '40000',

        'state_code' => '10',

        'country_code' => 'MYS',

    ],

    'items' => [

        [

            'item_id' => 101,

            'sorting_id' => 1,

            'item_description' => 'USB Keyboard',

            'invoiced_quantity' => 2,

            'unit_price' => 30.00,

            'price_discount' => 5,

            'tax_amount' => 3.60,

        ],

    ],

];



$response = app(\App\Services\MySyncTaxService::class)

    ->submitErpInvoice($payload);



$data = $response->json();
The documented ERP response can include values such as invoice_id, mysynctax_uuid, customer_status, qr_lhdn, customer_id, a submission UID and accepted or rejected document information.

Laravel MySyncTax JSON Response Example

Illustrative normal invoice response from the MySyncTax API documentation; identifiers and the receipt URL below are placeholders.

{

  "status": "ok",

  "mysynctax_uuid": "generated-unique-id",

  "qr_url": "https://mysynctax.com/v5/redirect/EXAMPLE"

}

Save the MySyncTax UUID against your local invoice. This receipt response alone does not establish that LHDN has validated an e-Invoice. Handle HTTP errors and the returned status before updating your records.

Laravel application logic

Laravel MyInvois UUID Response and Error Handling

Do not treat every non-200 response as the same problem. Separate authentication, duplicate, validation and server failures in your Laravel workflow.

Example response handling
$response = $mySyncTax->submitInvoice($payload);



if ($response->successful()) {

    return $response->json();

}



if ($response->status() === 401) {

    throw new \RuntimeException('Invalid MySyncTax API credentials.');

}



if ($response->status() === 409) {

    $duplicate = $response->json();



    // Handle duplicate separately instead of blindly retrying.

    return $duplicate;

}



if ($response->status() === 400) {

    throw new \InvalidArgumentException(

        $response->json('message') ?? 'Invalid invoice payload.'

    );

}



$response->throw();
Reliability

MyInvois API Error Handling in Laravel

These status codes are documented by MySyncTax for the main invoice flow and related note operations.

HTTP Documented meaning Recommended Laravel handling
400 Invalid or malformed JSON Log the request context, validate your payload and return a controlled validation error.
401 API key or secret missing / invalid Stop retries and verify MYSYNCTAX_KEY and MYSYNCTAX_SECRET.
404 Invoice UUID not found for applicable note flows Check the stored UUID before sending a credit, debit or refund operation.
409 Duplicate invoice / duplicate submission Do not create another local invoice. Inspect the duplicate response and reconcile using the stored sale ID / UUID.
422 Item mismatch for applicable note flows Validate note items against the original invoice before resubmitting.
500 Server processing error Log the failure and use a controlled queue / retry policy instead of immediate repeated requests.
Important for queues: avoid retrying 401, malformed 400 payloads, or known duplicates as though they were transient network failures. Reserve automatic retries for failures that can realistically succeed later.
Production design

Laravel Best Practices for a Stable MyInvois Integration

The API call is only one part of a production e-Invoice integration. Your Laravel application should also protect credentials, record external IDs and make failures traceable.

🔐 Protect credentials

  • Store secrets in environment configuration.
  • Do not log the full API secret.
  • Keep all API calls server-side.

🧾 Store external references

  • Keep sale_id_integrate stable.
  • Store mysynctax_uuid after submission.
  • Record QR or LHDN response fields you need later.

🔁 Use queues carefully

  • Queue invoice submissions when appropriate.
  • Separate permanent and temporary failures.
  • Prevent accidental duplicate jobs.

✅ Validate before sending

  • Validate invoice number and item data.
  • Send numerical amounts as numbers.
  • Use the documented date format where required.

📊 Log safely

  • Log endpoint, status and local invoice ID.
  • Mask API credentials.
  • Retain enough context for support and reconciliation.

🧪 Test business cases

  • Test normal invoices and duplicate handling.
  • Test customer TIN and address scenarios.
  • Test notes, self-billed flows and cancellation where relevant.
Beyond basic invoices

Other MyInvois APIs Your Laravel System Can Use

The same Laravel service pattern can be extended to additional endpoints documented by MySyncTax.

Adjustments

↩️ Credit / Debit / Refund

POST /v5/api/myinvois/note

Submit adjustment notes for invoices already submitted to LHDN. The payload uses a documented note_type such as credit, debit or refund.

Self-Billed

🏭 Self-Billed Invoice

POST /v5/api/myinvois/selfbill/invoice

For cases where the buyer generates the e-Invoice on behalf of the supplier.

Master Data

👤 Add / Update Customer

POST /v5/api/myinvois/add_customer

Create or update customer master data before relevant ERP or invoice workflows.

Master Data

🏢 Add / Update Supplier

POST /v5/api/myinvois/add_supplier

Maintain supplier information for self-billed and ERP-related invoice scenarios.

Document

📄 Generate / View PDF

GET /v5/invoice/view/{mysynctax_uuid}

Use the returned mysynctax_uuid to retrieve the rendered e-Invoice PDF according to the developer documentation.

Document Action

🚫 Cancel e-Invoice

POST /v5/api/v1/external/cancel-document/{unique_id}

The documentation states that LHDN enforces a 72-hour cancellation window. Your Laravel UI should therefore expose cancellation carefully.

Delivery

✉️ Send Invoice Email

POST /v5/api/invoice/send-email

Trigger an email notification containing the PDF e-Invoice link using the documented UUID input.

General TIN

🌐 General TIN Invoice

POST /v5/api/myinvois/invoice_generaltin

Use the documented general TIN workflow for applicable scenarios such as walk-in / B2C or other defined cases.

Reference

📚 Full API Documentation

The developer documentation remains the source of truth for current endpoint fields, examples and response formats.

View Documentation

Useful follow-up

Open the e-Invoice PDF from Laravel

The API documentation provides a PDF URL based on the returned MySyncTax UUID.

Laravel route example
use App\Models\Invoice;



Route::get('/invoices/{invoice}/pdf', function (Invoice $invoice) {

    abort_unless($invoice->mysynctax_uuid, 404);



    $url = 'https://mysynctax.com/v5/invoice/view/'

        . urlencode($invoice->mysynctax_uuid);



    return redirect()->away($url);

});
The current MySyncTax developer documentation says this PDF endpoint is accessible using the UUID and does not require authentication. Treat the UUID as a document reference and design your own Laravel authorization around who is allowed to obtain or use that link.

Delete Invoice

Use this API to request deletion of an invoice from MySyncTax by its unique ID. The API validates your integration credentials and checks the invoice submission status before processing the request.

Endpoint

POST https://mysynctax.com/v5/api/myinvois/delete/{mysynctax_uniqueId}

Request parameters

  • mysynctax_unique_id (string): unique invoice identifier passed in the URL.
  • mysynctax_key (string): integration API key assigned to your company.
  • mysynctax_secret (string): integration API secret assigned to your company.

Request example

Send both integration credentials in the JSON request body.

{

  "mysynctax_key": "YOUR_MYSYNCTAX_KEY",

  "mysynctax_secret": "YOUR_MYSYNCTAX_SECRET"

}

Laravel HTTP client example

Store the credentials in server-side configuration, for example services.mysynctax.key and services.mysynctax.secret.

use Illuminate\Support\Facades\Http;



$mysycntax_uniqueId = 'YOUR_INVOICE_UNIQUE_ID';

$url = 'https://mysynctax.com/v5/api/myinvois/delete/' . rawurlencode($mysycntax_uniqueId);



$response = Http::acceptJson()

    ->timeout(30)

    ->post($url, [

        'mysynctax_key' => config('services.mysynctax.key'),

        'mysynctax_secret' => config('services.mysynctax.secret'),

    ]);



$response->throw();

$result = $response->json();



if (!($result['success'] ?? false)) {

    // Inspect the API message; an already-submitted invoice cannot be deleted.

    logger()->warning('Invoice deletion was not completed', $result);

}

Response example

This response indicates that deletion was rejected because the invoice has already been submitted to LHDN.

{

  "success": false,

  "message": "Invoice cannot be deleted because it has already been submitted.",

  "unique_id": "50dc9929XXXXXXXXXXXXXXXXXXXXXXXXXX",

  "invoice_no": "MZXXX-XXXXXXXX",

  "submission_status": "Submitted"

}

The response includes success (boolean), message, unique_id, invoice_no and submission_status.

Important: Use POST, pass the invoice unique ID in the URL, and include both credentials in the JSON body. An invoice already submitted to LHDN cannot be deleted through this API. The supplied URL contains /dev/; confirm that this is the correct base path for your environment.

FAQ

Laravel MyInvois API Integration FAQ

Common implementation questions for Laravel developers integrating Malaysian e-Invoice workflows.

Can Laravel integrate directly with the MySyncTax MyInvois API?

Yes. Laravel can send JSON over HTTPS using its built-in HTTP client. This guide uses a small service class so invoice submission logic stays outside controllers.

Where should I store mysynctax_key and mysynctax_secret?

Store them in server-side environment configuration such as .env and expose them to your service through config/services.php. Do not place the secret in frontend JavaScript or public source code.

Which endpoint should a Laravel POS use for a normal invoice?

The developer documentation lists POST https://mysynctax.com/v5/api/myinvois for the normal invoice with receipt QR flow.

Which endpoint should a Laravel ERP use when it has customer master data?

MySyncTax documents POST https://mysynctax.com/v5/api/myinvois/invoice for ERP and accounting systems that manage customer data and require direct submission flow.

How do I handle duplicate submissions in Laravel?

The main API documentation maps duplicates to HTTP 409. Handle that response separately, reconcile the existing transaction, and do not blindly retry the same payload.

What should I save after a successful MyInvois submission?

At minimum, keep the returned MySyncTax UUID and relevant submission status. Depending on the endpoint, you may also receive a QR URL, LHDN QR link, invoice ID, customer information, submission UID and accepted document UUID.

Can I generate an e-Invoice PDF from Laravel?

Yes. The developer documentation lists GET https://mysynctax.com/v5/invoice/view/{mysynctax_uuid}. You can redirect an authorized Laravel user to that URL or incorporate it into your document workflow.

Does MySyncTax support credit notes, debit notes and refunds?

Yes. The developer documentation includes a note endpoint and supports the documented credit, debit and refund note types.

Does MySyncTax provide a separate Laravel MyInvois sandbox endpoint?

The current MySyncTax developer documentation does not list a separate Laravel-specific sandbox endpoint. Use the environment and credentials issued for your integration, and confirm test-versus-production access with MySyncTax before sending live invoice data.

Integration support

Need Help Connecting Laravel to MyInvois?

Share your Laravel application type, invoice flow, customer volume and whether you need normal invoice, ERP, self-billed or note workflows. MySyncTax can help you map your existing data structure to the available API endpoints.

💬 Talk to MySyncTax

Use WhatsApp for integration enquiries and implementation discussions.

Chat via WhatsApp

🧑‍💻 What to Prepare

  • Your Laravel version and system type.
  • The invoice flow you need to support.
  • Whether customer / supplier master data already exists in your system.
  • Your preferred test and production rollout approach.