Lead Gen & CRM
How can we help you?
Search our help articles, video tutorials, and quickstart guides

You've got this. You've got us. Search our Knowledge Base to quickly find answers to your questions.

Understanding Lead Gen & CRM Open API: Uploading Files

Article: 000054650
Updated: October 28, 2025

Lead Gen & CRM has a distinct API organization. This article will detail the parts of the Lead Gen & CRM API related to Uploading Files.


Article Contents


Users:
Administrators 
Company Managers  
Marketing Managers  
Sales Managers  
Salespersons  
Jr. Salespersons  

The /uploadFiles Endpoint 

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.

 

Parameters

Name Type 

Is Required

 
objectTypeThe string "lead", "account", or "opportunity" 

Required

fieldSystemNamestring 

Required: This should be the systemName of a File Upload custom field.

fileslist<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.


 

 

Example Code with PHP & cURL

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;


?>

 

The /uploadProductImage Endpoint

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.

 

Parameters

 

Name Type 

Is Required

 
idThe ID of the request 

Required

productIDThe ID of the target product 

Required

productImageFile 

Required: The location of the file to upload


 

Example Code with PHP & cURL 

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;

 

Postman Example

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

Additional API information can be found in the following articles:

 

 


Did this article answer your question?


Constant Contact Logo

Copyright © 2025 · All Rights Reserved · Constant Contact · Privacy Center