Malaysia v2: Cancel Document API
Cancel a document by its document ID, with a reason, in the Malaysia LHDN API v2 (legacy): endpoint, headers, request, responses and code examples.
This endpoint may no longer be available. Contact support@complyance.io before you rely on it. To cancel a Malaysian document within LHDN’s 72-hour window, you can cancel it in the MyInvois portal; see the life of a Malaysian e-invoice.
The Cancel Document API cancels a document by its documentId. You must give a reason for the cancellation.
Endpoint
| Environment | Host |
|---|---|
| Sandbox | https://malaysia-sandbox.complyance.io |
| Production | https://malaysia-prod.complyance.io |
Cancel a documenthttp
POST https://malaysia-sandbox.complyance.io/cancelDocument
POST https://malaysia-prod.complyance.io/cancelDocumentHeaders
| Header | Type | Description | Example | Conditionality |
|---|---|---|---|---|
x-api-key | string | Your API key | your-api-key | Mandatory |
Content-Type | string | Set as application/json | application/json | Mandatory |
Request body
The request body is JSON.
| Parameter | Type | Description | Example value |
|---|---|---|---|
documentId | string | Document reference number the supplier uses for internal tracking. | E-INV-01 |
reason | string | The reason for cancelling the document. | Testing Cancellation |
Request bodyjson
{
"documentId": "E-INV-01",
"reason": "Testing Cancellation"
}Response
Success response
HTTP status 200 OK:
Responsejson
{
"uuid": "ABCDEFGHJK0123456789CANC10",
"status": "Cancelled",
"error": null
}Error responses
| HTTP status code | Error code | Description |
|---|---|---|
400 | BAD_REQUEST | The input is invalid or fields are missing. |
401 | UNAUTHORIZED | The API key is missing or invalid. |
500 | SERVER_ERROR | An internal server error occurred. |
Error responsejson
{
"errorMessage": "Please check the field documentId"
}Code examples
bash
curl --location 'https://malaysia-prod.complyance.io/cancelDocument' \
--header 'Content-Type: application/json' \
--header 'x-api-key: your-api-key' \
--data '{
"documentId": "E-INV-01",
"reason": "Testing Cancellation"
}'javascript
const headers = {
'Content-Type': 'application/json',
'x-api-key': 'your-api-key'
};
const body = {
documentId: "E-INV-01",
reason: 'Testing Cancellation'
};
fetch('https://malaysia-prod.complyance.io/cancelDocument', {
method: 'POST',
headers: headers,
body: JSON.stringify(body)
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));python
import requests
url = 'https://malaysia-prod.complyance.io/cancelDocument'
headers = {
'Content-Type': 'application/json',
'x-api-key': 'your-api-key'
}
data = {
'documentId': 'E-INV-01',
'reason': 'Testing Cancellation'
}
response = requests.post(url, headers=headers, json=data)
print(response.json())php
<?php
$url = 'https://malaysia-prod.complyance.io/cancelDocument';
$headers = [
'Content-Type: application/json',
'x-api-key: your-api-key'
];
$data = [
'documentId' => 'E-INV-01',
'reason' => 'Testing Cancellation'
];
$options = [
'http' => [
'header' => $headers,
'method' => 'POST',
'content' => json_encode($data)
]
];
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo $result;
?>java
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.OutputStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws Exception {
URL url = new URL("https://malaysia-prod.complyance.io/cancelDocument");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.setRequestProperty("Content-Type", "application/json");
con.setRequestProperty("x-api-key", "your-api-key");
con.setDoOutput(true);
String jsonInputString = "{\"documentId\": \"E-INV-01\", \"reason\": \"Testing Cancellation\"}";
try (OutputStream os = con.getOutputStream()) {
byte[] input = jsonInputString.getBytes("utf-8");
os.write(input, 0, input.length);
}
try (BufferedReader br = new BufferedReader(new InputStreamReader(con.getInputStream(), "utf-8"))) {
StringBuilder response = new StringBuilder();
String responseLine = null;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
System.out.println(response.toString());
}
}
}go
package main
import (
"bytes"
"net/http"
"io/ioutil"
"fmt"
)
func main() {
url := "https://malaysia-prod.complyance.io/cancelDocument"
jsonData := []byte(`{"documentId": "E-INV-01", "reason": "Testing Cancellation"}`)
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("Content-Type", "application/json")
req.Header.Set("x-api-key", "your-api-key")
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error making request:", err)
return
}
defer resp.Body.Close()
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(body))
}Notes
- The
x-api-keyheader must contain a valid API key. - The
reasonparameter is required. Give a clear explanation for the cancellation. - Use the sandbox host for testing.
- Format the request body and headers correctly to avoid errors.
Last updated