Explore a full, working code sample of a loan integration with our Application Programming Interface (API). This documentation will outline the basic steps of creating a loan from the policyPay system. With your program set up in our production environment, it will be ready for live testing. When successful testing is completed, real loans can be created.
Once you submit to the API, you can see the accounts in the UI at policypay.io by logging in with your given credentials.
You can see all the available REST methods via our Swagger at rest.policypay.io or uat-rest.policypay.io
User Credentials
Email: ***
Password: ***
Public Key: ***
Secret Key: ***
Swagger API Endpoint Definitions
Once logged in with your given credentials, navigate to /loans /loan/create.
Selecting Try it out will bring up the request body for your API endpoint definitions. Once filled in completely, selecting Execute will run the API.
A response payload will be returned which includes your API endpoints along with a successul 200 code displayed. See Response Codes below for further details.
Your API endpoint definitions will vary and be custom for your specific needs. The following is an example.
Variable | Type | Required | Notes |
---|---|---|---|
programId | String | Yes | ******* |
insuredName | String | Yes | Name of Business on Policy |
String | Yes | Email of Applicant | |
phone | String | Yes | Phone of Applicant |
address1 | String | Yes | Mailing Address of Applicant |
address2 | String | Yes | Mailing Address of Applicant |
city | String | Yes | Mailing City of Applicant |
state | String | Yes | Mailing City of Applicant |
zip | String | Yes | Mailing Zip of Applicant |
notes | String | Yes | Pass blank string or you may add notes |
amountFinanced | Number | Yes | Amount the loan will be created for |
finProAgency | Object | Yes | Retail Agency on account |
finProAgency.searchCode | String | Yes | The Retail Agency's predefined code. ins123 for testing |
finProAgency.name | String | Yes | Not required if passing the search code |
finProAgency.phone | String | Yes | Not required if passing the search code |
finProAgency.email | String | Yes | Not required if passing the search code |
finProAgency.address1 | String | Yes | Not required if passing the search code |
finProAgency.address2 | String | Yes | Not required if passing the search code |
finProAgency.city | String | Yes | Not required if passing the search code |
finProAgency.state | String | Yes | Not required if passing the search code |
finProAgency.zip | String | Yes | Not required if passing the search code |
policies | Array | Yes | This is an array of policy objects |
policyEffDate | Date | Yes | Policy Effective date |
policyNo | String | Yes | Policy Number TBD is okay |
coverageType | String | Yes | Pulled form a list; Use General Liability for now |
premium | Number | Yes | Amount of total premium |
fees | Number | Yes | Amount of Policy Fees |
taxes | Number | Yes | Amount of Policy Taxes |
brokerFee | Number | Yes | Amount of Broker Fee |
inspectionFee | Number | Yes | Amount of Inspection Fee |
generalAgency | Object | Yes | General Agency on Policy |
generalAgency.searchCode | String | Yes | The General Agency’s predefined code; GA123 for testing |
generalAgency.name | String | Yes | Not required if passing the search code |
generalAgency.phone | String | Yes | Not required if passing the search code |
generalAgency.email | String | Yes | Not required if passing the search code |
generalAgency.address1 | String | Yes | Not required if passing the search code |
generalAgency.address2 | String | Yes | Not required if passing the search code |
generalAgency.city | String | Yes | Not required if passing the search code |
generalAgency.state | String | Yes | Not required if passing the search code |
generalAgency.zip | String | Yes | Not required if passing the search code |
broker | Object | No | The Broker that may be added; a double broker scenario; OPTIONAL |
broker.searchCode | String | No | Search code provided by policyPay; No Test code is provided |
broker.name | String | No | Not required if passing the search code |
broker.phone | String | No | Not required if passing the search code |
broker.email | String | No | Not required if passing the search code |
broker.address1 | String | No | Not required if passing the search code |
broker.address2 | String | No | Not required if passing the search code |
broker.city | String | No | Not required if passing the search code |
broker.state | String | No | Not required if passing the search code |
broker.state | String | No | Not required if passing the search code |
broker.zip | String | No | Not required if passing the search code |
Postman API Link
An alternate way of using our API is with your given Postman link. The link will take you to your already configured endpoint for you to fill out. In the Body section on Postman, you will find your configured endpoints. Once filled, selecting Send will execute the API call.
Congratulations! You have successfully created your loan.
Sample JSON Payload
Your unique programId is required.
{
"insuredName": "Test Create from API",
"email": "[email protected]",
"phone": "6192061433",
"address1": "2445 Brant St",
"address2": "",
"city": "San Diego",
"state": "CA",
"zip": "92101",
"notes": "",
"programId": "6509e78e84338864075ff5a3",
"amountFinanced": "750.00",
"finProAgency": {
"searchCode": "test123",
"name": "",
"phone": "",
"email": "",
"address1": "",
"address2": "",
"city": "",
"state": "",
"zip": ""
},
"policies": [
{
"policyEffDate": "2023-10-02",
"policyNo": "TBD",
"coverageType": "General Liability",
"premium": "1000",
"fees": "150",
"taxes": "50",
"brokerFee": "500",
"inspectionFee": "100",
"insuranceCompany": {
"searchCode": "INS123",
"name": "",
"phone": "",
"email": "",
"address1": "",
"address2": "",
"city": "",
"state": "",
"zip": ""
},
"generalAgency": {
"searchCode": "GA123",
"name": "",
"phone": "",
"email": "",
"address1": "",
"address2": "",
"city": "",
"state": "",
"zip": ""
},
"broker": {
"searchCode": "",
"name": "",
"phone": "",
"email": "",
"address1": "",
"address2": "",
"city": "",
"state": "",
"zip": ""
}
}
]
}
Sample JSON Response
{
"status": "success",
"message": "Loan created successfully",
"loan": {
"_id": "651cae40dd071006f4521c7d",
"insuredName": "Test Create from Postman",
"email": "[email protected]",
"uniqueNumber": "vjj6SZ7UKWWB3NeS",
"phone": "6192061433",
"ext": null,
"address1": "2445 Brant St",
"address2": "",
"city": "San Diego",
"state": "CA",
"zip": "92101",
"notes": "",
"programId": "6509e78e84338864075ff5a3",
"amountFinanced": 750,
"paymentMethod": "credit card",
"status": "Inactive",
"agencyId": "651ca2010906a07568c3655c",
"agencyName": "Eastern Premium Finance",
"agentName": "Eastern User",
"agentEmail": "[email protected]",
"downPayment": 1050,
"noOfInstallments": 9,
"payments": [
{
"_id": "651cae42dd071006f4521c81",
"uniqueNumber": "AH8Omz5blyLpXrYP",
"toBeChargedAt": "2023-10-02T00:00:00.000Z",
"amount": 1050,
"status": "Pending",
"type": "Down Payment"
}
],
"policies": [
{
"_id": "651cae42dd071006f4521c80",
"policyEffDate": "2023-10-02T00:00:00.000Z",
"policyNo": "TBD",
"coverageType": "General Liability",
"premium": 1000,
"fees": 150,
"taxes": 50,
"brokerFee": 500,
"inspectionFee": 100,
"insuranceCompany": {
"searchCode": "INS123",
"name": "",
"phone": "",
"email": "",
"address1": "",
"address2": "",
"city": "",
"state": "",
"zip": ""
},
"generalAgency": {
"searchCode": "GA123",
"name": "",
"phone": "",
"email": "",
"address1": "",
"address2": "",
"city": "",
"state": "",
"zip": ""
},
"broker": {
"searchCode": "",
"name": "",
"phone": "",
"email": "",
"address1": "",
"address2": "",
"city": "",
"state": "",
"zip": ""
},
"amountFinanced": 1800,
"expirationDate": "2024-10-02T00:00:00.000Z"
}
]
}
}
Response Codes
Code | Description |
---|---|
200 | Loan created successfully |
400 | Failed to create loan |
422 | Unprocessable entry |
500 | Internal server error |