Send the loan’s whole history
If you can send every proceed and payment back to the loan’s origination, do that and send no balance at all.- If none of that history predates the business’s activation date, the recorded events explain the loan on their own and there is no opening balance.
- If some of it does, Layer rolls that part up into an opening balance dated at the activation date. Events on or after activation post normally on top of it.
When you cannot reach the start of the loan
If your data begins partway through the loan’s life, passreported_balance when you create or update the loan, and send every event from that point on.
Request
at to the earliest date you can state the balance for, not the most recent. It marks where your knowledge of the loan begins, and events dated before it are rejected, so an at that is later than necessary shuts out history you could otherwise record.
- If
atis on or before the business’s activation date, Layer rolls the balance forward through any events between the two and dates the opening balance at activation. - If
atis after activation, the opening balance is dated atat. atcannot precede the loan’sorigination_date, and it cannot postdate history already recorded on the loan.
Recording earlier history later
If you later obtain records from before your currentat, re-send reported_balance with the earlier date and the balance as of that date, then send the events. The assertion is the boundary, so the boundary has to move before the earlier events will be accepted.
Once your history reaches the loan’s origination, retract the assertion by sending reported_balance as null on an update, and let the recorded events speak for themselves. Simply omitting reported_balance does not retract it, and neither does re-sending the loan through POST /loans. After a retraction, Layer re-derives the opening balance from the loan’s recorded history alone: if the history predating the activation date leaves principal outstanding, an opening balance remains, now dated at activation; if the loan was already repaid by then, none does.
Loan responses include the active opening_balance, so you can always read back what Layer currently derives.