Roll back a loan
Loans
Roll back a loan
Tear down a loan whose wallet disbursement failed — one call instead of three.
POST
Roll back a loan
Removes a loan that should never have existed — the exception flow for
a failed wallet disbursement. One call performs the full teardown
internally (
So the partner-side recovery logic collapses to: call rollback until
you get
The body is optional; POST with no body is valid.
After a successful rollback the loan no longer appears in queries —
undo-disbursal → undo-approval → delete) and returns
a single response, so your exception handler doesn’t need to chain
three synchronous requests.
The three individual endpoints remain available; rollback is the
consolidated form built on top of them.
Resumable by design
Each teardown step is durable in the LMS the moment it succeeds. If a step fails (or your call times out mid-sequence), the loan is left at a well-defined interim state — and calling rollback again resumes from that state instead of failing on steps that already ran:| Loan status when called | Steps performed |
|---|---|
Active | undo-disbursal → undo-approval → delete |
Approved | undo-approval → delete |
Submitted and pending approval | delete |
Closed (obligations met), Closed (written off), Overpaid | rejected with 409 aborted — settled loans can’t be rolled back |
200. There is no partial-failure state you need to
disambiguate yourself — but if you want to inspect anyway,
GET /v1/loans/external/{loan_external_id} reports the interim status
dynamically after every step (Active → Approved →
Submitted and pending approval → 404 once deleted).
Path parameters
The loan’s externalId. On the
/v1/loans/{loan_id}/rollback form,
this is the numeric LMS id instead.Request body
Optional. Reason for the rollback — recorded against both undo steps
in the LMS audit log.
Examples
Response
200 OK with the steps that ran on this call. A rollback resumed from
an interim state reports only the remaining steps it executed.
GET /v1/loans/external/{loan_external_id} returns 404. The LMS
retains the full activity history (creation, approval, disbursal,
every reversal, deletion) in its audit log.
Errors
| Code | When |
|---|---|
not_found | No loan with that id or externalId (including a loan already fully rolled back) |
aborted | Loan is settled (Closed / Overpaid), or has recorded repayments — rollback is not applicable in either case |
| other | A teardown step failed mid-sequence. The message names the step that halted and the steps already completed; completed steps are durable — call rollback again to resume |

