Light APIv1.0.0

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

  • customerCreditId string · uuidrequired

  • invoiceReceivableId string · uuidrequired

Request body

application/json;charset=UTF-8

  • amount integer · int64

    Amount 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

  • companyId string · uuid

    ID of the company

  • customerCredit object

    Invoice payable details

    • id string · uuid

      Unique identifier for the object

    • documentNumber string

      Document number

    • documentDate string · date

      Date the accounting document was issued

    • status string

      Status of the accounting document

      ⚠️ This enum is not exhaustive; new values may be added in the future.

      One of DRAFT APPROVAL_PENDING APPROVED POSTED PARTIALLY_CLEARED CLEARED ARCHIVED

    • amount integer · int64

      The amount of the accounting document in cents

    • currency string

  • invoiceReceivable object

    Invoice payable details

    • id string · uuid

      Unique identifier for the object

    • documentNumber string

      Document number

    • documentDate string · date

      Date the accounting document was issued

    • status string

      Status of the accounting document

      ⚠️ This enum is not exhaustive; new values may be added in the future.

      One of DRAFT APPROVAL_PENDING APPROVED POSTED PARTIALLY_CLEARED CLEARED ARCHIVED

    • amount integer · int64

      The amount of the accounting document in cents

    • currency string

  • amount integer · int64

    Amount of the customer credit applied to the sales invoice, in the smallest currency unit

  • linkedAt string · date-time

    Timestamp when the customer credit was linked to the sales invoice