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

As the name suggests, the GetPipelineReport function is used to retrieve the data from a pipeline report. It will include the contact and pipeline data for any contacts/companies in the pipeline.

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

If successful, this function will return an array with a list of contacts and their pipeline information (or an empty array if there are no results that match your parameters).

Parameters

PipelineId - The unique identifier of the pipeline you want to retrieve. You can get a list of your PipelineIds hereNote: PipelineId should be treated like a string, NOT an integer or any other number type.

SortBy - The field you'd like to sort the results by. Can be Priority, DateNote (the date of the last pipeline update), ContactName, or Status.

NumRows (optional) - The number of records returned. The default is 100, but you can set it to any number between 1 and 500. Note that if a contact has more than one pipeline attached to them, they might appear more than once.

Page (optional) - Use this if your results are limited by the number of Rows. For example, if your first search is capped at NumRows, you can then run a second search with Page = 2, and then another with Page = 3 in order to retrieve even more results.

SortDirection (optional) - Can be ASC to sort from low to high or DESC to sort from high to low. Defaults to ASC.

UserFilter (optional) - Defaults to show all records the API user has access to, but you can pass in a specific UserId to only show contacts assigned to that user. Here are instructions for finding the UserId.

StatusFilter (optional) - Set which statuses to return. By default, only open statuses will be returned but you can set this to "all" to show all statuses (open and closed), "closed" to only show closed statuses, or pass a specific StatusId to only show that particular status. You can get a list of your StatusIds here.

Example Code

This code shows how to retrieve the data from your pipeline report via the API.

<?php
/************************************************************************************
    This file demonstrates how to use the Less Annoying CRM API to retrieve pipeline
    information.
 
    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>";
 
$PipelineId = "1234"; //Find your PipelineIds at <https://www.lessannoyingcrm.com/app/Settings/Api>
 
//Specify the type of records you want to retrieve. PipelineId is the only required field.
$Function = "GetPipelineReport";
$Parameters = array(
    "PipelineId" =>
 $PipelineId,
    "Page" => 1,
    "NumRows" => 50,
    "SortBy" => "Status",
    "SortDirection" => "ASC",
    "StatusFilter" => "closed"
);
 
$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;
}