Add clearing record to invoice (by invoice number)

POST/invoices-by-number/{invoiceNumber}/clearingrecords

Adds 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'
Base URL
https://api-cpaas.sms.es/finance/sit/v1
Authentication

OAuth2 — send Authorization: Bearer <access_token>. Token URL: https://accounts-cpaas.sms.es/oauth2/access-token

Request

Path parameters

invoiceNumberstringrequired

Invoice number. If value contains %, it is URL-decoded.

Body required

application/json
amountIncrementnumber (float)

Required and non-zero for clearingTypeId 3 or 4; otherwise 0

bankAccountIdinteger

Required for paymentTypeId 1 (Bank Transfer); must be 0 for other payment types. Use 0 for default bank account.

clearingTypeIdintegerrequired

2=Payment (paidAmount required), 3=Interest (amountIncrement required), 4=Reminder (amountIncrement required). 1=Invoice is auto-generated and cannot be sent.

Possible values: 2, 3, 4
commentstring

If omitted, set to clearing type name

paidAmountnumber (float)

Required and positive for clearingTypeId 2 (Payment); must not exceed invoice totalUnpaid

paymentReferencestring
paymentTypeIdintegerrequired

1=Bank Transfer (bankAccountId required or 0 for default), 2=Credit Card, 3=Paypal, 4=Cash

Possible values: 1, 2, 3, 4
recordDatestring (date)required

Date in YYYY-MM-DD format

Request example

cURL · cURL
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"
}'

Responses

Clearing record added; returns the created record

application/json
amountIncrementnumber (float)
bankAccountIbanstring
bankAccountIdinteger
bankAccountNamestring
bankAccountNumberstring
bankAccountSwiftBicstring
clearingIdinteger
clearingTypeCodeNamestring
clearingTypeIdinteger
commentstring
idinteger
paidAmountnumber (float)
paymentReferencestring
paymentTypeIdinteger
paymentTypeNamestring
recordDatestring (date)
revokeCommentstring
revokeUserIdstring
revokeUserNamestring
statusstring

active or canceled

statusDatestring | null (date-time)
Example response
{
  "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"
}