Transfer and Delete a Pipeline

Purpose

To delete a pipeline and transfer the associated stages to another pipeline.

Request Details

Request URL

{api-domain}/crm/{version}/settings/pipeline/actions/transfer?layout_id={layout_id}

Header

Authorization: Zoho-oauthtoken <access_token>

Scope

scope=ZohoCRM.settings.pipeline.CREATE
(or)
scope=ZohoCRM.settings.pipeline.ALL

Parameters
  • layout_idstring, mandatory

    The unique ID of the layout that the pipeline was created in.

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2.1/settings/pipeline/actions/transfer?layout_id=3652397000000091023"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-d "@input.json"
4.0.04.x
Copied//Get instance of PipelineOperations Class
$pipelineOperations = new PipelineOperations($layoutId);
$transferAndDeleteWrapper = new TransferAndDeleteWrapper();
$transferPipeLine = new TransferPipeLine();
$pipelineClass = "com\\zoho\\crm\\api\\pipeline\\PipeLine";
$pipeline = new $pipelineClass();
$pipeline->setFrom("36523973712004");
$pipeline->setTo("36523973097007");
$transferPipeLine->setPipeline($pipeline);
$stage = new Stage();
$stage->setFrom("36523970006817");
$stage->setTo("36523970006819");
$transferPipeLine->setStages([$stage]);
$transferAndDeleteWrapper->setTransferPipeline([$transferPipeLine]);
//Call transferAndDelete method
$response = $pipelineOperations->transferAndDelete($transferAndDeleteWrapper);
Copied<?php

class TransferAndDelete
{
    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/actions/transfer?";

        $curl_options[CURLOPT_URL] =$url;
        $curl_options[CURLOPT_RETURNTRANSFER] = true;
        $curl_options[CURLOPT_HEADER] = 1;
        $curl_options[CURLOPT_CUSTOMREQUEST] = "POST";
        $requestBody=array();
        $transfer_pipeline=array();
        $transfer_pipelineObject=array();
        $pipeline=array();
        $pipeline["from"]="3652397000003712004";
        $pipeline["to"]="3652397000003097007";
        $transfer_pipelineObject["pipeline"]=$pipeline;
        $stages=array();
        $stagesObject=array();
        $stagesObject["from"]="3652397000000006817";
        $stagesObject["to"]="3652397000000006819";
        array_push($stages,$stagesObject);
        $transfer_pipelineObject["stages"]=$stages;
        array_push($transfer_pipeline,$transfer_pipelineObject);
        $requestBody["transfer_pipeline"]=$transfer_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 TransferAndDelete())->execute();
Request JSON
  • pipelineJSON object, mandatory

    The IDs of the pipelines that you want to transfer the deals from and to, respectively. This object contains the following keys:

    • from - string, mandatory - The ID of the pipeline you want to delete and transfer the associated deals from.

    • to - string, mandatory - The ID of the pipeline you want to transfer deals to from another pipeline.

  • stagesJSON array, mandatory

    The stages in the pipeline you want to map to the new one. This array contains the following keys:

    • from - string, mandatory - The ID of the stage in the pipeline you want to delete.

    • to - string, mandatory - The ID of the stage in the new pipeline you want to map the old one with.

Sample Input

Copied{
    "transfer_pipeline": [
        {
            "pipeline": {
                "from": "3652397000003712004",
                "to": "3652397000003097007"
            },
            "stages": [
                {
                    "from": "3652397000000006817",
                    "to": "3652397000000006819"
                }
            ]
        }
    ]
}

Possible Errors

  • MANDATORY_NOT_FOUNDHTTP 400

    You have not included either the JSON object "pipeline" or the "stages" array in the input.
    Resolution: Include the "pipeline" JSON object and the "stages" array with the required keys and their values.

  • INVALID_DATAHTTP 400

    The ID of the layout is invalid.
    Resolution: Provide a valid layout ID.

  • INVALID_DATAHTTP 400

    Either the "from" or "to" ID is invalid in the input.
    Resolution: Refer to the "details" key int he response for the API name of the invalid key, and provide a valid input.

  • 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{
    "transfer_pipeline": [
        {
            "code": "SUCCESS",
            "details": {
                "job_id": "3652397000003737002"
            },
            "message": "transfer pipeline scheduled successfully",
            "status": "success"
        }
    ]
}