API / Reference / Customer Credits
Link customer credit to invoice
POST
https://api.light.inc/v1/customer-credits/{customerCreditId}/invoice-receivables/{invoiceReceivableId}/link
Links a customer credit to a sales invoice
Identical to POST .../invoice-receivables/{invoiceReceivableId}; this is the newer path. When the credit is applied depends on its status: linking a POSTED credit clears the invoice immediately (it moves to PARTIALLY_PAID or PAID in this call), while linking a DRAFT credit only records the link, applied when the credit is posted. Requirements: invoice OPEN or PARTIALLY_PAID; credit DRAFT or POSTED; same customer, entity and currency; the credit's header amount set (CUSTOMER_CREDIT_AMOUNT_NOT_SET); not already linked (CUSTOMER_CREDIT_ALREADY_LINKED). The description of amount has it backwards: partial allocation is a capability granted by the entity's e-invoicing configuration, and an entity without one gets one link per credit with amount omitted or equal to the whole available credit (CUSTOMER_CREDIT_PARTIAL_ALLOCATION_NOT_ENABLED). The response's amount is what was actually linked: the requested amount, else the smaller of the credit and the invoice balance.
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
-
customerCreditIdstring · uuidrequired -
invoiceReceivableIdstring · uuidrequired
Request body
application/json;charset=UTF-8
-
amountinteger · int64Amount of the customer credit to apply to the sales invoice, in the smallest currency unit. If omitted, the remaining unallocated customer-credit balance is applied, capped by the invoice receivable's remaining balance. Partial allocation is not supported for entities configured with an e-invoicing provider.
Response
-
companyIdstring · uuidID of the company
-
customerCreditobjectInvoice 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
-
-
invoiceReceivableobjectInvoice 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 · int64Amount of the customer credit applied to the sales invoice, in the smallest currency unit
-
linkedAtstring · date-timeTimestamp when the customer credit was linked to the sales invoice