<aside> ⚠️ Note: This documentation is for the first version of our API which is now deprecated. You should probably be looking at the docs for our new API instead, which you can find here.

</aside>

The UpdatePipelineItem function is used to edit an existing pipeline item in the CRM.

When calling this this function, the Function parameter sent to the API should be set to UpdatePipelineItem.

If successful, this function will return an array that confirms the call was made successfully ("success" = "true").

Parameters

PipelineItemId - The Id of the pipeline item you want to update (this is returned after you call CreatePipeline, or you can get it from the GetPipelineReport function). Note: PipelineItemId should be treated like a string, NOT an integer or any other number type.

Note (optional) - A note to include with the first update

StatusId - The Id of the status for this pipeline. Here are instructions for finding the correct StatusIdNote: StatusId should be treated like a string, NOT an integer or any other number type.

Priority (optional) - Priority can be 1 (low), 2 (medium), or 3 (high)

CustomFields - You can save information to any custom pipeline fields you've created. NOTE: we will only update the custom fields that you pass us in this array. For example, if you have two custom fields defined but you only pass us one, we'll update that field and leave the other one alone.

Example Code

This code shows how to update an existing pipeline item.

<?php
/************************************************************************************
    This file demonstrates how to use the Less Annoying CRM API to update a pipeline
    item in your CRM.
 
    NOTE: To use this function, you'll need to know the Ids for the pipeline and
    status you're using. You can find a list of these Ids at
    www.lessannoyingcrm.com/app/Settings/Api
 
    If you have any questions, feel free to email [email protected] for help
 **************************************************************************************/
 
//Get your user UserCode and API token from <https://www.lessannoyingcrm.com/app/Settings/Api>
$UserCode = "ABCDE";
$APIToken = "111111111111111111111111111111111111111111111111";
$EndpointURL = "<https://api.lessannoyingcrm.com>";
 
//First we're going to create a contact
$Function = "CreateContact";
$Parameters = array(
    "FullName" = "Tyler King",
);
$Result = CallAPI($EndpointURL, $UserCode, $APIToken, $Function, $Parameters);
 
//Get the new ContactId
$ContactId = $Result['ContactId'];
 
//Now we'll create a new instance of a pipeline
$Function = "CreatePipeline";
$Parameters = array(
    "ContactId"=>$ContactId,
    "PipelineId"=>"111111", //You'll need to look up the correct PipelineId
    "StatusId"=>"2222222", //You'll need to look up the correct StatusId
);
 
//This call returns a "PipelineItemId" which is a specific instance of the pipeline
$Result = CallAPI($EndpointURL, $UserCode, $APIToken, $Function, $Parameters);
$PipelineItemId = @$Result['PipelineItemId'];
 
//Now that we have the pipeline created, let's try to update it.
$Function = "UpdatePipelineItem";
$Parameters = array(
    "PipelineItemId"=>$PipelineItemId,
    "Note"=>"This is a test note",
    "StatusId"=>"3333333", //You'll need to look up the correct StatusId
    "Priority"=>2,
);
 
//Here's how you can save update custom pipeline fields. You can find the FieldIds,
//at www.lessannoyingcrm.com/app/Settings/Api (the bottom of the page)
//NOTE: We will only update the fields that you pass in this array, so if you have two fields defined but only pass us one,
//we'll update that one and leave the other one alone.
$CustomFields = array(
    "1111"=>"This is a test", //the key should be the FieldId,
    "2222"=>"2011-01-02",
    "3333"=>array("Option 1"=>"on", "Option 2"=>"on") //checkboxes should just be an array containing each checked value
);
 
//Uncomment the following line to save the custom fields
//$Parameters['CustomFields'] = $CustomFields;
 
//Send the API call to update the pipeline item
$Result = CallAPI($EndpointURL, $UserCode, $APIToken, $Function, $Parameters);
function CallAPI($EndpointURL, $UserCode, $APIToken, $Function, $Parameters){
    $PostData = array(
      'UserCode' => $UserCode,
      'APIToken' => $APIToken,
      'Function' => $Function,
      'Parameters' => json_encode($Parameters),
    );
    $Options = array(
        'http' =>
            array(
                'method'  => 'POST', //We are using the POST HTTP method.
                'header'  => 'Content-type: application/x-www-form-urlencoded',
                'content' => http_build_query($PostData) // URL-encoded query string.
            )
    );
    $StreamContext = stream_context_create($Options);
    $APIResult = file_get_contents("$EndpointURL?UserCode=$UserCode", false, $StreamContext);
    $APIResult = json_decode($APIResult, true);
    if(@$APIResult['Success'] === true){
        echo "Success!";
    }
    else{
        echo "API call failed. Error:".@$APIResult['Error'];
        exit;
    }
    return $APIResult;
}