Here is a clarification on how to create a credit note or allocate a receipt or credit note to an invoice through API, where you can allocate a receipt or credit note to the invoice using the code shown here:
API Link
You can view how to create a credit note through the API via the following link: API Link
How to Allocate:
-
source_type:
-
Determines whether the allocation is for a credit note (credit note) or a receipt (Receipt).
-
This field is mandatory and must be selected carefully.
-
-
Source id:
-
It is the identifier for the receipt or credit note (not the reference).
-
It can be obtained through API integration or may appear directly in the receipt or credit note link.
-
-
date:
-
The allocation date (mandatory).
-
-
amount:
-
The amount to be allocated.
-
You must ensure that the amount does not exceed the invoice value.
-
Additional Notes:
-
All the fields mentioned are mandatory and no field can be left empty.
-
The invoice must be unpaid to complete the allocation process.