Convert a Lead

Purpose

To convert a lead.

Request URL

https://www.zohoapis.com/crm/v2/Leads/{record_id}/actions/convert

record_id - The unique ID of the record

Request Method

POST

Scope

scope=ZohoCRM.modules.all
(or)
scope=ZohoCRM.modules.Leads.{operation_type}

Possible operation types
ALL - Full access to the record
WRITE - Edit records in the module
CREATE - Create records in the module

Note:

  • In the input, the assign_to value can only be the User ID.

  • You can associate the existing contact or account to the converting lead even if the lead is converted or not converted to a deal. To achieve this, you have to send the account ID and contact ID in your input data.

  • If both account ID and overwrite values are true, then the account name will be replaced by the company name, while associating it with the existing account. However, the data of that account will remain the same.

  • If overwrite value is set to false, then association will only happen. However, if you set the overwrite value without account ID, the working of this method remains unchanged.

  • If contact ID is given in your input, then the converting lead will be associated to the existing contact.

  • You must use only Field API names in the input. You can obtain the field API names from

    • Fields metadata API (the value for the key “api_name” for every field). (Or)

    • Setup > Developer Space > APIs > API Names > {{Module}}. Choose “Fields” from the “Filter By” drop-down.

Sample Request

In the request, "@convertlead.json" contains the sample input.


				curl "https://www.zohoapis.com/crm/v2/Leads/1000000145990/actions/convert"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-d "@convertlead.json"
-X POST			

Sample Input


				{
    "data": [
       {
            "overwrite": true,
            "notify_lead_owner": true,
            "notify_new_entity_owner": true,
            "Accounts": "4000000373187",
            "Contacts": "4000000372131",
            "assign_to": "4000000219019",
            "Deals": {
                "Campaign_Source": "4000000372147",
                "Deal_Name": "Robert",
                "Closing_Date": "2016-03-30",
                "Stage": "Closed Won",
                "Amount": 56.6
            }
        }
    ]
}			

Sample Response


				{
    "data": [
       {
            "Contacts": "4000000372131",
            "Deals": "4000000377192",
            "Accounts": "4000000373187"
        }
    ]
}			

Sample Request


				ZCRMRecord record = ZCRMRecord.getInstance("Leads", 3247354544l);//module api name with record id
HashMap<String,Long> map = record.convert();
//returns a map as {"Accounts":"42685937005","Deals":null,"Contacts":"42685937007"}
Long accountsId = map.get("Accounts");
Long dealsId = map.get("Deals");
Long contactsId = map.get("Contacts");			

Sample Input


				{
    "data": [
       {
            "overwrite": true,
            "notify_lead_owner": true,
            "notify_new_entity_owner": true,
            "Accounts": "4000000373187",
            "Contacts": "4000000372131",
            "assign_to": "4000000219019",
            "Deals": {
                "Campaign_Source": "4000000372147",
                "Deal_Name": "Robert",
                "Closing_Date": "2016-03-30",
                "Stage": "Closed Won",
                "Amount": 56.6
            }
        }
    ]
}			

Sample Response


				{
    "data": [
       {
            "Contacts": "4000000372131",
            "Deals": "4000000377192",
            "Accounts": "4000000373187"
        }
    ]
}			

Sample Request


				$record=ZCRMRecord::getInstance("Leads",410405000001518001); // 410405000001518001 - Lead ID.
$modIns=ZCRMModule::getInstance("Deals");
$record_deal=$modIns->getRecord(410405000001519001)->getData(); // 410405000001519001 - Deal ID.
$user_instance=ZCRMUser::getInstance(410405000001516001, null);
$responseMap=$record->convert($record_deal,$user_instance);
echo "Contact ID:".$responseMap['Contacts'];
if(isset($responseMap[“Accounts”]))
{
echo "Account ID:".$responseMap[“Accounts”];
}
if(isset($responseMap[“Deals”]))
{
echo "Deal ID:".$responseMap[“Deals”];
}			

Sample Input


				{
    "data": [
       {
            "overwrite": true,
            "notify_lead_owner": true,
            "notify_new_entity_owner": true,
            "Accounts": "4000000373187",
            "Contacts": "4000000372131",
            "assign_to": "4000000219019",
            "Deals": {
                "Campaign_Source": "4000000372147",
                "Deal_Name": "Robert",
                "Closing_Date": "2016-03-30",
                "Stage": "Closed Won",
                "Amount": 56.6
            }
        }
    ]
}			

Sample Response


				{
    "data": [
       {
            "Contacts": "4000000372131",
            "Deals": "4000000377192",
            "Accounts": "4000000373187"
        }
    ]
}			

Sample Request


				def convert_record(self):
        try:
            record = ZCRMRecord.get_instance('Leads', 3719520000000326007)  # 3719520000000326007 is leadid
            potential_record = ZCRMRecord.get_instance('Deals')
            potential_record.set_field_value('Deal_Name', 'SAI1')
            potential_record.set_field_value('Closing_Date', '2017-10-10')
            potential_record.set_field_value('Stage', 'Needs Analysis')
            assign_to_user = zcrmsdk.ZCRMUser.get_instance(1386586000000105001, None)
            resp = record.convert(potential_record, assign_to_user)
            print(resp)
            print(resp[APIConstants.ACCOUNTS])
            print(resp[APIConstants.DEALS])
            print(resp[APIConstants.CONTACTS])
        except ZCRMException as ex:
            print(ex.status_code)
            print(ex.error_message)
            print(ex.error_code)
            print(ex.error_details)
            print(ex.error_content)			

Sample Input


				{
    "data": [
       {
            "overwrite": true,
            "notify_lead_owner": true,
            "notify_new_entity_owner": true,
            "Accounts": "4000000373187",
            "Contacts": "4000000372131",
            "assign_to": "4000000219019",
            "Deals": {
                "Campaign_Source": "4000000372147",
                "Deal_Name": "Robert",
                "Closing_Date": "2016-03-30",
                "Stage": "Closed Won",
                "Amount": 56.6
            }
        }
    ]
}			

Sample Response


				{
    "data": [
       {
            "Contacts": "4000000372131",
            "Deals": "4000000377192",
            "Accounts": "4000000373187"
        }
    ]
}			

Sample Request


				Syntax:
zoho.crm.convertLead(<leadId Long>,<dataMap Map>,<connectionName String>,<userAccess Boolean>);
mandatory : leadId,dataMap

Sample Request:
resp = zoho.crm.convertLead("7000000037308", { "overwrite": true, "notify_lead_owner": false, "notify_new_entity_owner": true, "Accounts": "7000000037323", "Deals": { "Deal_Name": "Robert", "Closing_Date": "2016-03-30", "Stage": "Closed Won", "Amount": 56.6 } });			

Sample Input


				{
    "data": [
       {
            "overwrite": true,
            "notify_lead_owner": true,
            "notify_new_entity_owner": true,
            "Accounts": "4000000373187",
            "Contacts": "4000000372131",
            "assign_to": "4000000219019",
            "Deals": {
                "Campaign_Source": "4000000372147",
                "Deal_Name": "Robert",
                "Closing_Date": "2016-03-30",
                "Stage": "Closed Won",
                "Amount": 56.6
            }
        }
    ]
}			

Sample Response


				{
    "data": [
       {
            "Contacts": "4000000372131",
            "Deals": "4000000377192",
            "Accounts": "4000000373187"
        }
    ]
}			

Sample Request


				ZCRMRecord record = ZCRMRecord.GetInstance("Leads", 3372164000001606016); //module api name with record id
ZCRMRecord potentialRecord = new ZCRMRecord("Deals"); // module api name
potentialRecord.SetFieldValue("Stage", "Qualification");
potentialRecord.SetFieldValue("Closing_Date", "2019-01-25");
potentialRecord.SetFieldValue("Deal_Name", "Deal_Name");
ZCRMUser user = ZCRMUser.GetInstance(3372164000001253020);
Dictionary<string,long> response = record.Convert(potentialRecord,user); // response is KeyValuePair			

Sample Input


				{
    "data": [
       {
            "overwrite": true,
            "notify_lead_owner": true,
            "notify_new_entity_owner": true,
            "Accounts": "4000000373187",
            "Contacts": "4000000372131",
            "assign_to": "4000000219019",
            "Deals": {
                "Campaign_Source": "4000000372147",
                "Deal_Name": "Robert",
                "Closing_Date": "2016-03-30",
                "Stage": "Closed Won",
                "Amount": 56.6
            }
        }
    ]
}			

Sample Response


				{
    "data": [
       {
            "Contacts": "4000000372131",
            "Deals": "4000000377192",
            "Accounts": "4000000373187"
        }
    ]
}