Skip to main content

Consumer Loans (/api/v1/loans)

Endpoints for creating, managing, extracting, and predicting risk for Consumer Loan Applications.

All endpoints require authentication via X-API-Key. Certain endpoints also require credit consumption.


1. Create Loan

Save a new consumer loan application.

  • Method: POST
  • Endpoint: /api/v1/loans
  • Authentication: Required

Request Body

ParameterTypeDescription
ageIntegerApplicant age
incomeNumberAnnual income
loanAmountNumberRequested loan amount
creditScoreIntegerCredit score
monthlyExpensesNumberTotal monthly expenses
numberOfCreditLinesIntegerNumber of open credit lines
interestRateNumberInterest rate
loanTermIntegerLoan term in months
dtiRatioNumberDebt-to-income ratio
educationStringEducation level
employmentTypeStringEmployment type
maritalStatusStringMarital status
hasMortgageBooleanWhether applicant has a mortgage
hasDependentsBooleanWhether applicant has dependents
loanPurposeStringPurpose of the loan
hasCoSignerBooleanWhether there is a co-signer
businessRevenueNumberBusiness revenue (optional)
applicationDateStringApplication date (optional)
actionTakenStringAction taken (optional)
creditTypeStringCredit type (optional)
creditPurposeStringCredit purpose (optional)
pricingInfoStringPricing info (optional)
censusTractStringCensus tract (optional)
probabilityOfDefaultNumberPre-calculated PD (optional)
notesStringUnderwriter notes (optional)

Response (201 Created)

{
"id": "uuid",
"age": 35,
"income": 85000.00,
"loanAmount": 50000.00,
"creditScore": 720,
"monthlyExpenses": 2000.00,
"numberOfCreditLines": 8,
"interestRate": 5.50,
"loanTerm": 36,
"dtiRatio": 12.50,
"education": "Bachelor",
"employmentType": "Full-time",
"maritalStatus": "Married",
"hasMortgage": true,
"hasDependents": false,
"loanPurpose": "Home Improvement",
"hasCoSigner": false,
"businessRevenue": null,
"applicationDate": null,
"actionTaken": null,
"creditType": null,
"creditPurpose": null,
"pricingInfo": null,
"censusTract": null,
"probabilityOfDefault": null,
"notes": null,
"status": "PENDING",
"createdAt": "2025-01-01T00:00:00.000Z",
"updatedAt": "2025-01-01T00:00:00.000Z",
"userId": "uuid",
"user": {
"id": "uuid",
"name": "John Doe",
"email": "john@example.com",
"orgId": "uuid-or-null"
}
}

2. Create Loan for Org User

Organisation owners can create a loan on behalf of a member.

  • Method: POST
  • Endpoint: /api/v1/loans/org-user
  • Authentication: Required (OWNER role)

Request Body

Same fields as Create Loan plus:

ParameterTypeDescription
targetUserIdStringRequired. UUID of the organisation member

3. Get Loan by ID

Retrieve a specific loan.

  • Method: GET
  • Endpoint: /api/v1/loans/:id

Response

{
"id": "uuid",
"loanAmount": 50000.00,
"status": "PENDING",
...all_loan_fields,
"user": { "name": "John Doe", "email": "john@example.com" }
}

4. Update Loan

Update a loan's fields and/or status.

  • Method: PUT
  • Endpoint: /api/v1/loans/:id

Request Body

Same fields as Create Loan, plus:

ParameterTypeDescription
statusStringPENDING, APPROVED, or REJECTED

5. Delete Loan

Delete a loan.

  • Method: DELETE
  • Endpoint: /api/v1/loans/:id

Response

{ "message": "Loan deleted successfully" }

6. Predict Risk (Consumer Loan)

Execute the risk prediction algorithm on a consumer loan based on JSON input. Consumes credits (LOAN_PREDICTION).

  • Method: POST
  • Endpoint: /api/v1/loans/predict
  • Credits: 1 per call

Request Body

{
"Age": 35,
"Income": 85000,
"LoanAmount": 15000,
"CreditScore": 720,
"MonthsEmployed": 24,
"NumCreditLines": 8,
"InterestRate": 10.5,
"LoanTerm": 36,
"DTIRatio": 12.5,
"Education": "Bachelor",
"EmploymentType": "Full-time",
"MaritalStatus": "Married",
"HasMortgage": "Yes",
"HasDependents": "No",
"LoanPurpose": "home_improvement",
"HasCoSigner": "No",
"Name": "John Doe",
"Address": "123 Main St, Anytown, USA"
}
curl -X POST https://api.riskinmind.ai/api/v1/loans/predict \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"Age": 35,
"Income": 85000,
"LoanAmount": 15000,
"CreditScore": 720,
"MonthsEmployed": 24,
"NumCreditLines": 8,
"InterestRate": 10.5,
"LoanTerm": 36,
"DTIRatio": 12.5,
"Education": "Bachelor",
"EmploymentType": "Full-time",
"MaritalStatus": "Married",
"HasMortgage": "Yes",
"HasDependents": "No",
"LoanPurpose": "home_improvement",
"HasCoSigner": "No",
"Name": "John Doe",
"Address": "123 Main St"
}'

Response

  • Content-Type: application/json
{
"probability": 0.85,
"rejection_probability": 0.15
}

7. Generate Reports (Consumer & Commercial)

Trigger report generation based on the loan's data and return a PDF binary stream. Consumes credits (LOAN_REPORT_GEN).

Consumer Report

  • Method: POST
  • Endpoint: /api/v1/loans/report/consumer

Commercial Report

  • Method: POST
  • Endpoint: /api/v1/loans/report/commercial

Request Body

ParameterTypeDescription
nameStringBorrower name
AgeNumberApplicant age
IncomeNumberAnnual income
LoanAmountNumberLoan amount
CreditScoreNumberCredit score
MonthsEmployedNumberMonths employed
NumCreditLinesNumberNumber of credit lines
InterestRateNumberInterest rate
LoanTermNumberLoan term (months)
LoanPurposeStringPurpose of the loan
DTIRatioNumberDebt-to-income ratio
PostLoanApprovalDTIRatioNumberPost-loan DTI ratio
EducationStringEducation level
EmploymentTypeStringEmployment type
MaritalStatusStringMarital status
HasDependentsBooleanHas dependents
NumDependentsNumberNumber of dependents
HasCoSignerBooleanHas co-signer
UnderwriterNotesStringUnderwriter notes
HasMortgageBooleanHas mortgage
MonthlyMortgageNumberMonthly mortgage payment
MonthlyPropertyTaxesNumberMonthly property taxes
MonthlyInsuranceNumberMonthly insurance
MonthlyHOANumberMonthly HOA fees
MonthlyAlimonyChildSupportNumberMonthly alimony/child support
MonthlyStudentLoanNumberMonthly student loan payment
OtherMonthlyDebtNumberOther monthly debt
MonthlyCreditCardNumberMonthly credit card expenses
MonthlyAutoLoanNumberMonthly auto loan payment
probability_of_defaultNumberProbability of default

Response

  • Content-Type: application/pdf
  • Returns: Binary PDF stream (consumer_loan_report.pdf or commercial_loan_report.pdf)
curl -X POST https://api.riskinmind.ai/api/v1/loans/report/consumer \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "name": "John Doe", "Age": 35, "Income": 85000, "LoanAmount": 15000 }' \
--output consumer_loan_report.pdf

8. CECL Prediction Engine

Calculate Current Expected Credit Losses (CECL) using the RiskInMind financial math engine. Consumes credits (CECL_ANALYSIS).

  • Method: POST
  • Endpoint: /api/v1/loans/cecl

Request Body (Array of loan exposures)

[
{
"loanId": "loan_123",
"exposureAtDefault": 50000,
"probabilityOfDefault": 0.02,
"lossGivenDefault": 0.45
}
]
curl -X POST https://api.riskinmind.ai/api/v1/loans/cecl \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '[
{
"loanId": "loan_123",
"exposureAtDefault": 50000,
"probabilityOfDefault": 0.02,
"lossGivenDefault": 0.45
}
]'

Response

{
"totalExpectedLoss": 450.00,
"breakdown": []
}

9. 1003 Loan Application Generation

Generate a standardized Uniform Residential Loan Application (Form 1003) PDF. Consumes credits (LOAN_1003_GEN).

  • Method: POST
  • Endpoint: /api/v1/loans/1003
  • Authentication: Required (OWNER role in organisation)

Request Body

ParameterTypeDescription
userIdStringUUID of the borrower
orgIdStringUUID of the organisation
borrowerObjectBorrower details (name, address, SSN, marital status, DOB, citizenship, dependents, etc.)
employmentObjectEmployment details (employer name, phone, address, income breakdown)
loan_propertyObjectLoan property details (amount, purpose, address)
declarationsObjectBankruptcy, judgments, citizenship, occupancy declarations
loan_originatorObjectOriginator details (org info, NMLSR ID, license, contact)
{
"userId": "user-uuid",
"orgId": "org-uuid",
"borrower": {
"first_name": "John",
"last_name": "Doe",
"marital_status": "Married",
"dependents": 2,
"ssn": "XXX-XX-XXXX",
"dob": "1990-01-15",
"citizenship_status": "US Citizen",
"current_address": {
"street": "123 Main St",
"city": "Anytown",
"state": "CA",
"zip_code": "12345"
}
},
"employment": {
"employer_name": "Acme Corp",
"phone": "555-0100",
"address": { "street": "456 Oak Ave", "city": "Anytown", "state": "CA", "zip_code": "12345" },
"base_income": 70000,
"overtime_income": 5000,
"bonus_income": 10000,
"commission_income": 0
},
"loan_property": {
"loan_amount": 350000,
"loan_purpose": "Purchase",
"property_address": {
"street": "789 Pine Rd",
"city": "Othertown",
"state": "CA",
"zip_code": "54321"
}
},
"declarations": {
"bankruptcy": false,
"outstanding_judgments": false,
"citizen_of_us": true,
"intend_to_occupy": true
},
"loan_originator": {
"organization_name": "RiskInMind Lending",
"originator_name": "Jane Agent",
"originator_nmlsr_id": "NMLS-12345",
"originator_email": "jane@riskinmind.com"
}
}

Response

  • Content-Type: application/pdf
  • Returns: Binary PDF stream of the completed 1003 form.

10. Get Extracted Loan Data

Retrieve aggregated extracted data from uploaded documents (bank statements, tax returns, pay stubs, etc.).

  • Method: GET
  • Endpoint: /api/v1/loans/extracted-data
  • Query Param: userId (optional — org owners can query their members)

Response

{
"success": true,
"data": {
"income": 85000,
"employer_name": "Acme Corp",
"bank_routing": "021000021",
...
},
"values": {
"income": "85000.00",
"employer_name": "Acme Corp",
...
}
}

11. Public Loan Data (Shareable)

Retrieve a loan's basic info and prediction without authentication — for shareable reports.

  • Method: POST
  • Endpoint: /api/v1/loans/public/data
  • Authentication: None

Request Body

{ "id": "loan-uuid" }

Response

{
"loan": {
"id": "uuid",
"loanAmount": 50000,
...
"user": { "name": "John Doe", "email": "john@example.com" }
},
"prediction": {
"probability_of_default": 0.05,
"probability_of_default_percent": "5.0%"
}
}

12. Email Public Loan Report

Share a loan report via email without authentication.

  • Method: POST
  • Endpoint: /api/v1/loans/public/email-report
  • Authentication: None

Request Body

{
"email": "recipient@example.com",
"borrower_name": "John Doe",
"loan_id": "loan-uuid",
"report_url": "https://riskinmind.com/share/..."
}

Response

{
"success": true,
"message": "Report shared successfully via email"
}