Creating a Loan Application
Description
This web service creates a loan application for the marketplace. It commits an object of type Loan Application (peer__Loan_Application__c) to the database.
You can also use this API to refinance a regular or protect enabled loan.
Definition
POST https://<domain>/services/apexrest/peer/v1/loanApplications
Parameters
The table given below provides details of the request parameters used by this web service:
Field | Type | Description |
---|---|---|
amount* |
Decimal |
|
borrowerId* |
String |
|
createSchedule |
Integer |
This is used to define whether the disbursement schedule must be generated.
|
dueDay | Integer |
This is the payment due day that is considered for schedule generation. It must be a positive integer. Value of "31" sets the due date to the last day of the month for loans with monthly payments. The system automatically adjusts the due date as per the number of days in a given month, such as 31st for January and 28th for February. |
disbursalDate |
Date |
|
expiryDate |
Date |
|
interestRate* |
Decimal | This is the interest rate of the loan application. |
loanProductId | String |
|
maturityDate* | Date |
This is the last installment date that can be present on the loan. The loan__last_installment_date__c date field is updated with this value on the CL Contract object. If this value is not provided, the API uses the Term parameter to calculate the last installment date. Either this or the term parameter must be passed, else API error is returned. |
protectFeePercent | Decimal |
|
protectType | String |
The protect type has to be selected whether the borrower needs it on full loan amount or on partial loan amount. Selecting ‘Partial’ will result in the lender / investor receiving protection against payment default but not a write off. ‘Full’ protects lenders / investors in case of write off also. |
protectWaiverType | String |
|
purpose* |
String |
|
term* |
Integer |
This is the term of the loan application. It must be a positive integer. Either this or the Maturity Date parameter must be passed, else an API error is returned. |
additionalLoanAmount | Decimal | In case of a refinanced loan, this is the amount to be added to the existing loan amount that is being refinanced. You do not need to provide the loan amount if this parameter is provided. |
loansToBeRefinanced | String | The list of loan contract IDs to be passed, separated by comma. For example, ["a4y41000000LFb6", "a3y43200000KDb6"] |
eodAccrualType | String |
|
eodFeeAccrual | Boolean |
|
Error messages
When you use this web service you can receive the possible error messages as shown in the table below:
Error code | Error Message |
System.Label |
Reason | HTTP Status Code |
---|---|---|---|---|
INVALID_INPUT |
Unable to parse the Request parameters |
UNABLE_PARSE_REQ_PARAMS |
You will receive this error if an error occurs while parsing Request parameters. |
400 |
INVALID_INPUT |
Account Id is null |
ACCOUNT_ID_NULL |
You will receive this error if the Borrower Account Id (borrowerId) is not specified in the Request Parameters. |
400 |
INVALID_INPUT |
Unable to find the Account |
ACCOUNT_NOT_FOUND |
You will receive this error if no record exists in the system for the Borrower Account Id (borrowerId) specified in the Request Parameters. |
400 |
INVALID_INPUT |
Loan Purpose is not valid |
LOAN_PURPOSE_NOT_VALID |
You will receive this error if the Loan purpose is either null or not found in the system. |
400 |
INVALID_INPUT |
Loan amount is not valid |
LOAN_AMOUNT_NOT_VALID |
You will receive this error if the Loan amount is either null or a non-positive number. |
400 |
INVALID_INPUT |
Term is not valid |
TERM_NOT_VALID |
You will receive this error if the Term is either null or a non-positive number. |
400 |
API_EXCEPTION |
<exception_message> |
NA |
You will receive this error if any validation fails or any unexpected error occurs during the processing of the request, the system will raise the exception. |
500 |
Sample Request
The sample request to be sent is as shown below:
POST https://na11.salesforce.com/services/apexrest/peer/v1/loanApplications
{ "borrowerId":"001G000001KY8by", "purpose":"Family", "amount":10000, "term":10, "interestRate":9, "createSchedule":1 }
{ "borrowerId" : "0016g000007sR4d", "loanProductId" : "a8B6g000000gKyS", "amount" : 10000, "term" : 10, "interestRate" : 10, "purpose" : "Personal", "disbursalDate" : "2017-08-01", "firstInstallmentDate" : "2017-09-01", "eodAccrualType" : "Accrual Through Date", "eodFeeAccrual" : true }
Sample Response
This sample response contains the newly created loan application for the given borrower. The sample response that you will receive is as shown below:
{ "status":"SUCCESS", "response":[ ], "errorMessage":null, "errorCode":"NO_ERROR", "content":[ { "attributes":{ "type":"peer__Loan_Application__c", "url":"/services/data/v30.0/sobjects/peer__Loan_Application__c/a2qG00000009OoJIAU" }, "peer__Stage__c":"New", "peer__Application_Date__c":"2014-01-03", "peer__Loan_Purpose_1__c":"a1hG0000000JR1tIAG", "peer__Amount_Funded__c":0, "peer__Sorting_Criteria__c":0, "LastModifiedDate":"2014-09-23T11:32:01.000+0000", "peer__Interest_Rate__c":9, "peer__Attractiveness_Parameter__c":0, "peer__Amount_In_Funding__c":0, "peer__Requested_Loan_Amount__c":10200, "peer__Profitable_Application__c":true, "peer__Time_Left__c":"171 Days -11 Hours -32 Minutes", "peer__Loan__c":"a1WG00000050a2JMAQ", "peer__Borrower__c":"001G000001KY8byIAD", "SystemModstamp":"2014-09-23T11:32:01.000+0000", "peer__Monthly_Payment__c":1062.55, "peer__Remaining_Requested_Amount__c":10200, "peer__Disbursal_Date__c":"2014-06-23", "peer__First_Payment_Date__c":"2014-07-23", "LastModifiedById":"005G0000003IKKRIA4", "peer__Is_Expired__c":false, "peer__Amount_Time_Left__c":"$10200 / 171 Days -11 Hours -32 Minutes", "peer__Expiry_Date__c":"2014-06-23T00:00:00.000+0000", "peer__Term__c":10, "Name":"APP-00038502", "CreatedById":"005G0000003IKKRIA4", "CreatedDate":"2014-09-23T11:32:01.000+0000", "IsDeleted":false, "Id":"a2qG00000009OoJIAU", "peer__Percent_Funded__c":0 } ] }