Your .NET System
Prepare invoice, customer and item data from your ASP.NET Core, desktop, ERP, POS or backend application.
.NET MyInvois API integration enables ASP.NET Core, C# ERP, POS and accounting applications in Malaysia to send e-Invoice data through the MySyncTax REST API. This developer guide uses HttpClient and JSON to show the core integration flow: load MySyncTax credentials securely, build the invoice payload, submit it to the documented endpoint and process the returned status, UUID and QR information. It also covers practical error handling for malformed requests, unauthorized credentials and duplicate submissions. The same pattern can be placed inside an ASP.NET Core service layer so controllers and business logic remain clean. The examples are intended as a maintainable C# MyInvois API reference that follows the live MySyncTax documentation and avoids unnecessary keyword repetition.
using var client = new HttpClient();
var json = JsonConvert.SerializeObject(payload);
var content = new StringContent(
json,
Encoding.UTF8,
"application/json"
);
var response = await client.PostAsync(
"https://mysynctax.com/v5/api/myinvois",
content
);
var result =
await response.Content.ReadAsStringAsync();
MyInvois API integration in .NET C# means connecting your C# business application to an e-Invoice API so invoice data can be sent as JSON, processed and returned with integration status information. MySyncTax provides an API layer designed for POS, ERP and third-party systems.
Prepare invoice, customer and item data from your ASP.NET Core, desktop, ERP, POS or backend application.
Send the payload as JSON over HTTPS with your assigned mysynctax_key and mysynctax_secret.
Process invoice submissions and use the returned identifiers and status information inside your own application workflow.
Before coding the integration, prepare the credentials, application components and invoice data your C# service will send to the API.
HttpClient for HTTPS requestsmysynctax_keymysynctax_secretA practical implementation flow for a C# application using the documented MySyncTax API.
Store the assigned API key and secret securely and load them into your application configuration.
Create a C# request object containing your integration credentials, invoice number, sale ID, payment term and invoice items.
Use Newtonsoft.Json or System.Text.Json so the request body matches the API's expected JSON structure.
Send the JSON to the appropriate MySyncTax endpoint using an HTTPS POST request with application/json.
Check the HTTP status code and deserialize the response. Store the returned MySyncTax identifier and relevant status information with your original transaction.
Do not blindly resend the same payload. Treat duplicate, authentication and validation responses as separate application states.
The official MySyncTax documentation includes a C# HttpClient example. The example below expands that pattern into a more complete reusable integration method.
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using System.Net;
using System.Net.Http;
using System.Text;
using Newtonsoft.Json;
public sealed class MyInvoisService
{
private readonly HttpClient _httpClient;
private readonly string _apiKey;
private readonly string _apiSecret;
public MyInvoisService(
HttpClient httpClient,
IConfiguration configuration)
{
_httpClient = httpClient;
_apiKey = configuration["MySyncTax:ApiKey"]
?? throw new InvalidOperationException("Missing MySyncTax API key.");
_apiSecret = configuration["MySyncTax:ApiSecret"]
?? throw new InvalidOperationException("Missing MySyncTax API secret.");
}
public async Task<string> SubmitInvoiceAsync(
string invoiceNo,
int saleId,
CancellationToken cancellationToken = default)
{
var payload = new
{
mysynctax_key = _apiKey,
mysynctax_secret = _apiSecret,
invoice_no = invoiceNo,
sale_id_integrate = saleId,
payment_note_term = "CASH",
items = new[]
{
new
{
item_id = 101,
sorting_id = 1,
invoiced_quantity = 2,
unit_price = 30.00m,
item_description = "USB Keyboard",
price_discount = 5.00m,
tax_amount = 3.60m
}
}
};
var json = JsonConvert.SerializeObject(payload);
using var content = new StringContent(
json,
Encoding.UTF8,
"application/json"
);
using var response = await _httpClient.PostAsync(
"https://mysynctax.com/v5/api/myinvois",
content,
cancellationToken
);
var responseBody =
await response.Content.ReadAsStringAsync(cancellationToken);
if (response.StatusCode == HttpStatusCode.Unauthorized)
{
throw new InvalidOperationException(
"MySyncTax authentication failed."
);
}
if (response.StatusCode == HttpStatusCode.Conflict)
{
// The same invoice payload may already exist.
return responseBody;
}
response.EnsureSuccessStatusCode();
return responseBody;
}
}
HttpClient with IHttpClientFactory in ASP.NET Core rather than repeatedly creating new clients per request. The documented normal invoice flow uses invoice-level fields plus an item collection. Keep amounts numeric and use the required date format when a date field is included.
{
"mysynctax_key": "YOUR_KEY",
"mysynctax_secret": "YOUR_SECRET",
"invoice_no": "INV-10001",
"sale_id_integrate": 10001,
"payment_note_term": "CASH",
"items": [
{
"item_id": 101,
"sorting_id": 1,
"invoiced_quantity": 2,
"unit_price": 30.00,
"item_description": "USB Keyboard",
"price_discount": 5.00,
"tax_amount": 3.60
}
]
}
YYYY-MM-DD HH:MM:SS for documented date fields.Choose the endpoint based on the business flow your C# application needs to support.
| Use case | Method | Endpoint |
|---|---|---|
| Normal invoice | POST | https://mysynctax.com/v5/api/myinvois |
| ERP invoice with customer | POST | https://mysynctax.com/v5/api/myinvois/invoice |
| Credit / Debit / Refund note | POST | https://mysynctax.com/v5/api/myinvois/note |
| Self-billed invoice | POST | https://mysynctax.com/v5/api/myinvois/selfbill/invoice |
| Self-billed note | POST | https://mysynctax.com/v5/api/myinvois/selfbill/note |
| Add / update customer | POST | https://mysynctax.com/v5/api/myinvois/add_customer |
| Add / update supplier | POST | https://mysynctax.com/v5/api/myinvois/add_supplier |
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.
Good integration code should treat each HTTP response as an application state rather than only checking whether a request returned JSON.
Inspect the serialized request, required fields, JSON syntax and data types before retrying.
Check the configured mysynctax_key and mysynctax_secret.
Do not automatically create another invoice. Reconcile the response with your existing transaction record.
Log the response, use controlled retry logic where appropriate, and avoid generating duplicate business transactions.
Keep the MyInvois API connection behind a service layer so your accounting, POS or ERP code is not tightly coupled to raw HTTP calls.
Owns the invoice, customer, supplier and transaction data used by your business application.
Maps your internal models to API payloads, performs validation, submits requests and interprets responses.
Stores the original sale ID, outbound request reference, returned UUID/status and error information for traceability.
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.
POST https://mysynctax.com/v5/api/myinvois/delete/{mysynctax_uniqueId}
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.Send both integration credentials in the JSON request body.
{
"mysynctax_key": "YOUR_MYSYNCTAX_KEY",
"mysynctax_secret": "YOUR_MYSYNCTAX_SECRET"
}
Keep the credentials in server-side environment configuration. This example assumes httpClient is a reused HttpClient instance.
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Text.Json;
var mysynctax_uniqueId = "YOUR_INVOICE_UNIQUE_ID";
var url = $"https://mysynctax.com/v5/api/myinvois/delete/{Uri.EscapeDataString(mysynctax_uniqueId)}";
var payload = new Dictionary<string, string>
{
["mysynctax_key"] = Environment.GetEnvironmentVariable("MYSYNCTAX_KEY")
?? throw new InvalidOperationException("MYSYNCTAX_KEY is not configured."),
["mysynctax_secret"] = Environment.GetEnvironmentVariable("MYSYNCTAX_SECRET")
?? throw new InvalidOperationException("MYSYNCTAX_SECRET is not configured.")
};
using var content = new StringContent(
JsonSerializer.Serialize(payload), Encoding.UTF8, "application/json");
using var response = await httpClient.PostAsync(url, content);
var responseBody = await response.Content.ReadAsStringAsync();
response.EnsureSuccessStatusCode();
Console.WriteLine(responseBody);
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.
Common implementation questions from developers integrating Malaysian e-Invoice workflows into C# applications.
Yes. A C# application can send JSON requests to the MySyncTax API using HttpClient and process the JSON response returned by the endpoint.
MySyncTax integration requests require mysynctax_key and mysynctax_secret in the JSON request body.
The documented standard submission endpoint is POST https://mysynctax.com/v5/api/myinvois.
Either can be used in a .NET application as long as the resulting JSON matches the API's expected field names and data types. The official documentation currently shows a Newtonsoft.Json example.
Treat it as a duplicate-submission state. Reconcile the returned information against the original invoice instead of blindly creating or resending a new transaction.
Yes. In an ASP.NET Core project, a typed or named HttpClient registered through IHttpClientFactory is a clean way to manage the API client.
The current MySyncTax developer documentation does not list separate ASP.NET Core-specific sandbox and production endpoints. Your C# application uses the documented REST endpoints, while environment access and credentials should be confirmed with MySyncTax before going live.
Use the MySyncTax developer documentation for the current API payloads and endpoints, or contact the integration team if you need help mapping your ERP, POS or accounting data into the MyInvois workflow.