Update a Pipeline
Purpose
To update a pipeline in a layout.
Request Details
Request URL
{api-domain}/crm/{version}/settings/pipeline/{pipeline_ID}?layout_id={layout_id}
You can also send the pipeline ID in the input body.
Header
Authorization: Zoho-oauthtoken <access_token>
Scope
scope=ZohoCRM.settings.pipeline.UPDATE
Parameters
- layout_idstring, mandatory
The unique ID of the layout the pipeline is created in.
Sample Request
Copiedcurl "https://www.zohoapis.com/crm/v2.1/settings/pipeline/3652397000003097007?layout_id=3652397000000091023"
-X PUT
-d input.json
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copied//Get instance of PipelineOperations Class
$pipelineOperations = new PipelineOperations($layoutId);
$pipelineClass = "com\\zoho\\crm\\api\\pipeline\\PipeLine";
$pipeline = new $pipelineClass();
$pipeline->setId("34770619482001");
$pipeline->setDisplayValue("Qualification");
$pickList = new PickListValue();
$pickList->setId("34770610006801");
$pickList->setSequenceNumber(1);
$pipeline->setMaps([$pickList]);
$bodyWrapper = "com\\zoho\\crm\\api\\pipeline\\BodyWrapper";
$body = new $bodyWrapper();
$body->setPipeline([$pipeline]);
//Call createPipelines method that takes BodyWrapper instance as parameter
$response = $pipelineOperations->updatePipelines($body);
//Get instance of PipelineOperations Class
$pipelineOperations = new PipelineOperations($layoutId);
$pipelineClass = "com\\zoho\\crm\\api\\pipeline\\PipeLine";
$pipeline = new $pipelineClass();
$pipeline->setDisplayValue("Qualification");
$pickList = new PickListValue();
$pickList->setId("34770610006801");
$pickList->setSequenceNumber(1);
$pipeline->setMaps([$pickList]);
$bodyWrapper = "com\\zoho\\crm\\api\\pipeline\\BodyWrapper";
$body = new $bodyWrapper();
$body->setPipeline([$pipeline]);
//Call updatePipeline method that takes BodyWrapper instance as parameter
$response = $pipelineOperations->updatePipeline($pipelineId, $body);
Copied<?php
class UpdatePipelines
{
public function execute(){
$curl_pointer = curl_init();
$curl_options = array();
$parameters = array();
$parameters["layout_id"]="34770610087501";
foreach ($parameters as $key=>$value){
$url =$url.$key."=".$value."&";
}
$url = "https://www.zohoapis.com/crm/v2.1/settings/pipeline?";
$curl_options[CURLOPT_URL] =$url;
$curl_options[CURLOPT_RETURNTRANSFER] = true;
$curl_options[CURLOPT_HEADER] = 1;
$curl_options[CURLOPT_CUSTOMREQUEST] = "PUT";
$requestBody=array();
$pipeline=array();
$pipelineObject=array();
$pipelineObject["display_value"]="Pipeline1";
$pipelineObject["default"]=false;
$maps=array();
$mapsObject=array();
$mapsObject["display_value"]="Qualification";
$mapsObject["sequence_number"]=2;
$mapsObject["actual_value"]="Qualification";
$mapsObject["id"]="3652397000000006801";
array_push($maps,$mapsObject);
$mapsObject1=array();
$mapsObject1["display_value"]="Needs Analysis";
$mapsObject1["sequence_number"]=1;
$mapsObject1["actual_value"]="Needs Analysis";
$mapsObject1["id"]="3652397000000006803";
array_push($maps,$mapsObject1);
$mapsObject2=array();
$mapsObject2["display_value"]="Value Proposition";
$mapsObject2["sequence_number"]=3;
$mapsObject2["actual_value"]="Value Proposition";
$mapsObject2["id"]="3652397000000006805";
array_push($maps,$mapsObject2);
$mapsObject3=array();
$mapsObject3["display_value"]="Proposal/Price Quote";
$mapsObject3["sequence_number"]=4;
$mapsObject3["actual_value"]="Proposal/Price Quote";
$mapsObject3["id"]="3652397000000006811";
array_push($maps,$mapsObject3);
$pipelineObject["maps"]=$maps;
array_push($pipeline,$pipelineObject);
$requestBody["pipeline"]=$pipeline;
$curl_options[CURLOPT_POSTFIELDS]= json_encode($requestBody);
$headersArray = array();
$headersArray[] = "Authorization". ":" . "Zoho-oauthtoken " . "1000.30f3a589XXXXXXXXXXXXXXXXXXX4077.dc5XXXXXXXXXXXXXXXXXXXee9e7c171c";
$curl_options[CURLOPT_HTTPHEADER]=$headersArray;
curl_setopt_array($curl_pointer, $curl_options);
$result = curl_exec($curl_pointer);
$responseInfo = curl_getinfo($curl_pointer);
curl_close($curl_pointer);
list ($headers, $content) = explode("\r\n\r\n", $result, 2);
if(strpos($headers," 100 Continue")!==false){
list( $headers, $content) = explode( "\r\n\r\n", $content , 2);
}
$headerArray = (explode("\r\n", $headers, 50));
$headerMap = array();
foreach ($headerArray as $key) {
if (strpos($key, ":") != false) {
$firstHalf = substr($key, 0, strpos($key, ":"));
$secondHalf = substr($key, strpos($key, ":") + 1);
$headerMap[$firstHalf] = trim($secondHalf);
}
}
$jsonResponse = json_decode($content, true);
if ($jsonResponse == null && $responseInfo['http_code'] != 204) {
list ($headers, $content) = explode("\r\n\r\n", $content, 2);
$jsonResponse = json_decode($content, true);
}
var_dump($headerMap);
var_dump($jsonResponse);
var_dump($responseInfo['http_code']);
}
}
(new UpdatePipelines())->execute();
Request JSON
- display_valueString, mandatory
The name of the pipeline you want to update. This key accepts an alphanumeric value.
- mapsJSON array, mandatory
The different stages that a deal has to pass through in the sales pipeline. This array contains the following keys:
sequence_number - integer, mandatory - The order in which the stage must be displayed. If the value of this key is "1", then this stage will be displayed first.
id - string, mandatory - The unique ID of the stage. Use the Fields Metadata API to obtain the unique ID of the field.
Sample Input
Copied{
"pipeline": [
{
"display_value": "Pipeline1",
"default": false,
"maps": [
{
"display_value": "Qualification",
"sequence_number": 2,
"actual_value": "Qualification",
"id": "3652397000000006801"
},
{
"display_value": "Needs Analysis",
"sequence_number": 1,
"actual_value": "Needs Analysis",
"id": "3652397000000006803"
},
{
"display_value": "Value Proposition",
"sequence_number": 3,
"actual_value": "Value Proposition",
"id": "3652397000000006805"
},
{
"display_value": "Proposal/Price Quote",
"sequence_number": 4,
"actual_value": "Proposal/Price Quote",
"id": "3652397000000006811"
}
]
}
]
}
Possible Errors
- MANDATORY_NOT_FOUNDHTTP 400
You have not included the pipeline ID in the request URL.
Resolution: You must include the ID of the pipeline you want to update in the URL. - INVALID_DATAHTTP 400
The ID of the pipeline in the request body is invalid.
Resolution: Use the Fields Metadata API to obtain the unique IDs of the stages. - INVALID_DATAHTTP 400
The ID of the stage in the "maps" object is invalid.
Resolution: Use the Fields Metadata API to obtain the unique IDs of the stages. - INVALID_DATAHTTP 400
The pipeline's ID in the request URL is invalid.
Resolution: Provide a valid pipeline ID. Use the Get Pipelines API to obtain the pipeline's ID. - CANNOT_DELETEHTTP 400
You cannot delete the last stage of the pipeline.
Resolution: Add another stage to the pipeline before deleting the last one. - REQUIRED_PARAM_MISSINGHTTP 400
You have not included the mandatory parameter "layout_id" in your request.
Resolution: Specify valid layout ID in the request.
Sample Response
Copied{
"pipeline": [
{
"code": "SUCCESS",
"details": {
"id": "3652397000003097007"
},
"message": "Pipeline updated",
"status": "success"
}
]
}