Add Customer Document

This request allows you to upload a customer document.

Introduction

This request is a bit different from our others listed here in our documentation. Here's what you need to know about uploading customer documents:

  • This request requires two steps (pretty exciting, right?). Step one is acquiring a URL to send the upload file to, and step two is actually uploading the file to your account through the URL.
  • Most of our requests on this site allow you to try them yourself; however, this one doesn't quite work that way. We'll provide you the information for trying this yourself in your own REST client, though.

For more information on uploading customer documents, take a look at our API – Document Upload article.

And for an example of how uploading documents in the UI works, see Uploading a Customer Document.

Step 1 - Acquire the URL

The first step to adding a customer document is acquiring a URL to send it to. Here, you'll send a POST request to the following URL:

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

This step requires a JSON payload, and here is an example of the payload you will need to send:

{
  "sectionId": 1, // This is the category the note will be placed in.
  "fileName": "test.jpg", // This is the file's name.
  "size": 160000, // This is the size of the file in bytes.
  "customFileName": "customFileName.jpg" // (optional) This field allows you to set a display name for the file in the UI.
}

If your request is successful, your response will look something like this:

{
  "d": {
    "id": "9",
    "fileName": "test_5fa319d2069f32562c8664e12dde5cbacac86faabdade.jpg",
    "uploadUrl": "https://autopal-fandora.s3.amazonaws.com/tenants/5200243/fileAttachments/CustomerDocuments/9/python_5fa319d2069f32562c8664e12dde5cbacac86faabdade.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEIX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJGMEQCICNfcrl2MHJRCdi5k5HlgwzKDsc08VadT5b%2BIfKaRvjQAiAQJl4Bm7ds%2BXh%2FY1KdU8GyWgaX8S%2BU1Ta7r2BJasId1iq9Awje%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAAaDDA2MzcxMjg3OTQ4NSIMtPFKW0U0KYF%2BtqEPKpEDo8gTv%2BheKM8Ae4l7eW6HM5bkze%2B7xFS7MeBQ3rKBFr1OCGFR%2BDlDeWoy8r3OHu4mFK4W8kGtMJIkP2UErRbp98KhYW36spnysu0vUqm12ArERFsuCM70e3c0BHfSE60t0PF1dS2psxOtGbcvkUYkykIduQEg%2FPL1VmQbXHV0kiTupnbyNb8JC%2Bxc3bvHLmd3QyTJA68gMa5x5bKwaWNqtM78m2tHFt7v2JGnDSFb43UQqDAbuQrfiYyIG%2BZVTRZFWt4TFpb%2B8v9LgC0q32IJuc1enKmPi2LdGFYA54PS5f1e8RlCBk3ORzacTwS%2FpUgWLyJT%2FPpaFXUg%2BCMjqotPrgaJ2Si6XRHOtEZicZH8U%2BjOr%2B9x7bYypv67VWpV%2BgyY4rddo1fD2B7ynYgDrxjqobfvhUQNO9U19dRTtk9Waw6epdxr5SpmdpaROUGvJL%2FCK%2FfoLL0HLOUimD%2Fo7ehOGPQAYIdzZAfdX3XsSkWwClTsfRIPI3CObysxa%2Fz4Ust3goewAuL1rnnl687Q5BWEgkMwm6qM%2FQU67AENk3%2BqvhG28Pv7asRKB8UK1FO8NJhZP1uNgwHm%2FwslO9J45m4JGnggRTyac%2FTB1KhygRZv%2BA2X3xbpbbo0bppmFAPSy5ldCrSp7xL6PFqCaAR3CoqQbv%2FU2ykslyIYO%2ByWLbCCjSG8SJstZteCN6Oj8BvlqFFeJM9fUB2bt904pY0xeX61qwhCMHGqUCPcoOrtpo%2FflPrDye%2F1EfiTsANo91EWlYiOmulNlm4VeAQ0pl7VxXeYt695xE3LzY0LY9X%2Fbulpdp%2F7neRjBrGivXxFLUJoIeHMz96xSDH%2BCqaAbBQoxVtJGFJmkJdykQ%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQ5VMVMN6QNWU5QQQ%2F20201104%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201104T211458Z&X-Amz-SignedHeaders=host&X-Amz-Expires=2700&X-Amz-Signature=181bc0ae135f0eaf116f5667d2486ba0d511df047f858cec784e9012b2f221a0",
    "customFileName": "customFileName.jpg",
    "mime": "image/jpeg"
  }
}

In this response, you'll notice there is a uploadUrl field. This is important, because you'll need to use the URL provided in the next step.

Step 2 - Upload the Document

In this step, you'll upload the document to your account.

To upload the document, you will need to send a PUT request to the URL listed in the uploadUrl field returned by the request in the step above. You'll also need to remove the Authorization and Autopal-Instance-Id tokens from your headers.

Here are examples of the payload you will need in both cURL and Python:

curl --upload-file "C:\path\filename.filetype" 
"https://autopal-fandora.s3.amazonaws.com/tenants/5200243/fileAttachments/CustomerDocuments/9/python_5fa319d2069f32562c8664e12dde5cbacac86faabdade.jpg?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEIX%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEaCXVzLWVhc3QtMSJGMEQCICNfcrl2MHJRCdi5k5HlgwzKDsc08VadT5b%2BIfKaRvjQAiAQJl4Bm7ds%2BXh%2FY1KdU8GyWgaX8S%2BU1Ta7r2BJasId1iq9Awje%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F8BEAAaDDA2MzcxMjg3OTQ4NSIMtPFKW0U0KYF%2BtqEPKpEDo8gTv%2BheKM8Ae4l7eW6HM5bkze%2B7xFS7MeBQ3rKBFr1OCGFR%2BDlDeWoy8r3OHu4mFK4W8kGtMJIkP2UErRbp98KhYW36spnysu0vUqm12ArERFsuCM70e3c0BHfSE60t0PF1dS2psxOtGbcvkUYkykIduQEg%2FPL1VmQbXHV0kiTupnbyNb8JC%2Bxc3bvHLmd3QyTJA68gMa5x5bKwaWNqtM78m2tHFt7v2JGnDSFb43UQqDAbuQrfiYyIG%2BZVTRZFWt4TFpb%2B8v9LgC0q32IJuc1enKmPi2LdGFYA54PS5f1e8RlCBk3ORzacTwS%2FpUgWLyJT%2FPpaFXUg%2BCMjqotPrgaJ2Si6XRHOtEZicZH8U%2BjOr%2B9x7bYypv67VWpV%2BgyY4rddo1fD2B7ynYgDrxjqobfvhUQNO9U19dRTtk9Waw6epdxr5SpmdpaROUGvJL%2FCK%2FfoLL0HLOUimD%2Fo7ehOGPQAYIdzZAfdX3XsSkWwClTsfRIPI3CObysxa%2Fz4Ust3goewAuL1rnnl687Q5BWEgkMwm6qM%2FQU67AENk3%2BqvhG28Pv7asRKB8UK1FO8NJhZP1uNgwHm%2FwslO9J45m4JGnggRTyac%2FTB1KhygRZv%2BA2X3xbpbbo0bppmFAPSy5ldCrSp7xL6PFqCaAR3CoqQbv%2FU2ykslyIYO%2ByWLbCCjSG8SJstZteCN6Oj8BvlqFFeJM9fUB2bt904pY0xeX61qwhCMHGqUCPcoOrtpo%2FflPrDye%2F1EfiTsANo91EWlYiOmulNlm4VeAQ0pl7VxXeYt695xE3LzY0LY9X%2Fbulpdp%2F7neRjBrGivXxFLUJoIeHMz96xSDH%2BCqaAbBQoxVtJGFJmkJdykQ%3D%3D&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQ5VMVMN6QNWU5QQQ%2F20201104%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20201104T211458Z&X-Amz-SignedHeaders=host&X-Amz-Expires=2700&X-Amz-Signature=181bc0ae135f0eaf116f5667d2486ba0d511df047f858cec784e9012b2f221a0"
import requests

url = "https://autopal-fandora.s3.amazonaws.com/tenants/5200243/fileAttachments/CustomerDocuments/52/customer_document_6217a94d247adf032a3f8fb64e79cf1c12f7a59f2681f-%281%29_62ded3cfd061d5ae135535d9de0e6a9d44d1cb86a2412.txt?X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Security-Token=IQoJb3JpZ2luX2VjEGIaCXVzLWVhc3QtMSJIMEYCIQDGaZvNCK9%2B6q%2BS%2BmXLiI%2FKXbHkIjI5pOQ2rew%2FIn9qqgIhAPVrI%2FBvXXS5HjkPLEgWHnVZTHxz%2FJtMeo6zE7vNYGPGKtsECKv%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FwEQABoMMDYzNzEyODc5NDg1Igw7JMt00E9hcc0%2FZ30qrwScwNrMYrQAiFr4c6ZUw%2Bo95IXs9jb1sF5ST2yk3e5ZGs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faws4_request&X-Amz-Date=20220725T173303Z&X-Amz-SignedHeaders=host&X-Amz-Expires=2700&X-Amz-Signature=1f51090fd50d0f490f38b47d4424a155484f5234ccbd0ea30983113606aa841a"

file = open(r"C:\path\filename.filetype", 'rb')

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

print(response.text)