A contract records what a customer buys, from when, and how often it is billed. Each contract line is a product with its own quantity, price and billing dates. A contract is created as a DRAFT; publishing it makes it ACTIVE, and Light then invoices it on its schedule.
An ACTIVE contract is changed through an edit. Opening and publishing an edit do not change the contract's state, and invoices Light generates while the edit is open follow the published version.
POST /v1/contracts/{contractId}/begin-editopens the edit.hasWorkingVersionbecomestrue. A contract has one open edit at a time: a second begin-edit, or a begin-edit on a contract that is notACTIVE, returnsCONTRACT_CANNOT_BE_MODIFIED.- Make the changes with
PATCH /v1/contracts/{contractId}. While the edit is open,GET /v1/contracts/{contractId}returns the edit's fields and lines. POST /v1/contracts/{contractId}/publishapplies the edit. The contract's state does not change andhasWorkingVersiongoes back tofalse.GET /v1/contracts/{contractId}returns the published contract.
POST /v1/contracts/{contractId}/cancel-edit discards the edit instead and restores the published version.
What an edit can change
- On the contract:
startDate,endDate,renewalDate,estimatedAmount,netTerms,invoiceLeadDays,payeeBankAccountId,descriptionandcustomProperties. The other fields of the update request, such ascurrency,companyEntityId,invoiceTemplateId,paymentType,billingStartorareLinesWithTax, returnCONTRACT_CANNOT_BE_MODIFIED.
What an edit cannot change
- A line that was already published, apart from its
customProperties. A change to any other field of that line, such asquantity,priceOverwrite,discountorproductId, and deleting the line returnCONTRACT_LINE_CANNOT_BE_MODIFIED. A newbillingEndis the exception: the update may accept it, and publish can then returnCONTRACT_AMENDMENT_REQUIRED. The edit stays open after that refused publish; cancel it to discard the change. - An invoiced period. A new
startDateorendDatethat changes an invoiced period is refused at publish with one ofCONTRACT_LINE_WOULD_MODIFY_INVOICED_PERIODS,CONTRACT_START_DATE_WOULD_MODIFY_INVOICED_PERIODS(when the newstartDatealone causes it) orCONTRACT_PART_PERIOD_ALREADY_INVOICED(when, on a prorated contract, the edit would bill more days of a part period whose invoice is no longer a draft). The exception is a change on a prorated contract that only adds days to a period whose invoice is still a draft: it publishes and updates that draft.
Publishing an edit in which no change was made returns CONTRACT_CANNOT_BE_PUBLISHED.
Reset
POST /v1/contracts/{contractId}/reset takes an ACTIVE contract back to DRAFT. It:
- archives the draft invoices the contract's schedule created;
- reverses the contract's posted deferred revenue entries and archives its draft ones;
- unlinks every invoice from the contract, posted ones included;
- clears the agreed unit price of every line, so a line priced from the product catalog is published again at the product's current price.
Publishing the contract again is a first publish: it creates draft invoices for the periods of the contract's schedule up to today, including periods the customer was already billed for.
Lowering the quantity of a published line is not possible in an edit, so today it needs a reset, with these effects.
Retries
Every call above that changes the contract accepts an X-Idempotency-Key header. A retry with the same key returns the first result instead of running the call again. See Idempotency.