/invoices-by-number/{invoiceNumber}/clearingrecordsAdds a clearing record (payment, interest, or reminder) to the invoice's clearing. The invoice is identified by invoice number. Invoice clearing is created when invoice status is approved and payment status is 'open'. Not allowed for netting members or collection members. Supplier invoices with payment status 'on-hold' do not have clearing; clearing is created when approved for payment.
When totalUnpaid becomes 0 after this record, invoice payment status is set to closed. For CUSTOMER_INVOICE with POSTPAID/PREPAID, payment may be applied to billing balance automatically.
If the path contains %, the value is URL-decoded before lookup. If multiple invoices match the invoice number, the API returns 409 (TOO_MANY_RECORDS_FOR_INV_NUMBER).
Audit event:
- invoice.by.number.clearing.record.add
Privilege (one of; checked against invoice class):
- finance-invoices.manage
- finance-cust-invoices.manage
- finance-supplier-invoices.manage
- finance-netting-invoices.manage
clearingTypeId:
- 1 - Invoice (auto-generated)
- 2 - Payment (paidAmount required)
- 3 - Interest (amountIncrement required)
- 4 - Reminder (amountIncrement required)
paymentTypeId:
- 1 - Bank Transfer (bankAccountId required or 0 for default)
- 2 - Credit Card
- 3 - Paypal
- 4 - Cash
Errors:
- INVOICE_NOTFOUND - Invoice not found
- NETTING_MEMBER_COLLECTION_LEAD_CHANGE_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
- INVOICE_CLEARING_NOTFOUND - Invoice clearing not found
- CREDIT_RECORD_NOTFOUND - Credit record not found
- PAYMENT_TRANSFER_FAILED - Payment transfer to billing failed
- BILLING_RECORD_NOTFOUND - Billing record not found
- INVOICE_CLEARING_RECORD_NOTFOUND - Invoice clearing record not found
- TOO_MANY_RECORDS_FOR_INV_NUMBER - There are multiple invoices for the given invoice number
- NOT_AUTHORIZED - Not authorized
- NOT_AUTHENTICATED - Not authenticated
- INT_APP_ERROR - Unexpected internal error
Error items:
- invalid value - clearingTypeId can not be nil
- invalid value - clearingTypeId can not be 1
- invalid value - clearingTypeId must be in (2,3,4)
- invalid value - recordDate can not be nil
- invalid value - RecordDate date invalid
- invalid value - paymentTypeID can not be nil
- PAYMENT_TYPE_NOT_FOUND - Payment type not found
- invalid value - amountIncrement must not be empty or 0 for clearingTypeId 3 or 4
- invalid value - paidAmount must not be empty less than 0 for clearingTypeId 2 or 5
- payment overflow - maximum paidAmount can be <totalUnpaid>
- invalid value - bank account id not provided
- invalid value - bank account with given id not found
- invalid value - bank account currency and invoice currency do not match
- BANK_ACC_NOT_ALLOWED_FOR_PAYMENT_TYPE - Bank acc not allowed for payment type: 'paymentTypeName'
Request
Path parameters
Invoice number. If value contains %, it is URL-decoded.
Body required
Required and non-zero for clearingTypeId 3 or 4; otherwise 0
Required for paymentTypeId 1 (Bank Transfer); must be 0 for other payment types. Use 0 for default bank account.
2=Payment (paidAmount required), 3=Interest (amountIncrement required), 4=Reminder (amountIncrement required). 1=Invoice is auto-generated and cannot be sent.
2, 3, 4If omitted, set to clearing type name
Required and positive for clearingTypeId 2 (Payment); must not exceed invoice totalUnpaid
1=Bank Transfer (bankAccountId required or 0 for default), 2=Credit Card, 3=Paypal, 4=Cash
1, 2, 3, 4Date in YYYY-MM-DD format
Request example
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <access_token>");
var content = new StringContent("{\"amountIncrement\":0,\"bankAccountId\":1,\"clearingTypeId\":2,\"paidAmount\":100.5,\"paymentReference\":\"REF-001\",\"paymentTypeId\":1,\"recordDate\":\"2026-01-15\"}", null, "application/json");
request.Content = content;
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-by-number/{invoiceNumber}/clearingrecords", Method.Post);
request.AddHeader("Content-Type", "application/json");
request.AddHeader("Accept", "application/json");
request.AddHeader("Authorization", "Bearer <access_token>");
var body = "{\"amountIncrement\":0,\"bankAccountId\":1,\"clearingTypeId\":2,\"paidAmount\":100.5,\"paymentReference\":\"REF-001\",\"paymentTypeId\":1,\"recordDate\":\"2026-01-15\"}";
request.AddStringBody(body, DataFormat.Json);
RestResponse response = await client.ExecuteAsync(request);
Console.WriteLine(response.Content);curl -L -X POST "https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords" \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-H "Authorization: Bearer <access_token>" \
--data-raw '{
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
}'var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer <access_token>'
};
var data = json.encode({
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
});
var dio = Dio();
var response = await dio.request(
'https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords',
options: Options(
method: 'POST',
headers: headers,
),
data: data,
);
if (response.statusCode == 200) {
print(json.encode(response.data));
}
else {
print(response.statusMessage);
}var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer <access_token>'
};
var request = http.Request('POST', Uri.parse('https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords'));
request.body = json.encode({
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
});
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"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords"
method := "POST"
payload := strings.NewReader(`{
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
}`)
client := &http.Client{}
req, err := http.NewRequest(method, url, payload)
if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")
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))
}POST /finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords HTTP/1.1
Host: api-cpaas.sms.es
Content-Type: application/json
Accept: application/json
Authorization: Bearer <access_token>
Content-Length: 150
{
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
}OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"amountIncrement\":0,\"bankAccountId\":1,\"clearingTypeId\":2,\"paidAmount\":100.5,\"paymentReference\":\"REF-001\",\"paymentTypeId\":1,\"recordDate\":\"2026-01-15\"}");
Request request = new Request.Builder()
.url("https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords")
.method("POST", body)
.addHeader("Content-Type", "application/json")
.addHeader("Accept", "application/json")
.addHeader("Authorization", "Bearer <access_token>")
.build();
Response response = client.newCall(request).execute();Unirest.setTimeouts(0, 0);
HttpResponse<String> response = Unirest.post("https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords")
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.header("Authorization", "Bearer <access_token>")
.body("{\"amountIncrement\":0,\"bankAccountId\":1,\"clearingTypeId\":2,\"paidAmount\":100.5,\"paymentReference\":\"REF-001\",\"paymentTypeId\":1,\"recordDate\":\"2026-01-15\"}")
.asString();const myHeaders = new Headers();
myHeaders.append("Content-Type", "application/json");
myHeaders.append("Accept", "application/json");
myHeaders.append("Authorization", "Bearer <access_token>");
const raw = JSON.stringify({
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
});
const requestOptions = {
method: "POST",
headers: myHeaders,
body: raw,
redirect: "follow"
};
fetch("https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords", 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-by-number/{invoiceNumber}/clearingrecords",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer <access_token>"
},
"data": JSON.stringify({
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
})
};
$.ajax(settings).done(function (response) {
console.log(response);
});var data = JSON.stringify({
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.setRequestHeader("Authorization", "Bearer <access_token>");
xhr.send(data);val client = OkHttpClient()
val mediaType = "application/json".toMediaType()
val body = """
{
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
}
""".trimIndent().toRequestBody(mediaType)
val request = Request.Builder()
.url("https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords")
.post(body)
.addHeader("Content-Type", "application/json")
.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, "POST");
curl_easy_setopt(curl, CURLOPT_URL, "https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords");
curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L);
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "Content-Type: application/json");
headers = curl_slist_append(headers, "Accept: application/json");
headers = curl_slist_append(headers, "Authorization: Bearer <access_token>");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
const char *data = "{\"amountIncrement\":0,\"bankAccountId\":1,\"clearingTypeId\":2,\"paidAmount\":100.5,\"paymentReference\":\"REF-001\",\"paymentTypeId\":1,\"recordDate\":\"2026-01-15\"}";
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data);
CURLcode res = curl_easy_perform(curl);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
}
return 0;
}const axios = require('axios');
let data = JSON.stringify({
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
});
let config = {
method: 'post',
maxBodyLength: Infinity,
url: 'https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Bearer <access_token>'
},
data : data
};
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': 'POST',
'hostname': 'api-cpaas.sms.es',
'path': '/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords',
'headers': {
'Content-Type': 'application/json',
'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);
});
});
let postData = JSON.stringify({
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
});
req.write(postData);
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-by-number/{invoiceNumber}/clearingrecords"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
NSDictionary *headers = @{
@"Content-Type": @"application/json",
@"Accept": @"application/json",
@"Authorization": @"Bearer <access_token>"
};
[request setAllHTTPHeaderFields:headers];
NSData *postData = [[NSData alloc] initWithData:[@"{\"amountIncrement\":0,\"bankAccountId\":1,\"clearingTypeId\":2,\"paidAmount\":100.5,\"paymentReference\":\"REF-001\",\"paymentTypeId\":1,\"recordDate\":\"2026-01-15\"}" dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:postData];
[request setHTTPMethod:@"POST"];
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 postData = ref {|{
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
}|};;
let reqBody =
let uri = Uri.of_string "https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords" in
let headers = Header.init ()
|> fun h -> Header.add h "Content-Type" "application/json"
|> fun h -> Header.add h "Accept" "application/json"
|> fun h -> Header.add h "Authorization" "Bearer <access_token>"
in
let body = Cohttp_lwt.Body.of_string !postData in
Client.call ~headers ~body `POST 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-by-number/{invoiceNumber}/clearingrecords',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
}',
CURLOPT_HTTPHEADER => array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer <access_token>'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
<?php
$client = new Client();
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
'Authorization' => 'Bearer <access_token>'
];
$body = '{
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
}';
$request = new Request('POST', 'https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords', $headers, $body);
$res = $client->sendAsync($request)->wait();
echo $res->getBody();
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
$headers.Add("Accept", "application/json")
$headers.Add("Authorization", "Bearer <access_token>")
$body = @"
{
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
}
"@
$response = Invoke-RestMethod "https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords" -Method 'POST' -Headers $headers -Body $body
$response | ConvertTo-Jsonimport requests
import json
url = "https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords"
payload = json.dumps({
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
})
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer <access_token>"
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)import http.client
import json
conn = http.client.HTTPSConnection("api-cpaas.sms.es")
payload = json.dumps({
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
})
headers = {
"Content-Type": "application/json",
"Accept": "application/json",
"Authorization": "Bearer <access_token>"
}
conn.request("POST", "/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))library(httr)
headers = c(
'Content-Type' = 'application/json',
'Accept' = 'application/json',
'Authorization' = 'Bearer <access_token>'
)
body = '{
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
}';
res <- VERB("POST", url = "https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords", body = body, 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-by-number/{invoiceNumber}/clearingrecords")
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request["Accept"] = "application/json"
request["Authorization"] = "Bearer <access_token>"
request.body = JSON.dump({
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
})
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("Content-Type", "application/json".parse()?);
headers.insert("Accept", "application/json".parse()?);
headers.insert("Authorization", "Bearer <access_token>".parse()?);
let data = r#"{
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
}"#;
let json: serde_json::Value = serde_json::from_str(&data)?;
let request = client.request(reqwest::Method::from_bytes(b"POST")?, "https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords")
.headers(headers)
.json(&json);
let response = request.send().await?;
let body = response.text().await?;
println!("{}", body);
Ok(())
}printf '{"amountIncrement":0,"bankAccountId":1,"clearingTypeId":2,"paidAmount":100.5,"paymentReference":"REF-001","paymentTypeId":1,"recordDate":"2026-01-15"}' | http --follow --timeout 3600 POST "https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords" \
'Content-Type':'application/json' \
'Accept':'application/json' \
'Authorization':'Bearer <access_token>'wget --no-check-certificate --quiet \
--method POST \
--timeout=0 \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer <access_token>' \
--body-data '{"amountIncrement":0,"bankAccountId":1,"clearingTypeId":2,"paidAmount":100.5,"paymentReference":"REF-001","paymentTypeId":1,"recordDate":"2026-01-15"}' \
'https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords'let parameters = """
{
"amountIncrement": 0,
"bankAccountId": 1,
"clearingTypeId": 2,
"paidAmount": 100.5,
"paymentReference": "REF-001",
"paymentTypeId": 1,
"recordDate": "2026-01-15"
}
"""
let postData = parameters.data(using: .utf8)
var request = URLRequest(url: URL(string: "https://api-cpaas.sms.es/finance/sit/v1/invoices-by-number/{invoiceNumber}/clearingrecords")!,timeoutInterval: Double.infinity)
request.addValue("application/json", forHTTPHeaderField: "Content-Type")
request.addValue("application/json", forHTTPHeaderField: "Accept")
request.addValue("Bearer <access_token>", forHTTPHeaderField: "Authorization")
request.httpMethod = "POST"
request.httpBody = postData
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 added; returns the created record
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": "active",
"statusDate": "2026-01-15T10:00:00.000Z"
}Bad Request - Missing context or validation 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": "REQUEST_ERROR",
"message": "Bad Request"
}
}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 - Multiple invoices for number, or not allowed to add clearing record (netting member or collection member)
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": "COLLECTION_MEMBER_CLEARING_RECORD_NOT_ALLOWED",
"message": "Invoice is collection member.Collection members ar not allowed to have clearing records"
}
}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"
}
}