E-Invoice
Cancel E-Invoice
Cancel a previously generated e-invoice on the IRP portal.
POST
/
v1
/
invoices
/
{id}
/
einvoice
/
cancel
Cancel an e-invoice (IRN)
curl --request POST \
--url https://billing.example.com/v1/invoices/{id}/einvoice/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cancel_code": 123,
"reason": "<string>"
}
'import requests
url = "https://billing.example.com/v1/invoices/{id}/einvoice/cancel"
payload = {
"cancel_code": 123,
"reason": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({cancel_code: 123, reason: '<string>'})
};
fetch('https://billing.example.com/v1/invoices/{id}/einvoice/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://billing.example.com/v1/invoices/{id}/einvoice/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cancel_code' => 123,
'reason' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/invoices/{id}/einvoice/cancel"
payload := strings.NewReader("{\n \"cancel_code\": 123,\n \"reason\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/invoices/{id}/einvoice/cancel")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cancel_code\": 123,\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/invoices/{id}/einvoice/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cancel_code\": 123,\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | The unique identifier of the invoice whose e-invoice should be canceled (e.g., inv_Rp3mK7nBwQ). |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
cancel_code | integer | Yes | The cancellation reason code. Must be between 1 and 4. See codes below. |
reason | string | Yes | A human-readable explanation for the cancellation. Minimum 10 characters. |
Cancel Codes
| Code | Meaning |
|---|---|
1 | Duplicate entry |
2 | Data entry mistake |
3 | Order canceled |
4 | Others |
Example Request
curl -X POST https://api.recurso.dev/v1/invoices/inv_Rp3mK7nBwQ/einvoice/cancel \
-H "Authorization: Bearer rsk_live_7f3a9b2c1d4e8f0a" \
-H "Content-Type: application/json" \
-d '{
"cancel_code": 2,
"reason": "Incorrect line item amounts were included on the original invoice"
}'
Response
{
"message": "E-invoice cancelled successfully"
}
CANCELLED — read it back with
Get e-invoice status.
Notes
- E-invoices can only be canceled within 24 hours of generation, as per IRP regulations.
- A canceled e-invoice cannot be reinstated. You must generate a new invoice and submit it for e-invoicing.
- The
reasonfield is transmitted to the IRP and becomes part of the permanent compliance record.
Cancellation is permanent and governed by IRP rules. Attempting to cancel an e-invoice older than 24 hours will return a
422 Unprocessable Entity error.Authorizations
Tenant API key obtained from POST /auth/register or POST /v1/developer/keys.
Path Parameters
Body
application/json
Response
E-invoice cancelled.
⌘I
Cancel an e-invoice (IRN)
curl --request POST \
--url https://billing.example.com/v1/invoices/{id}/einvoice/cancel \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"cancel_code": 123,
"reason": "<string>"
}
'import requests
url = "https://billing.example.com/v1/invoices/{id}/einvoice/cancel"
payload = {
"cancel_code": 123,
"reason": "<string>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({cancel_code: 123, reason: '<string>'})
};
fetch('https://billing.example.com/v1/invoices/{id}/einvoice/cancel', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://billing.example.com/v1/invoices/{id}/einvoice/cancel",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'cancel_code' => 123,
'reason' => '<string>'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://billing.example.com/v1/invoices/{id}/einvoice/cancel"
payload := strings.NewReader("{\n \"cancel_code\": 123,\n \"reason\": \"<string>\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://billing.example.com/v1/invoices/{id}/einvoice/cancel")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"cancel_code\": 123,\n \"reason\": \"<string>\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://billing.example.com/v1/invoices/{id}/einvoice/cancel")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"cancel_code\": 123,\n \"reason\": \"<string>\"\n}"
response = http.request(request)
puts response.read_body{
"message": "<string>"
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}{
"error": {
"code": "BAD_REQUEST",
"message": "<string>"
}
}