Add Loan Document

This request uploads a loan document.

This request is a bit different from our others listed here in our documentation:

  • This request requires two steps. (Pretty exciting, right?) The first step is acquiring a URL to send the upload file to. Then, the second step is actually uploading the file to the account through the URL.
  • Most of our requests on this site can be tried in-page; however, this one doesn't quite work that way. We'll provide the information for trying this in your own REST client, though.

For an example of how loan documents work within the UI, take a look at our Loan Documents article.

Step 1 - Generate Upload URL

The first step to adding a loan document is generating a URL. Here, send a POST request to the following URL:

https://loanpro.simnang.com/api/public/api/1/Loans({ID})/document/upload

This step requires a JSON payload, and the payload should be formatted like the following example:

{
  "sectionId": 1, // This is the ID of the "section"——or category——that the document is filed under. You can create your own sections.
  "fileName": "file.jpg",
  "customFileName": "Loan Document"
}
Authorization:<Bearer token>
Autopal-Instance-Id:<Tenant ID>
Content-Type:application/json

A successful request will result in a response like the following:

{
  "d": {
    "id": "89",
    "fileName": "file.jpg",
    "uploadUrl": "https://autopal-fandora.s3.amazonaws.com/tenants/5200243/fileAttachments/LoanDocuments/9/python_5fa319d2069f32562c8664e12dde5cbacac86faabdade.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Security-Token=IQoJb3JA...-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQ5...us-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201104T211458Z&X-Amz-SignedHeaders=host&X-Amz-Expires=2700&X-Amz-Signature=181bc0...",
    "customFileName": "Loan Document",
    "mime": "image/jpeg"
  }
}

This response includes a uploadUrl field. This field holds the URL used in the next step.

Step 2 - Upload Document

🚧

This step does not require authentication. Do not use any headers.

To upload the document, send a PUT request to the uploadUrl returned by the request in the step above. Here are examples of the payload in both cURL and Python:

curl

--upload-file "C:\Users\filepath\file.jpg" 

"https://autopal-fandora.s3.amazonaws.com/tenants/5200243/fileAttachments/LoanDocuments/9/python_5fa319d2069f32562c8664e12dde5cbacac86faabdade.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Security-Token=IQoJb3JA...-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQ5...us-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201104T211458Z&X-Amz-SignedHeaders=host&X-Amz-Expires=2700&X-Amz-Signature=181bc0..."
import requests

url = "https://autopal-fandora.s3.amazonaws.com/tenants/5200243/fileAttachments/LoanDocuments/257/python_5fa1c4014f0fa0667c8c0f3c633fab28724aed68f76ed.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEG0aCXVzLWVhc3QtMSJIMEYCIQDx4%2FYC02ty1IzFW4IlEP8Bu1tJirLA8phWjeXx27xn1wIhAOCnvWzL5PfaVwIkEtHnO9aJKqtP8MVz55GgK%2B792gj8Kr0DCMb%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQABoMMDYzNzEyODc5NDg1Igxu9QkHJnsJgukhpssqkQPxaa%2F6VNsu%2FjB4ggmZmTwnrkC7evvKyzDjKGwhpDFRIJDCjCuFHin49nb1P47wyg%2F1DsY1KPyYxH29LCZKWBMoUMfyVV4ofmlddzsf914UW3vA%2BJiF7VtBtPDs2HY%2FO4kbVPsRHBwm0QJD4BE0BzZLyHMTuRfPSxKnQ62oDI7X7GBIQhq7Bgcjnj%2BjUyFvdtrrmJGXcXhXanCOjPYx1H6ATxpmDQjgXXp106vexaF8AssE2St%2BZZVT5pqGpoXYbdPZTSDlH9RMYc0wMwtx%2FJ1yJR6YmqF339TTwFl2Is5%2FMeJH80wmGsF95AU0q1kNWjZUU%2BJaAR0r9m%2F0jH6xqrebhJEMa%2F1vx4u9RFecgYOQpVtzQlf9%2FFc2%2FzPrcSohJf%2BkvV6it%2B0hYwKTLck9%2BwKMS1iA88ic98SgKOX3p7i3lnzYI9lV2tzsXtC16EwIW2mqFDmyN2rr63IVwiYwIVd50cUjOpMGBTKk61rkk2OUF%2Fn5exTT1OKXmhT5DoodcJnEg3B7ran1SImQrIdxH6An1zC2%2FIb9BTrqAV21t919ebTVEKOvCdxd5xKHCa%2FfALkOursakednppYWvCPrIDXK0j2Tak89UYugXjbFD0Hl134RkkiL%2BzpjQwEbPkTbxN8ex9Vvyx%2FygL7FeP2SJjTy%2BYM69un61am8f%2FRYsAYPsgqxaBU6FlrGkiLY3Kb52FqfgiwA2lGgVJ9GHbjwXiZ%2BOk3hbj1dUckK84nXRr9AbyyKjdD%2BwmFBl%2Bn0klDq%2FvQm2wG9qbnzwnMZ3kuVdHswitT06WWSN6CjEBbKx2gqme2uLKB0e%2FBLJGdRzAt8HqyxEnI7TRzpqWpTlStoThZXzPrP9A%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQ5VMVMN6RKBGKS25%2F20201103%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201103T205633Z&X-Amz-SignedHeaders=host&X-Amz-Expires=2700&X-Amz-Signature=39d7fe294efa180f695f3e2cdf074ca81b659c2d21e7ee551514527a826da998"

file = open(r'C:\Users\filepath\file.jpg', 'rb')

response = requests.put(url, data=file)

print('Status:', request.status_code)
print(response.text)

If using Postman, it's possible to upload files by selecting the 'Binary' body type and using the 'Upload File' button.