API / Reference / Credit Notes
Link credit note to invoice payable
POST
https://api.light.inc/v1/credit-notes/{creditNoteId}/invoice-payables/{invoicePayableId}
Links a credit note to an invoice payable for clearing (offsetting balances). Because credit notes cannot be applied in the ledger until the invoice payable is posted, this creates a 'link' record that will be used during posting to automatically clear the credit note balance against the invoice payable balance. Requirements: credit note must be in POSTED status, both documents must belong to the same company entity, same vendor (businessPartnerId), same currency, and clearing amount cannot exceed available balance on either document.
The credit note must be POSTED (or PARTIALLY_CLEARED); a draft fails with CREDIT_NOTE_CANNOT_BE_LINKED_UPDATED_UNLINKED. What the link does depends on the bill's state. A bill in IN_DRAFT or APPROVAL_PENDING only records the link, applied when the bill is posted; a posted, unpaid bill (UNPAID, READY_FOR_PAYMENT_RELEASE, SCHEDULED, PENDING_PAYMENT_APPROVAL) is cleared immediately and moves to PARTIALLY_PAID or COMPLETED — the response doesn't show that, so re-read the bill. amount has no default: it must be above zero (INVALID_LINKING_AMOUNT), within the note's unallocated amount (CREDIT_NOTE_AMOUNT_EXCEEDED), and for a posted bill within its remaining balance. Vendor, entity and currency must match; a pair already linked is CREDIT_NOTE_ALREADY_LINKED.
Authorization
Send one of these on every request. See Authentication for how to get credentials.
- API key
Basic authentication header of the form Basic <api_key>, where <api_key> is your api key.
- Bearer token
Path parameters
-
creditNoteIdstring · uuidrequired -
invoicePayableIdstring · uuidrequired
Request body
application/json;charset=UTF-8
-
amountinteger · int64Amount to clear in cents
No default. Must be above zero and within both the note's unallocated amount and, for a posted bill, its remaining balance.
Response
-
companyIdstring · uuidID of the company
-
creditNoteobjectInvoice payable details
-
idstring · uuidUnique identifier for the object
-
documentNumberstringDocument number
-
documentDatestring · dateDate the accounting document was issued
-
statusstringStatus of the accounting document
⚠️ This enum is not exhaustive; new values may be added in the future.
One of
DRAFTAPPROVAL_PENDINGAPPROVEDPOSTEDPARTIALLY_CLEAREDCLEAREDARCHIVED -
amountinteger · int64The amount of the accounting document in cents
-
currencystring
-
-
invoicePayableobjectInvoice payable details
-
idstring · uuidUnique identifier for the object
-
documentNumberstringDocument number
-
documentDatestring · dateDate the accounting document was issued
-
statusstringStatus of the accounting document
⚠️ This enum is not exhaustive; new values may be added in the future.
One of
DRAFTAPPROVAL_PENDINGAPPROVEDPOSTEDPARTIALLY_CLEAREDCLEAREDARCHIVED -
amountinteger · int64The amount of the accounting document in cents
-
currencystring
-
-
amountinteger · int64Clearing amount in cents
-
currencystring -
createdAtstring · date-timeTimestamp when the link was created
-
updatedAtstring · date-timeTimestamp when the link was last updated