/invoices/{invoiceId}/clearingrecords/{recordId}Deletes an invoice clearing record by logical delete: the record's status is set to deleted.
Invoice clearing totals are recalculated.
For CUSTOMER_INVOICE, if the record represents payment, deleting it is applied to billing balance (decreases balance, increases unpaid amount). If that would result in blocked balance (insufficient funds already spent), the API returns 409 CHANGE_PAYMENT_BLOCK_BALANCE. Use query parameter force=yes to force deletion even when it would block balance (balance/account may be blocked for use afterward).
Audit event:
- invoice.clearing.record.delete
Privilege (one of; checked against invoice class):
- finance-invoices.manage
- finance-cust-invoices.manage
- finance-supplier-invoices.manage
- finance-netting-invoices.manage
Errors:
- INVOICE_NOTFOUND - Invoice not found
- INVOICE_CLEARING_NOTFOUND - Invoice clearing not found
- INVOICE_CLEARING_RECORD_NOTFOUND - Invoice clearing record not found
- INVOICE_CLEARING_RECORD_DELETED - Invoice clearing record already deleted
- INVOICE_CLEARING_RECORD_CANCELED - Invoice clearing record is canceled and can not be deleted
- NETTING_MEMBER_CLEARING_NOT_ALLOWED - Can not manage clearing records for netting invoice member
- COLLECTION_MEMBER_CLEARING_RECORD_NOT_ALLOWED - Invoice is collection member.Collection members ar not allowed to have clearing records
- CHANGE_PAYMENT_BLOCK_BALANCE - After delete of edit payment balance will be blocked because of insufficient funds available
- CREDIT_RECORD_NOTFOUND - Credit record not found
- PAYMENT_TRANSFER_FAILED - Payment transfer to billing failed
- BILLING_RECORD_NOTFOUND - Billing record not found
- NOT_AUTHORIZED - Not authorized
- NOT_AUTHENTICATED - Not authenticated
- INT_APP_ERROR - Unexpected internal error
Request
Path parameters
Invoice ID
Invoice clearing record ID to delete
Query parameters
If "yes", force delete payment for customer invoices even if the operation would lead to customer balance blocking.
yes, no · Default: "no"Request example
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Delete, "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <access_token>");
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());var options = new RestClientOptions("")
{
MaxTimeout = -1,
};
var client = new RestClient(options);
var request = new RestRequest("https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}", Method.Delete);
request.AddHeader("Accept", "application/json");
request.AddHeader("Authorization", "Bearer <access_token>");
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);curl -L -X DELETE "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}" \
-H "Accept: application/json" \
-H "Authorization: Bearer <access_token>"var headers = {
'Accept': 'application/json',
'Authorization': 'Bearer <access_token>'
};
var dio = Dio();
var response = await dio.request(
'https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}',
options: Options(
method: 'DELETE',
headers: headers,
),
);
if (response.statusCode == 200) {
print(json.encode(response.data));
}
else {
print(response.statusMessage);
}var headers = {
'Accept': 'application/json',
'Authorization': 'Bearer <access_token>'
};
var request = http.Request('DELETE', Uri.parse('https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}'));
request.headers.addAll(headers);
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
print(await response.stream.bytesToString());
}
else {
print(response.reasonPhrase);
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}"
method := "DELETE"
client := &http.Client{}
req, err := http.NewRequest(method, url, nil)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Accept", "application/json")
req.Header.Add("Authorization", "Bearer <access_token>")
res, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
defer res.Body.Close()
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println(err)
return
}
fmt.Println(string(body))
}DELETE /finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId} HTTP/1.1
Host: api-cpaas.sms.es
Accept: application/json
Authorization: Bearer <access_token>OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}")
.method("DELETE", null)
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer <access_token>")
.build();
Response response = client.newCall(request).execute();Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.delete("https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}")
.header("Accept", "application/json")
.header("Authorization", "Bearer <access_token>")
.asString();const myHeaders = new Headers();
myHeaders.append("Accept", "application/json");
myHeaders.append("Authorization", "Bearer <access_token>");
const requestOptions = {
method: "DELETE",
headers: myHeaders,
redirect: "follow"
};
fetch("https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}", requestOptions)
.then((response) => response.text())
.then((result) => console.log(result))
.catch((error) => console.error(error));var settings = {
"url": "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}",
"method": "DELETE",
"timeout": 0,
"headers": {
"Accept": "application/json",
"Authorization": "Bearer <access_token>"
}
};
$.ajax(settings).done(function (response) {
console.log(response);
});var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("DELETE", "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <access_token>");
xhr.send();val client = OkHttpClient()
val request = Request.Builder()
.url("https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}")
.delete()
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer <access_token>")
.build()
val response = client.newCall(request).execute()#include <stdio.h>
#include <curl/curl.h>
int main(void) {
CURL *curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "DELETE");
curl_easy_setopt(curl, CURLOPT_URL, "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer <access_token>");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
CURLcode res = curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
return 0;
}const axios = require('axios');
let config = {
method: 'delete',
maxBodyLength: Infinity,
url: 'https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}',
headers: {
'Accept': 'application/json',
'Authorization': 'Bearer <access_token>'
}
};
axios.request(config)
.then((response) => {
console.log(JSON.stringify(response.data));
})
.catch((error) => {
console.log(error);
});const https = require('follow-redirects').https;
const fs = require('fs');
let options = {
'method': 'DELETE',
'hostname': 'api-cpaas.sms.es',
'path': '/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}',
'headers': {
'Accept': 'application/json',
'Authorization': 'Bearer <access_token>'
},
'maxRedirects': 20
};
const req = https.request(options, function (res) {
let chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
let body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
req.end();#import <Foundation/Foundation.h>
dispatch_semaphore_t sema = dispatch_semaphore_create(0);
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Accept": @"application/json",
@"Authorization": @"Bearer <access_token>"
};
[request setAllHTTPHeaderFields:headers];
[request setHTTPMethod:@"DELETE"];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
dispatch_semaphore_signal(sema);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSError *parseError = nil;
NSDictionary *responseDictionary = [NSJSONSerialization JSONObjectWithData:data options:0 error:&parseError];
NSLog(@"%@",responseDictionary);
dispatch_semaphore_signal(sema);
}
}];
[dataTask resume];
dispatch_semaphore_wait(sema, DISPATCH_TIME_FOREVER);open Lwt
open Cohttp
open Cohttp_lwt_unix
let reqBody =
let uri = Uri.of_string "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}" in
let headers = Header.init ()
|> fun h -> Header.add h "Accept" "application/json"
|> fun h -> Header.add h "Authorization" "Bearer <access_token>"
in
Client.call ~headers `DELETE uri >>= fun (_resp, body) ->
body |> Cohttp_lwt.Body.to_string >|= fun body -> body
let () =
let respBody = Lwt_main.run reqBody in
print_endline (respBody)<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_HTTPHEADER => array(
'Accept: application/json',
'Authorization: Bearer <access_token>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
<?php
$client = new Client();
$headers = [
'Accept' => 'application/json',
'Authorization' => 'Bearer <access_token>'
];
$request = new Request('DELETE', 'https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}', $headers);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer <access_token>")
$response = Invoke-RestMethod "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}" -Method 'DELETE' -Headers $headers
$response | ConvertTo-Jsonimport requests
import json
url = "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}"
payload = {}
headers = {
"Accept": "application/json",
"Authorization": "Bearer <access_token>"
}
response = requests.request("DELETE", url, headers=headers, data=payload)
print(response.text)import http.client
import json
conn = http.client.HTTPSConnection("api-cpaas.sms.es")
payload = ''
headers = {
"Accept": "application/json",
"Authorization": "Bearer <access_token>"
}
conn.request("DELETE", "/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))library(httr)
headers = c(
'Accept' = 'application/json',
'Authorization' = 'Bearer <access_token>'
)
res <- VERB("DELETE", url = "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}", add_headers(headers))
cat(content(res, 'text'))require "uri"
require "json"
require "net/http"
url = URI("https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Delete.new(url)
request["Accept"] = "application/json"
request["Authorization"] = "Bearer <access_token>"
response = https.request(request)
puts response.read_body
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = reqwest::Client::builder()
.build()?;
let mut headers = reqwest::header::HeaderMap::new();
headers.insert("Accept", "application/json".parse()?);
headers.insert("Authorization", "Bearer <access_token>".parse()?);
let request = client.request(reqwest::Method::from_bytes(b"DELETE")?, "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}")
.headers(headers);
let response = request.send().await?;
let body = response.text().await?;
println!("{}", body);
Ok(())
}http --follow --timeout 3600 DELETE "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}" \
'Accept':'application/json' \
'Authorization':'Bearer <access_token>'wget --no-check-certificate --quiet \
--method DELETE \
--timeout=0 \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access_token>' \
'https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}'var request = URLRequest(url: URL(string: "https://api-cpaas.sms.es/finance/sit/v1/invoices/{invoiceId}/clearingrecords/{recordId}")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Accept")
request.addValue("Bearer <access_token>", forHTTPHeaderField: "Authorization")
request.httpMethod = "DELETE"
let task = URLSession.shared.dataTask(with: request) { data, response, error in
guard let data = data else {
print(String(describing: error))
return
}
print(String(data: data, encoding: .utf8)!)
}
task.resume()Responses
- 200
- 400
- 401
- 404
- 409
- 500
Clearing record deleted successfully; returns the record with status "deleted"
active or canceled
{
"amountIncrement": 0,
"bankAccountIban": "CH9300762011623852957",
"bankAccountId": 1,
"bankAccountName": "Main account",
"bankAccountNumber": "123456",
"bankAccountSwiftBic": "CRESCHZZ",
"clearingId": 100,
"clearingTypeCodeName": "PAYMENT",
"clearingTypeId": 2,
"comment": "Bank transfer",
"id": 1,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"paymentTypeName": "Bank transfer",
"recordDate": "2026-01-15",
"revokeComment": "",
"revokeUserId": "",
"revokeUserName": "",
"status": "deleted",
"statusDate": "2026-01-22T10:00:00.000Z"
}Bad Request - Missing context, record already deleted, record canceled, or payment transfer failed
Show child attributes
Machine-readable error code
Optional structured error details (e.g. validation errors)
Show child attributes
Human-readable item error description
Machine-readable item error code
Value that failed validation (if applicable)
{}Human-readable error message
{
"error": {
"code": "INVOICE_CLEARING_RECORD_CANCELED",
"message": "Invoice clearing record is canceled and can not be deleted"
}
}Not Authorized or Not Authenticated
Show child attributes
Machine-readable error code
Optional structured error details (e.g. validation errors)
Show child attributes
Human-readable item error description
Machine-readable item error code
Value that failed validation (if applicable)
{}Human-readable error message
{
"error": {
"code": "NOT_AUTHORIZED",
"message": "Not authorized"
}
}Invoice, clearing, credit/billing record, or clearing record not found
Show child attributes
Machine-readable error code
Optional structured error details (e.g. validation errors)
Show child attributes
Human-readable item error description
Machine-readable item error code
Value that failed validation (if applicable)
{}Human-readable error message
{
"error": {
"code": "BILLING_RECORD_NOTFOUND",
"message": "Billing record not found"
}
}Conflict - Netting/collection member or balance would be blocked
Show child attributes
Machine-readable error code
Optional structured error details (e.g. validation errors)
Show child attributes
Human-readable item error description
Machine-readable item error code
Value that failed validation (if applicable)
{}Human-readable error message
{
"error": {
"code": "CHANGE_PAYMENT_BLOCK_BALANCE",
"message": "After delete of edit payment balance will be blocked because of insufficient funds available"
}
}Internal Server Error
Show child attributes
Machine-readable error code
Optional structured error details (e.g. validation errors)
Show child attributes
Human-readable item error description
Machine-readable item error code
Value that failed validation (if applicable)
{}Human-readable error message
{
"error": {
"code": "INT_APP_ERROR",
"message": "Unexpected internal error"
}
}