> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.staple.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.staple.ai/_mcp/server.

# Cancel Malaysia E-Invoice

POST https://api.staple.io/v2/einvoice/malaysia/cancel
Content-Type: application/json

# Cancel Malaysia E-Invoice

Cancel a previously submitted Malaysia e-invoice document on LHDN MyInvois.

You can cancel by sending either:

-   `docId` (Staple document ID), or
    
-   `uuid` (MyInvois document UUID)
    

> Important:  
> Cancellation is subject to MyInvois/LHDN rules, such as allowed time window and document state.  
> If cancellation is not allowed, clients should issue a Credit Note instead.

* * *

## Endpoint

**POST** `/v2/einvoice/malaysia/cancel`

* * *

## Request Headers

| Attribute | Type | Option | Description |
| --- | --- | --- | --- |
| x-api-key | String | Required | A unique string |
| Authorization | String | Required | Bearer token |

**Content-Type:** `application/json`  
**Accept:** `application/json`

* * *

## Request Payload (by docId)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| reason | String | ✅ | Cancellation reason |
| docId | Number | ✅ | Staple document ID |

### Sample

```json
{
  "reason": "Wrong line item quantity",
  "docId": 242020
}

```

* * *

## Request Payload (by uuid)

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| reason | String | ✅ | Cancellation reason |
| uuid | String | ✅ | MyInvois document UUID |

### Sample

```json
{
  "reason": "Wrong line item quantity",
  "uuid": "KAQ2848KJ35CCAH3PY86FMMK10"
}

```

* * *

## Response (Success)

```json
{
  "uuid": "KAQ2848KJ35CCAH3PY86FMMK10",
  "status": "Cancelled"
}

```

* * *

## Response Field Notes

-   `uuid`: MyInvois document UUID of the cancelled document
    
-   `status`: Expected success value is `Cancelled`
    

* * *

## Error Notes

If cancellation fails, clients should inspect the returned error details from this endpoint.

Example request payload:

```json
{
  "reason": "Wrong line item quantity",
  "docId": 242020
}

```

Reference: https://docs.staple.ai/api-reference/v2/e-invoice/cancel-malaysia-e-invoice

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: v2
  version: 1.0.0
paths:
  /v2/einvoice/malaysia/cancel:
    post:
      operationId: cancelMalaysiaEInvoice
      summary: Cancel Malaysia E-Invoice
      description: >-
        # Cancel Malaysia E-Invoice


        Cancel a previously submitted Malaysia e-invoice document on LHDN
        MyInvois.


        You can cancel by sending either:


        -   `docId` (Staple document ID), or
            
        -   `uuid` (MyInvois document UUID)
            

        > Important:  

        > Cancellation is subject to MyInvois/LHDN rules, such as allowed time
        window and document state.  

        > If cancellation is not allowed, clients should issue a Credit Note
        instead.


        * * *


        ## Endpoint


        **POST** `/v2/einvoice/malaysia/cancel`


        * * *


        ## Request Headers


        | Attribute | Type | Option | Description |

        | --- | --- | --- | --- |

        | x-api-key | String | Required | A unique string |

        | Authorization | String | Required | Bearer token |


        **Content-Type:** `application/json`  

        **Accept:** `application/json`


        * * *


        ## Request Payload (by docId)


        | Field | Type | Required | Description |

        | --- | --- | --- | --- |

        | reason | String | ✅ | Cancellation reason |

        | docId | Number | ✅ | Staple document ID |


        ### Sample


        ```json

        {
          "reason": "Wrong line item quantity",
          "docId": 242020
        }


        ```


        * * *


        ## Request Payload (by uuid)


        | Field | Type | Required | Description |

        | --- | --- | --- | --- |

        | reason | String | ✅ | Cancellation reason |

        | uuid | String | ✅ | MyInvois document UUID |


        ### Sample


        ```json

        {
          "reason": "Wrong line item quantity",
          "uuid": "KAQ2848KJ35CCAH3PY86FMMK10"
        }


        ```


        * * *


        ## Response (Success)


        ```json

        {
          "uuid": "KAQ2848KJ35CCAH3PY86FMMK10",
          "status": "Cancelled"
        }


        ```


        * * *


        ## Response Field Notes


        -   `uuid`: MyInvois document UUID of the cancelled document
            
        -   `status`: Expected success value is `Cancelled`
            

        * * *


        ## Error Notes


        If cancellation fails, clients should inspect the returned error details
        from this endpoint.


        Example request payload:


        ```json

        {
          "reason": "Wrong line item quantity",
          "docId": 242020
        }


        ```
      tags:
        - eInvoice
      parameters:
        - name: x-api-key
          in: header
          description: API key issued by Staple.
          required: true
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/E-Invoice_cancelMalaysiaEInvoice_Response_200
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                reason:
                  type: string
servers:
  - url: https://api.staple.io
    description: https://api.staple.io
components:
  schemas:
    E-Invoice_cancelMalaysiaEInvoice_Response_200:
      type: object
      properties: {}
      description: Empty response body
      title: E-Invoice_cancelMalaysiaEInvoice_Response_200
  securitySchemes:
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key
      description: API key issued by Staple.
    bearerAuth:
      type: http
      scheme: bearer
      description: JWT obtained from the login endpoint.

```

## Examples



**Request**

```json
{
  "reason": "Wrong buyer details"
}
```

**Response**

```json
{}
```

**SDK Code**

```python E-Invoice_cancelMalaysiaEInvoice_example
import requests

url = "https://api.staple.io/v2/einvoice/malaysia/cancel"

payload = { "reason": "Wrong buyer details" }
headers = {
    "x-api-key": "<apiKey>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript E-Invoice_cancelMalaysiaEInvoice_example
const url = 'https://api.staple.io/v2/einvoice/malaysia/cancel';
const options = {
  method: 'POST',
  headers: {'x-api-key': '<apiKey>', 'Content-Type': 'application/json'},
  body: '{"reason":"Wrong buyer details"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go E-Invoice_cancelMalaysiaEInvoice_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.staple.io/v2/einvoice/malaysia/cancel"

	payload := strings.NewReader("{\n  \"reason\": \"Wrong buyer details\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("x-api-key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby E-Invoice_cancelMalaysiaEInvoice_example
require 'uri'
require 'net/http'

url = URI("https://api.staple.io/v2/einvoice/malaysia/cancel")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-api-key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"reason\": \"Wrong buyer details\"\n}"

response = http.request(request)
puts response.read_body
```

```java E-Invoice_cancelMalaysiaEInvoice_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.staple.io/v2/einvoice/malaysia/cancel")
  .header("x-api-key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"reason\": \"Wrong buyer details\"\n}")
  .asString();
```

```php E-Invoice_cancelMalaysiaEInvoice_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.staple.io/v2/einvoice/malaysia/cancel', [
  'body' => '{
  "reason": "Wrong buyer details"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'x-api-key' => '<apiKey>',
  ],
]);

echo $response->getBody();
```

```csharp E-Invoice_cancelMalaysiaEInvoice_example
using RestSharp;

var client = new RestClient("https://api.staple.io/v2/einvoice/malaysia/cancel");
var request = new RestRequest(Method.POST);
request.AddHeader("x-api-key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"reason\": \"Wrong buyer details\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift E-Invoice_cancelMalaysiaEInvoice_example
import Foundation

let headers = [
  "x-api-key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = ["reason": "Wrong buyer details"] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.staple.io/v2/einvoice/malaysia/cancel")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```