Lead Gen & CRM has a distinct API organization. This article will detail the parts of the Lead Gen & CRM API related to Uploading Files.
| Administrators | ✓ | |
| Company Managers | ||
| Marketing Managers | ||
| Sales Managers | ||
| Salespersons | ||
| Jr. Salespersons |
Multipart Form-Data
As JSON is not designed for binary data, we have a separate endpoint for uploading files to the API. The upload response will still be in JSON format.
Upload requests should be sent to https://api.sharpspring.com/pubapi/<api-version>/uploadFiles using multipart form-data.
| Name | Type |
Is Required | |||
| objectType | The string "lead", "account", or "opportunity" |
Required | |||
| fieldSystemName | string |
Required: This should be the systemName of a File Upload custom field. | |||
| files | list<File> |
Required | |||
| <filename> | int |
Required: You must include a parameter for each file you are uploading, named the same as the filename, and set to the ID of the object you wish to update with that file. Because of this, when uploading multiple files in a single API call, filenames must be unique. |
A common method of connecting to APIs is using the low-level cURL utility. The following example demonstrates uploading files to a lead custom field using PHP.
<?php
$requestID = session_id();
$accountID = '<account-id>';
$secretKey = '<secret-key>';
$params = [
'id' => $requestID,
'objectType' => 'lead',
'fieldSystemName' => '<systemName-of-field-to-update>',
];
$files = [
['fileName' => 'file1.png', 'leadID' => 1234],
['fileName' => 'file2.png', 'leadID' => 5678],
];
foreach ($files as $index => $file) {
$fileName = $file['fileName'];
$leadID = $file['leadID'];
$params['files[' . $index . ']'] = curl_file_create(
realpath($fileName),
mime_content_type($fileName),
basename($fileName)
);
$params[$fileName] = $leadID;
}
$queryString = http_build_query(array('accountID' => $accountID, 'secretKey' => $secretKey));
$url = "http://api.sharpspring.com/pubapi/v1/uploadFiles?$queryString";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
?>
Multipart Form-Data
As JSON is not designed for binary data, we have a separate endpoint for uploading files to the API. The upload response will still be in JSON format. Upload requests should be sent to https://api.sharpspring.com/pubapi/<api-version>/uploadProductImage using multipart form-data.
| Name | Type |
Is Required | |||
| id | The ID of the request |
Required | |||
| productID | The ID of the target product |
Required | |||
| productImage | File |
Required: The location of the file to upload |
A common method of connecting to APIs is using the low-level cURL utility. The following example demonstrates uploading files to a lead custom field using PHP.
<?php
$requestID = session_id();
$accountID = '<account-id>';
$secretKey = '<secret-key>';
$queryString = http_build_query(array('accountID' => $accountID, 'secretKey' => $secretKey));
$url = "http://api.sharpspring.com/pubapi/v1/uploadProductImage?$queryString";
$ch = curl_init($url);
$fileToUpload = curl_file_create('example-image.jpg');
$params = [
'id' => $requestID,
'productID' => 681462799,
'productImage' => $fileToUpload,
];
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
echo $result;
An example Postman request.
{
"name": "uploadProductImage",
"request": {
"method": "POST",
"header": [],
"body": {
"mode": "formdata",
"formdata": [
{
"key": "id",
"value": "123",
"type": "text"
},
{
"key": "productID",
"value": "681462799",
"type": "text"
},
{
"key": "productImage",
"type": "file",
"src": "/C:/Users/scoobydoo/Downloads/rye-rove-raggy.jpeg"
}
]
},
"url": {
"raw": "https://api.sharpspring.com/pubapi/v1.2/uploadProductImage?accountID=your-account-id&secretKey=your-secret-key",
"protocol": "https",
"host": [
"api",
"sharpspring",
"com"
],
"path": [
"pubapi",
"v1.2",
"uploadProductImage"
],
"query": [
{
"key": "accountID",
"value": "your-account-id"
},
{
"key": "secretKey",
"value": "your-secret-key"
}
]
}
},
"response": []
}
Additional API information can be found in the following articles:
Copyright © 2025 · All Rights Reserved · Constant Contact · Privacy Center