LoanPro API - Document Upload (New)
General
LoanPro has updated the preferred method for document upload through the API. The new method is a two-step process:
- Send a POST to receive a pre-signed S3 upload URL
- Upload the document to S3 using the pre-signed URL
- Make changes to the document properties
This is the recommended process, but the legacy process is still supported.
Note: When you pull document information through the API the active property will show 0 for all documents. The active property is no longer used to show if a document is active. The archived property is now used to show whether the document is active/archived. So, 0 means it has not been archived and 1 means archived.
Get a Pre-Signed URL
To get a pre-signed URL, send a POST request to either of the following URLs, depending on whether you are uploading a loan document or a customer document:
- /api/public/api/1/Loans({ID})/document/upload
- /api/public/api/1/Customers({ID})/document/upload
The payload should contain the following:
- sectionId (required) - The ID of the document section. This must be an ID that exists within your LoanPro account.
- fileName (required) - Name of the file that will be uploaded. This must match the actual file name.
- customFileName (optional) - Custom file name. This doesn't need to match the actual file name, and will be a label used in LoanPro.
- size (optional) - Size of the file in bytes.
Your payload should look something like this:
{
"sectionId": 1,
"fileName": "test.jpg",
"size": 160000,
"customFileName": "other_name.jpg"
}
The response should look something like this:
{
"d": {
"id": "89",
"fileName": "test_1572647511.jpg",
"uploadUrl": "https://autopal-fandora.s3.amazonaws.com/tenants/1/fileAttachments/LoanDocuments/89/test_1572647511.jpg?
X-Amz-Content-Sha256=UNSIGNED-PAYLOAD
&X-Amz-Algorithm=AWS4-HMAC-SHA256
&X-Amz-Credential=AKIAQ5VMVMN6QS2AAJZF%2F20191101%2Fus-east-1%2Fs3%2Faws4_request
&X-Amz-Date=20191101T223152Z
&X-Amz-SignedHeaders=host
&X-Amz-Expires=600
&X-Amz-Signature=fd63f88946e626ec7fbea9d1711ca3078bf42ee507d456b487caebb5b7bdca72",
"customFileName": "test.jpg",
"mime": "image/jpeg"
}
}
The response includes the following:
- id - The ID of the created Document.
- fileName - System-generated unique filename (usually the file name with a number appended).
- customFileName - Name provided in the request payload.
- mime - Identified MIME type based on the file extension.
- uploadUrl - S3 url where the file must be uploaded. This link has an expiration time of 10 minutes.
The example below demonstrates how to do this:
Upload the File
Now the file can be uploaded to the url received. This can be done using a PUT request to the URL that includes the file.
Here is a cURL example:
curl --upload-file "/home/user/Documents/send/test.jpg"
"https://autopal-fandora.s3.amazonaws.com/tenants/1/fileAttachments/LoanDocuments/89/test_1572647511.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAQ5VMVMN6QS2AAJZF%2F20191101%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20191101T223152Z&X-Amz-SignedHeaders=host&X-Amz-Expires=600&X-Amz-Signature=fd63f88946e626ec7fbea9d1711ca3078bf42ee507d456b487caebb5b7bdca72"
Updating Documents
To update a document, send a PUT request to the url of the document. For Loan documents, it is:
https://loanpro.simnang.com/api/public/api/1/odata.svc/LoanDocuments(id=<id>)
and for customer documents it is:
https://loanpro.simnang.com/api/public/api/1/odata.svc/CustomerDocuments(id=<id>)
In both cases, replace “<id>” with the ID of the document.
Changing Active Status
To inactivate a document, the "archived" property should be changed from a 0 to a 1. To do this, send a PUT request with a body that looks something like the following:
{
"id": 59,
"archived": 1,
"__update": true,
"__id": 59
}
Changing Customer visibility
To change the customer visibility of the document, send a PUT request with the body formatted as follows:
{
"id": 59,
"customerVisible": 1,
"__update": true,
"__id": 59
}
- customerVisible – Set to “1” to allow the customer to see the document on the customer website
- id – The ID of the document being updated
Updating Metadata
To update the metadata of a document, send a PUT request with the body formatted as follows:
{
"id": 76,
"sectionId": "5",
"description": "this is a description",
"fileName": "test.png",
"__id": 76,
"__update": true
}
- id – The ID of the document to update
- sectionId – The document’s section ID
- description – The description for the document
- fileName – The file name for the document
Note: The sectionId must be a valid one. See Create New Loan Document Section or Create New Customer Document Section for help creating new document sections.