Less Annoying CRM logo Less Annoying CRM LACRM

Sending files with the API

The LACRM API supports uploading files with some API calls. This requires using a different content type, so you'll need to make sure your requests are set up properly first.

Note: we enforce a 50MB file limit when uploading files via the API.

Normally when you make a request to the API, you're sending a JSON body with Function & Parameters defined. When sending a file, you'll need to use multipart/form-data. You'll still send along Function and Parameters, but you'll also need to send a 3rd key called File, with the file set as the value.

Here's a PHP code example, adapted from the CallLacrmApi function described earlier in the documentation:

$CurlHandle = curl_init("https://api.lessannoyingcrm.com/v2/");
$Headers = array(
    "Content-Type: multipart/form-data",
    "Authorization: YOUR_API_KEY_HERE"

curl_setopt($CurlHandle, CURLOPT_POST, 1);
curl_setopt($CurlHandle, CURLOPT_POSTFIELDS, [
    "Function" => "CreateFile",
    "Parameters" => json_encode([
        "ContactId" => "CONTACT_TO_UPLOAD_FILE_TO"
    "File" => new CURLFile("PATH_TO_FILE")
curl_setopt($CurlHandle, CURLOPT_HTTPHEADER, $Headers);
curl_setopt($CurlHandle, CURLOPT_RETURNTRANSFER, true);

$CurlResult = curl_exec($CurlHandle);
$ReturnValue = false;
if (curl_errno($CurlHandle)) {
} else {
    $ResultObject = json_decode($CurlResult, true);
    $HttpCode = curl_getinfo($CurlHandle, CURLINFO_HTTP_CODE);
    if ($HttpCode === 400) {
        error_log("Error $ResultObject[ErrorCode]: $ResultObject[ErrorDescription]");
    } else {
        $ReturnValue = $ResultObject;