How to upload a document that's associated with a customer.
Introduction
Uploading a customer document requires two requests: one to generate a URL to send the upload file to, and one to upload the file to an account via the provided URL.
For an example of how customer documents work within the UI, take a look at our Uploading a Customer Document article.
Step 1 – Acquire the URL
The first step to adding a customer document is acquiring a URL to send it to. Begin by sending 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 needed to send:
{
"sectionId": 1, // This is the category the note will be placed in.
"fileName": "test.jpg", // This is the file's name.
"customFileName": "customFileName.jpg" // (optional) This field allows you to set a display name for the file in the UI.
}
The API returns a response formatted like the following:
{
"d": {
"id": "9",
"fileName": "test_5fa319d2069f32562c8664e12dde5cbacac86faabdade.jpg",
"uploadUrl": "https://autopal-fandora.s3.amazonaws.com/tenants/{tenantID}/fileAttachments/CustomerDocuments/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": "customFileName.jpg",
"mime": "image/jpeg"
}
}
This response includes an uploadUrl
field, and the URL provided here is used in the next step.
Step 2 – Upload the Document
In this step, upload the document to your account.
To upload the document, send a PUT request to the URL listed in the uploadUrl
field returned by the request in the step above. Also, remove the Authorization
and Autopal-Instance-Id
tokens from the 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/{tenantID}/fileAttachments/CustomerDocuments/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/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%2Bo95IXs9jb1sF5ST2yk3e5ZGsrf6MTDsrmof0XvlL6F62Ynz6ReFM42B%2B5BZ8%2BkV6B0HBoXj8KSPZ0ARMtbtbtBP%2BF838q6FCvZWr7dWTJ9Qu2DdWJbXV1tMzsu54V15qv4DZizBpYC9AoYppenG94KkZq19yoUQT6GCugihC%2FkMI82yy%2Fmn73QY9F1D20peFA9KhhBurE%2FGG5%2FgET9leyyjWf5OPlIrNmD6VgdDTEKHs2V9p6WqaM23jdrephhIy9F305ZPsnJv6ypPXyN9pHTUiuScWPp72bve7fqdVmn8CW%2BmwAkSoVu5%2BdbjXxXy%2BcMvWZsSitgyO1UjozjCLwxCjra1qvXhPWDc212qfrW2S7XaotT2mvRulMr6hkvhyx0pRLrvKTdtYZLn0BWDn3i5r%2FYuV8YRvzct7KdZLV7Up2FLtHFd7LKZEq6KLUqN7VXZ9t4sD%2BsFfR7YIYcnDDpskGlWGtKf0PpNtybf3xoP39LfkV3Ma%2BNjwVky5xbltNLNCJ%2FHCNV5TmdbZ7iV5nSgN60p0fYvaWkvMhzEsVd3R%2FIEByYi5yZzVVWLJMBamcTooFR%2FRnjQpkfpBs061TV22%2FS%2F6r9o2pbTkVmxpBLn%2BWrRIlGscgna9Pu4PjY%2BLfXxT8t2Rbcnd6w56lxFQYByN0yaf%2BPDfBoL0EgXS%2BMO7EgkXOQQNeE7wG9V86XbOte6fq%2FJfLLHsVktgOC%2FxSIMJuj%2B5YGOqgBD56U8cJUNeuRe1qJ4iCAp79rAjOONn3m9IGXG2f0cHiDhDzYd00lHfA0JUCmX2GZKAu4ITZgNBl1Nm%2BA%2BzGuiiTrzhwrNMQvTXd00CMHpo%2F98uZDO85DrOh4mW3%2BapSPzSUTdKqwMTyzLdbGLrgNFiH%2BUwjKrG7EQkqEEqYwEeiFnyWiCASNPoOPibjuUWrnHPmbaKtced9WUnXU7S3dqj9MansO029h&X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=ASIAQ5VMVMN6UNZCS2GI%2F20220725%2Fus-east-1%2Fs3%2Faws4_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)
If using Postman, upload files by selecting the 'Binary' body type and using the 'Upload File' button.