Recommended: report the balance you know
Rather than computing the opening balance yourself, passreported_balance when you create or update the loan: the outstanding principal at any point in time. Layer derives the opening balance from your assertion and the proceeds and payments already recorded on the loan.
Request
- If recorded proceeds and payments fully explain the reported balance, no opening balance is created (and any existing one is cleared).
- If the derivation would be negative (recorded proceeds exceed the reported balance plus the principal already recorded as repaid), the request fails with a
400. This is a built-in consistency check on your data. - Re-sending
reported_balanceafter backfilling more history re-derives the opening balance. Because creating a loan with an existingexternal_idupserts it, syncs can include the assertion on every run.
at to a time you actually know the balance for: typically the moment your reliable data begins, such as just before the first repayment you will record. Avoid backdating into periods whose books are already closed: prior statements were delivered without this loan, and an entry dated inside them restates those books.
Alternative: set the opening balance directly
If you have already computed the outstanding principal net of everything you plan to record, setopening_balance explicitly instead. It is mutually exclusive with reported_balance.
Request
opening_balance leaves it unchanged, and passing null explicitly removes it (the ledger entry is reversed). The balance must be positive, and effective_at must be on or before every recorded proceed and payment on the loan. Proceed and payment dates are evaluated as midnight US Eastern time at the start of their date, so an opening balance effective at exactly that instant counts as on or before a same-day event.
Loan responses include the active opening_balance, so you can always read back what is currently set.
Recording history the opening balance already includes
The opening balance marks where the loan’s recorded history begins, so proceeds and payments dated before itseffective_at are rejected: recording them would double-count activity the opening balance already reflects. An event counts as before the opening balance only when midnight US Eastern time at the start of its date is strictly earlier than effective_at; a same-instant event is treated as on or after it and records normally.
If you later obtain real historical records (for example, paydowns from before the loan entered Layer, or the original disbursement), record them with included_in_opening_balance: true. Layer backs each event out of the opening balance (a payment’s principal portion increases it, a proceed’s amount decreases it) and moves the opening balance’s effective_at back to the event date, so the explicit record replaces what the opening balance implied and the loan’s balance is unchanged.
Continuing the example above, backfilling one of the pre-Layer repayments raises the opening balance from $12,000.00 to $13,000.00, while the payment itself brings the balance right back down (the MCA’s derived split puts $1,000.00 to principal and $150.00 to fee):
Request
effective_at. If you have events in arbitrary order, record the later ones normally and re-send reported_balance afterwards to re-derive the opening balance.