Delete a sales invoice
curl --request POST \
--url https://api.altera.co/sales/delete \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"invoiceId": 12345,
"reason": "Removing a QA test draft"
}
'import requests
url = "https://api.altera.co/sales/delete"
payload = {
"invoiceId": 12345,
"reason": "Removing a QA test draft"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({invoiceId: 12345, reason: 'Removing a QA test draft'})
};
fetch('https://api.altera.co/sales/delete', 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://api.altera.co/sales/delete",
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([
'invoiceId' => 12345,
'reason' => 'Removing a QA test draft'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://api.altera.co/sales/delete"
payload := strings.NewReader("{\n \"invoiceId\": 12345,\n \"reason\": \"Removing a QA test draft\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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://api.altera.co/sales/delete")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"invoiceId\": 12345,\n \"reason\": \"Removing a QA test draft\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.altera.co/sales/delete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"invoiceId\": 12345,\n \"reason\": \"Removing a QA test draft\"\n}"
response = http.request(request)
puts response.read_body{
"result": "OK",
"data": {
"fullDelete": 1,
"softDelete": 0,
"counterRollbackResult": "NOK"
}
}{
"result": "Error",
"errorMessage": "This tag cannot be deleted, it has been used in at least one invoice. You can disable it so it won't appear on the suggestion lists.",
"errorMessagePL": "Ta kategoria nie może zostać usunięta ponieważ została użyta w przynajmniej jednej fakturze. Możesz ją zablokować aby nie pojawiała się na liście sugerowanych."
}{
"result": "Error",
"errorCode": "KEY_EXPIRED",
"errorMessage": "API key has expired"
}{
"result": "Error",
"errorMessage": "This tag cannot be deleted, it has been used in at least one invoice. You can disable it so it won't appear on the suggestion lists.",
"errorMessagePL": "Ta kategoria nie może zostać usunięta ponieważ została użyta w przynajmniej jednej fakturze. Możesz ją zablokować aby nie pojawiała się na liście sugerowanych."
}Delete a sales invoice
Existing removal endpoint, including test drafts. DRAFT is deleted permanently; an eligible issued invoice is soft-deleted. Related documents, read-only or accounting-approved documents, and invoices submitted to or accepted by KSeF cannot be deleted. fullDelete and softDelete count removed invoice records. This endpoint uses POST, not DELETE.
POST
/
sales
/
delete
Delete a sales invoice
curl --request POST \
--url https://api.altera.co/sales/delete \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"invoiceId": 12345,
"reason": "Removing a QA test draft"
}
'import requests
url = "https://api.altera.co/sales/delete"
payload = {
"invoiceId": 12345,
"reason": "Removing a QA test draft"
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({invoiceId: 12345, reason: 'Removing a QA test draft'})
};
fetch('https://api.altera.co/sales/delete', 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://api.altera.co/sales/delete",
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([
'invoiceId' => 12345,
'reason' => 'Removing a QA test draft'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"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://api.altera.co/sales/delete"
payload := strings.NewReader("{\n \"invoiceId\": 12345,\n \"reason\": \"Removing a QA test draft\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
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://api.altera.co/sales/delete")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"invoiceId\": 12345,\n \"reason\": \"Removing a QA test draft\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.altera.co/sales/delete")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"invoiceId\": 12345,\n \"reason\": \"Removing a QA test draft\"\n}"
response = http.request(request)
puts response.read_body{
"result": "OK",
"data": {
"fullDelete": 1,
"softDelete": 0,
"counterRollbackResult": "NOK"
}
}{
"result": "Error",
"errorMessage": "This tag cannot be deleted, it has been used in at least one invoice. You can disable it so it won't appear on the suggestion lists.",
"errorMessagePL": "Ta kategoria nie może zostać usunięta ponieważ została użyta w przynajmniej jednej fakturze. Możesz ją zablokować aby nie pojawiała się na liście sugerowanych."
}{
"result": "Error",
"errorCode": "KEY_EXPIRED",
"errorMessage": "API key has expired"
}{
"result": "Error",
"errorMessage": "This tag cannot be deleted, it has been used in at least one invoice. You can disable it so it won't appear on the suggestion lists.",
"errorMessagePL": "Ta kategoria nie może zostać usunięta ponieważ została użyta w przynajmniej jednej fakturze. Możesz ją zablokować aby nie pojawiała się na liście sugerowanych."
}Remove a test draft
The existing endpoint removes aDRAFT permanently from the API key’s company. Confirm the invoice identifier and its status before calling it:
{
"invoiceId": 12345,
"reason": "Removing a QA test draft"
}
reason is optional; when supplied it must contain 5 to 400 characters. This route uses POST.
A permanently deleted draft returns:
{
"result": "OK",
"data": {
"fullDelete": 1,
"softDelete": 0,
"counterRollbackResult": "NOK"
}
}
fullDelete counts removed invoice records, not related rows. A zero count means that no invoice was removed by the mutation. Verify cleanup using the company sales list. A later GET by identifier for a permanently deleted draft returns HTTP 404 with errorCode: "NOT_FOUND".
Restrictions and issued invoices
An eligible issued invoice is soft-deleted rather than permanently removed. Related documents, read-only or accounting-approved documents, and invoices submitted to or accepted by KSeF cannot be deleted through this endpoint. A submitted invoice requires a correction. Deletion of issued invoices can attempt to roll back the invoice-number counter when possible. ANOK counter result is not itself a failed deletion. Use this endpoint for controlled test cleanup, rather than automatic removal of issued documents.Authorizations
OpenApi Key created within Altera.app for a certain company
Body
application/json
Was this page helpful?

