Endpoint
Authentication
Requires authentication withBearer token.
Access Control
- Admin: Can update any repayment, including amount changes
- Supervisor: Can update repayments in their unions (except amount changes), within 24 hours of creation
- Credit Officer: Cannot update repayments
Path Parameters
The unique identifier of the repayment to update
Request Body
New payment amount. Admin only. Changing the amount will:
- Reverse the original allocations
- Delete existing allocation records
- Reallocate the new amount to schedule items
- Recalculate the remaining schedule
- Update the loan status if needed
Update the payment method. Options:
CASH- Cash paymentTRANSFER- Bank transferPOS- Point of sale terminalMOBILE- Mobile money (e.g., M-Pesa)USSD- USSD paymentOTHER- Other payment methods
Update the payment reference number or transaction ID
Update notes about the payment
Time Restrictions
Response
Indicates if the update was successful
Response message (e.g., “Repayment updated successfully”)
The updated repayment object
Unique identifier for the repayment record
ID of the loan this repayment is for
Updated payment amount
Currency code for the payment
Date and time when payment was made (ISO 8601)
Updated payment method (CASH, TRANSFER, POS, MOBILE, USSD, OTHER)
Updated payment reference number or transaction ID
Updated notes about the payment
ID of the user who originally recorded this repayment (unchanged)
Loan details with borrower information
Loan ID
Unique loan number
Original loan amount
Current loan status (may have changed if amount was updated)
Timestamp when repayment record was originally created (unchanged)
Timestamp when repayment record was last updated
Example Request - Update Method and Reference
Example Response
Example Request - Update Amount (Admin Only)
Amount Update Process
When an Admin changes the repayment amount:Step 1: Reverse Original Allocations
The system finds all allocations for this repayment and reverses them:- Updates schedule items by subtracting the allocated amounts from
paidAmount - Recalculates schedule item statuses (PAID → PARTIAL or PENDING)
- Clears
closedAttimestamps
Step 2: Delete Old Allocations
AllRepaymentAllocation records for this repayment are deleted.
Step 3: Reallocate with New Amount
The new amount is allocated to schedule items following the same rules as creating a new repayment:- Sequential allocation by due date (oldest first)
- Handles partial and excess payments
- Creates new allocation records
Step 4: Recalculate Schedule
All remaining schedule items are recalculated to ensure consistency.Step 5: Update Loan Status
If the amount change affects the total amount repaid, the loan status may transition:- If loan becomes fully paid →
COMPLETED - If loan was completed but now has balance →
ACTIVE
Common Use Cases
Correcting Payment Method
If a payment was recorded with the wrong method:Adding Transaction Reference
If the reference was initially missing:Correcting Amount (Admin)
If the payment amount was recorded incorrectly:Error Responses
Bad request - validation errors
Unauthorized - missing or invalid authentication token
Forbidden - insufficient permissionsOr for time restrictions:
Not found - repayment does not exist
Permission Summary
| Field | Credit Officer | Supervisor | Admin |
|---|---|---|---|
| method | ❌ Cannot update | ✅ Within 24h | ✅ Anytime |
| reference | ❌ Cannot update | ✅ Within 24h | ✅ Anytime |
| notes | ❌ Cannot update | ✅ Within 24h | ✅ Anytime |
| amount | ❌ Cannot update | ❌ Cannot update | ✅ Anytime |
Audit Trail
All repayment update actions are automatically logged to the audit trail with:- Action:
REPAYMENT_UPDATED - Entity:
Repayment - Actor: Authenticated user who updated the repayment
- Before: Original repayment data
- After: Updated repayment data
- Timestamp: When the update was performed
Best Practices
- Update promptly: If you notice an error, update the repayment within 24 hours to avoid needing Admin intervention
- Add notes: Always include notes explaining why the update was made for audit purposes
- Verify before updating: Double-check the new values before updating, especially for amount changes
- Amount changes: Only use amount updates for genuine errors - don’t use this to reverse payments (use delete endpoint instead)
