Search Records API

Purpose

To retrieve the records that match your search criteria.

Request Details

Request URL

https://www.zohoapis.com/crm/v2/{module_api_name}/search

Supported names

Leads, Accounts, Contacts, Deals, Campaigns, Tasks, Cases, Events, Calls, Solutions, Products, Vendors, Price Books, Quotes, Sales Orders, Purchase Orders, Invoices, Custom, Notes, and Activities

Header

Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52

Scope

scope=ZohoCRM.modules.ALL
(or)
scope=ZohoCRM.modules.{module_name}.{operation_type}
(and)
scope=ZohoSearch.securesearch.READ

Possible module names

leads, accounts, contacts, deals, campaigns, tasks, cases, events, calls, solutions, products, vendors, pricebooks, quotes, salesorders, purchaseorders, invoices, custom, notes, and activities

Possible operation types

ALL - Full access to the record
READ - Get records from the module

Request Details: criteria

Request URL:

https://www.zohoapis.com/crm/v2/{module_api_name}/search?criteria={{criteria_here}}

Attributes
  • criteriastring
    • Performs search by following the shown criteria. (({api_name}:{starts_with|equals}:{value})and/or({api_name}:{starts_with|equals}:{value}))

    • You can search for a maximum of 10 criteria (with same or different columns) with equals and starts_with conditions.

    • The only operator supported for encrypted fields is equals.

    • When you use "equals" for multiple conditions, and if one of your conditions is (Company:equals:ABC), the response will contain records with ABC as well as ABC Inc in their Company fields.
      When you use "equals" with a single condition and search for a field (mentioned in point #3 of the Note on this page), like Campaign_Name:equals:CRM, the response will contain only those records whose Campaign_Name is "CRM" and not records with "Best CRM" or "Latest CRM" in their Campaign_Name fields.

    • When you use parentheses or comma in the value for a criteria, you must escape them using a backslash. Further, you must encode the value.

    • Example:
      Consider the search term: ((Last_Name:equals:Burns,B)and(First_Name:starts_with:M))
      After escaping comma and parenthesis in the value: ((Last_Name:equals:Burns\,B)and(First_Name:starts_with:M))
      After encoding the value: ((Last_Name:equals:Burns%5C%2CB)and(First_Name:starts_with:M))

    • To search for Date, DateTime, Lookup, Number, Currency, Boolean fields, you need comparators other than starts_with and equals. Refer to the Query API to search for fields of these data types.

Sample Request to Search Records

Copiedcurl "https://www.zohoapis.com/crm/v2/Leads/search?criteria=((Last_Name:equals:Burns%5C%2CB)and(First_Name:starts_with:M))"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
3.0.08.0
CopiedString moduleAPIName = "Leads";

//Get instance of RecordOperations Class
RecordOperations recordOperations = new RecordOperations();

ParameterMap paramInstance = new ParameterMap();

paramInstance.add(SearchRecordsParam.CRITERIA, "((Last_Name:starts_with:Last Name) and (Company:starts_with:fasf\\(123\\) K))");

paramInstance.add(SearchRecordsParam.EMAIL, "raja@gmail.com");

paramInstance.add(SearchRecordsParam.PHONE, "234567890");

paramInstance.add(SearchRecordsParam.WORD, "First Name Last Name");

paramInstance.add(SearchRecordsParam.CONVERTED, "both");

paramInstance.add(SearchRecordsParam.APPROVED, "both");

paramInstance.add(SearchRecordsParam.PAGE, 1);

paramInstance.add(SearchRecordsParam.PER_PAGE, 2);
HeaderMap headerInstance = new HeaderMap();
//Call searchRecords method that takes moduleAPIName and ParameterMap Instance as parameter
APIResponse < ResponseHandler > response = recordOperations.searchRecords(moduleAPIName, paramInstance,headerInstance);
Copiedpackage com.zoho.crm.api.sample.restapi.records;
import javax.net.ssl.SSLContext;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.conn.ssl.NoopHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
public class SearchRecordsAPI 
{
	public static void main(String[] args) 
	{
		try
		{
			HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
			SSLContext sslContext = SSLContext.getDefault();
			SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, NoopHostnameVerifier.INSTANCE);
			CloseableHttpClient httpclient = httpClientBuilder.setSSLSocketFactory(sslConnectionSocketFactory).build();
			URIBuilder uriBuilder = new URIBuilder("https://www.zohoapis.com/crm/v2/Leads/search");
			uriBuilder.addParameter("criteria", "((Last_Name:starts_with:Last Name) and (Company:starts_with:fasf\\\\(123\\\\) K))");
			uriBuilder.addParameter("email", "raja@gmail.com");
			uriBuilder.addParameter("phone", "234567890");
			uriBuilder.addParameter("word", "First Name Last Name");
			uriBuilder.addParameter("converted", "both");
			uriBuilder.addParameter("approved", "both");
			uriBuilder.addParameter("page", "1");
			uriBuilder.addParameter("per_page", "1");
			HttpUriRequest requestObj = new HttpGet(uriBuilder.build());
			requestObj.addHeader("Authorization", "Zoho-oauthtoken 1000.xxxxxxx.xxxxxxx");
			HttpResponse response = httpclient.execute(requestObj);
			HttpEntity responseEntity = response.getEntity();
			System.out.println("HTTP Status Code : " + response.getStatusLine().getStatusCode());
			if(responseEntity != null)
			{
				Object responseObject = EntityUtils.toString(responseEntity);
				String responseString = responseObject.toString();
				System.out.println(responseString);
			}
		}
		catch(Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
3.0.07.x
Copied//Get instance of RecordOperations Class that takes moduleAPIName as parameter
 $recordOperations = new RecordOperations();
 $paramInstance = new ParameterMap();
 $paramInstance->add(SearchRecordsParam::criteria(), "((Last_Name:starts_with:Last Name) or (Company:starts_with:fasf\\(123\\) K))");
 $paramInstance->add(SearchRecordsParam::email(), "abc@xyz.com");
 $paramInstance->add(SearchRecordsParam::phone(), "234567890");
 $paramInstance->add(SearchRecordsParam::word(), "First Name Last Name");
 $paramInstance->add(SearchRecordsParam::converted(), "both");
 $paramInstance->add(SearchRecordsParam::approved(), "both");
  $paramInstance->add(SearchRecordsParam::page(), 1);
 $paramInstance->add(SearchRecordsParam::perPage(), 2);
$headerInstance = new HeaderMap();
//Call searchRecords method
$response = $recordOperations->searchRecords($moduleAPIName,$paramInstance,$headerInstance);
Copied<?php
class SearchRecords{
    
    public function execute(){
        $curl_pointer = curl_init();
        
        $curl_options = array();
        $url = "https://www.zohoapis.com/crm/v2/Leads/search?";
        $parameters = array();
        $parameters["page"]="1";
        $parameters["per_page"]="2";
        $parameters["word"]="as";
        
        foreach ($parameters as $key=>$value){
            $url =$url.$key."=".$value."&";
        }
        $curl_options[CURLOPT_URL] = $url;
        $curl_options[CURLOPT_RETURNTRANSFER] = true;
        $curl_options[CURLOPT_HEADER] = 1;
        $curl_options[CURLOPT_CUSTOMREQUEST] = "GET";
        $headersArray = array();
        $headersArray[] = "Authorization". ":" . "Zoho-oauthtoken " ."1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf";
        $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 SearchRecords())->execute();
3.0.08.x
Copied//Get instance of RecordOperations Class
RecordOperations recordOperations = new RecordOperations();
ParameterMap paramInstance = new ParameterMap();
paramInstance.Add(SearchRecordsParam.CRITERIA, "((Last_Name:starts_with:Last Name) and (Company:starts_with:fasf\\(123\\) K))");
paramInstance.Add(SearchRecordsParam.EMAIL, "abc@zoho.com");
paramInstance.Add(SearchRecordsParam.PHONE, "234567890");
paramInstance.Add(SearchRecordsParam.WORD, "First Name Last Name");
paramInstance.Add(SearchRecordsParam.CONVERTED, "both");
paramInstance.Add(SearchRecordsParam.APPROVED, "both");
paramInstance.Add(SearchRecordsParam.PAGE, 1);
paramInstance.Add(SearchRecordsParam.PER_PAGE, 2);
HeaderMap headerInstance = new HeaderMap();
//Call SearchRecords method that takes moduleAPIName and ParameterMap Instance as parameter
APIResponse<ResponseHandler>response = recordOperations.SearchRecords(moduleAPIName, paramInstance,headerInstance);
Copiedusing System;
using System.IO;
using System.Net;
namespace Com.Zoho.Crm.API.Sample.RestAPI.Records
{
    public class SearchRecordsAPI
    {
        public static void SearchRecords()
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.zohoapis.com/crm/v2/Leads/search?email=abc@gmail.com");
            request.Method = "GET";
            request.Headers["Authorization"] = "Zoho-oauthtoken 1000.abfeXXXXXXXXXXX2asw.XXXXXXXXXXXXXXXXXXsdc2";
            request.KeepAlive = true;
            HttpWebResponse response;
            try
            {
                response = (HttpWebResponse)request.GetResponse();
            }
            catch (WebException e)
            {
                if (e.Response == null) { throw; }
                response = (HttpWebResponse)e.Response;
            }
            HttpWebResponse responseEntity = response;
            Console.WriteLine("HTTP Status Code : " + (int)response.StatusCode);
            string responsestring = new StreamReader(responseEntity.GetResponseStream()).ReadToEnd();
            responseEntity.Close();
            Console.WriteLine(responsestring);
        }
    }
}
3.0.03.x.x
Copied# Get instance of RecordOperations Class
record_operations = RecordOperations()
# Get instance of ParameterMap Class
param_instance = ParameterMap()
# Possible parameters for Search Records operation
param_instance.add(SearchRecordsParam.email, 'user@zoho.com')
param_instance.add(SearchRecordsParam.phone, '234567890')
param_instance.add(SearchRecordsParam.word, 'First Name Last Name')
param_instance.add(SearchRecordsParam.approved, 'both')
param_instance.add(SearchRecordsParam.converted, 'both')
param_instance.add(SearchRecordsParam.page, 1)
param_instance.add(SearchRecordsParam.per_page, 20)
# Encoding must be done for parentheses or comma
param_instance.add(SearchRecordsParam.criteria, '((Last_Name:starts_with:Last Name) and
(Company:starts_with:fasf\\(123\\) K))')
# param_instance.add(SearchRecordsParam.criteria, "(External:in:TestExternal12)")
# Get instance of HeaderMap Class
header_instance = HeaderMap()
# header_instance.add(SearchRecordsHeader.x_external, "Leads.External")
# Call searchRecords method that takes ParameterMap Instance and moduleAPIName as parameter
response = record_operations.search_records(module_api_name, param_instance, header_instance)
Copieddef search_records():
    import requests

    url = 'https://www.zohoapis.com/crm/v2/Leads/search'

    headers = {
        'Authorization': 'Zoho-oauthtoken 1000.04be928e4a96XXXXXXXXXXXXX68.0b9eXXXXXXXXXXXX60396e268',
    }

    parameters = {
        'criteria': '((Last_Name:starts_with:Last Name) and (Company:starts_with:fasf\\\\(123\\\\) K))',
        'email': 'newlead@zoho.com',
        'phone': '234567890',
        'word': 'First Name Last Name',
        'converted': 'both',
        'approved': 'both',
        'page': 1,
        'per_page': 15
    }

    response = requests.get(url=url, headers=headers, params=parameters)

    if response is not None:
        print("HTTP Status Code : " + str(response.status_code))

        print(response.json())

search_records()
1.0.010.x
Copied//Get instance of RecordOperations Class
let recordOperations = new RecordOperations();
//Get instance of ParameterMap Class
let paramInstance = new ParameterMap();
/* Possible parameters for Search Records operation */
await paramInstance.add(SearchRecordsParam.EMAIL, "abc@zoho.com");
await paramInstance.add(SearchRecordsParam.PHONE, "234567890");
await paramInstance.add(SearchRecordsParam.WORD, "First Name Last Name");
await paramInstance.add(SearchRecordsParam.CONVERTED, "both");
await paramInstance.add(SearchRecordsParam.APPROVED, "both");
await paramInstance.add(SearchRecordsParam.PAGE, 1);
await paramInstance.add(SearchRecordsParam.PER_PAGE, 2);
//Encoding must be done for parentheses or comma
await paramInstance.add(SearchRecordsParam.CRITERIA, "((Last_Name:starts_with:Last Name) or (Company:starts_with:fasf\\(123\\) K))");
//Get instance of HeaderMap Class
let headerInstance = new HeaderMap();
//Call searchRecords method that takes ParameterMap Instance and moduleAPIName as parameter
let response = await recordOperations.searchRecords(moduleAPIName, paramInstance,headerInstance);
Copiedasync function searchRecords() {
    const got = require("got");

    let url = 'https://www.zohoapis.com/crm/v2/Leads/search'

    let headers = {
        Authorization : "Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
    }

    let parameters = {
        'criteria': '((Last_Name:starts_with:Last Name) and (Company:starts_with:fasf\\\\(123\\\\) K))',
        'email': 'newlead@zoho.com',
        'phone': '234567890',
        'word': 'First Name Last Name',
        'converted': 'both',
        'approved': 'both',
        'page': 1,
        'per_page': 15
    }

    let requestDetails = {
        method : "GET",
        headers : headers,
        searchParams : parameters,
        throwHttpErrors : false
    }
    
    let response = await got(url, requestDetails)
    
    if(response != null) {
        console.log(response.statusCode);
        console.log(response.body);
    }
}
searchRecords()
2.02.x.x
Copied# Get instance of RecordOperations Class
ro = Record::RecordOperations.new
# Get instance of ParameterMap Class
pm = ParameterMap.new
# record_id = 3524033000005495066
# Possible parameters for Search Records operation
# Encoding must be done for parentheses or comma
pm.add(Record::RecordOperations::SearchRecordsParam.criteria, 'Last_Name:starts_with:a')

# pm.add(Record::RecordOperations::GetRecordParam.converted,"false")
# field_names =["Company","Email"]
# field_names.each do |field_name|
# pm.add(Record::::RecordOperations::GetRecordParam.fields,field_name)
# end
# Get instance of HeaderMap Class
hm = HeaderMap.new
# Call searchRecords method that takes ParameterMap Instance and moduleAPIName as parameter
response = ro.search_records(module_api_name,pm,hm)
Copiedclass SearchRecords 

    def execute
        parameters ={}
        parameters["per_page"]="2";
        parameters["page"]="1";
        parameters["word"]="as";
        query_string = parameters.to_a.map { |x| "#{x[0]}=#{x[1]}" }.join('&')
        url= "https://www.zohoapis.com/crm/v2/Leads/search"
        url += '?' + query_string if !query_string.nil? && (query_string.strip != '')
        url = URI(url)
        req = Net::HTTP::Get.new(url.request_uri)
        http = Net::HTTP.new(url.host, url.port)
        http.use_ssl = true
        headers={}
        headers["Authorization"]="Zoho-oauthtoken 1000.50XXXXXXXXX&77e3a.44XXXXXXXXX8353"
        headers&.each { |key, value| req.add_field(key, value) }
        response=http.request(req)
        status_code = response.code.to_i
        headers = response.each_header.to_h
        print status_code
        print headers
        unless response.body.nil?
            print  response.body
        end
    end
end
SearchRecords.new.execute
1.0.0ES6
Copied//Get instance of RecordOperations Class
let recordOperations = new ZCRM.Record.Operations();
//Get instance of ParameterMap Class
let paramInstance = new ParameterMap();
/* Possible parameters for Search Records operation */
await paramInstance.add(ZCRM.Record.Model.SearchRecordsParam.EMAIL, "abc@gmail.com");
await paramInstance.add(ZCRM.Record.Model.SearchRecordsParam.PHONE, "234567890");
await paramInstance.add(ZCRM.Record.Model.SearchRecordsParam.WORD, "First Name Last Name");
await paramInstance.add(ZCRM.Record.Model.SearchRecordsParam.CONVERTED, "both");
await paramInstance.add(ZCRM.Record.Model.SearchRecordsParam.APPROVED, "both");
await paramInstance.add(ZCRM.Record.Model.SearchRecordsParam.PAGE, 1);
await paramInstance.add(ZCRM.Record.Model.SearchRecordsParam.PER_PAGE, 2);
//Encoding must be done for parentheses or comma
await paramInstance.add(ZCRM.Record.Model.SearchRecordsParam.CRITERIA, "((Last_Name:starts_with:Last Name) or (Company:starts_with:fasf\\(123\\) K))");
//Call searchRecords method that takes ParameterMap Instance and moduleAPIName as parameter
let response = await recordOperations.searchRecords(moduleAPIName, paramInstance);
Copiedvar listener = 0;
class SearchRecordsAPI {

	async searchRecords() {
		var url = "https://www.zohoapis.com/crm/v2/Leads/search"
        var parameters = new Map()
        var headers = new Map()
        var token = {
            clientId:"1000.NPY9M1V0XXXXXXXXXXXXXXXXXXXF7H",
            redirectUrl:"http://127.0.0.1:5500/redirect.html",
            scope:"ZohoCRM.users.ALL,ZohoCRM.bulk.read,ZohoCRM.modules.ALL,ZohoCRM.settings.ALL,Aaaserver.profile.Read,ZohoCRM.org.ALL,profile.userphoto.READ,ZohoFiles.files.ALL,ZohoCRM.bulk.ALL,ZohoCRM.settings.variable_groups.ALL"
        }
        var accesstoken = await new SearchRecordsAPI().getToken(token)
        headers.set("Authorization", "Zoho-oauthtoken " + accesstoken)
        // parameters.set("criteria", "((Last_Name:starts_with:Last Name) and (Company:starts_with:fasf\\\\(123\\\\) K))")
        // parameters.set("email", "abc@gmail.com")
        // parameters.set("phone", "234567890")
        parameters.set("word", "Firs")
        // parameters.set("converted", "both")
        // parameters.set("approved", "both")
        // parameters.set("page", "1")
        // parameters.set("per_page", "1")
        var requestMethod = "GET"
        var reqBody = null
        var params = "";
        parameters.forEach(function(value, key) {
            if (parameters.has(key)) {
                if (params) {
                    params = params + key + '=' + value + '&';
                }
                else {
                    params = key + '=' + value + '&';
                }
            }
        });
        var apiHeaders = {};
        if(headers) {
            headers.forEach(function(value, key) {
                apiHeaders[key] = value;
            });
        }
        if (params.length > 0){
            url = url + '?' + params.substring(0, params.length - 1);
        }
        var requestObj = {
            uri : url,
            method : requestMethod,
            headers : apiHeaders,
            body : JSON.stringify(reqBody),
            encoding: "utf8",
            allowGetBody : true,
			throwHttpErrors : false
        };
        var result = await new SearchRecordsAPI().makeAPICall(requestObj);
        console.log(result.status)
        console.log(result.response)
	}

    async getToken(token) {

        if(listener == 0) {

            window.addEventListener("storage", function(reponse) {
                if(reponse.key === "access_token" && (reponse.oldValue != reponse.newValue || reponse.oldValue == null)){
                    location.reload();
                }
                if(reponse.key === "access_token"){

                    sessionStorage.removeItem("__auth_process");
                }
            }, false);
            listener = 1;
            if(sessionStorage.getItem("__auth_process")) {
                sessionStorage.removeItem("__auth_process");
            }
        }
        ["granted_for_session", "access_token","expires_in","expires_in_sec","location","api_domain","state","__token_init","__auth_process"].forEach(function (k) {
            var isKeyExists = localStorage.hasOwnProperty(k);
            if(isKeyExists) {
                sessionStorage.setItem(k, localStorage[k]);
            }
            localStorage.removeItem(k);
        });
        var valueInStore = sessionStorage.getItem("access_token");
        var tokenInit = sessionStorage.getItem("__token_init");
        if(tokenInit != null && valueInStore != null && Date.now() >= parseInt(tokenInit) + 59 * 60 * 1000){ // check after 59th minute
            valueInStore = null;
            sessionStorage.removeItem("access_token");
        }

        var auth_process = sessionStorage.getItem("__auth_process");
        if ((valueInStore == null && auth_process == null) || (valueInStore == 'undefined' && (auth_process == null || auth_process == "true"))) {
            var accountsUrl = "https://accounts.zoho.com/oauth/v2/auth"
            var clientId;
            var scope;
            var redirectUrl;
            if(token != null) {
                clientId = token.clientId;
                scope = token.scope;
                redirectUrl = token.redirectUrl;
            }

            var fullGrant = sessionStorage.getItem("full_grant");
            var grantedForSession = sessionStorage.getItem("granted_for_session");
            if(sessionStorage.getItem("__token_init") != null && ((fullGrant != null && "true" == full_grant) || (grantedForSession != null && "true" == grantedForSession))) {
                accountsUrl += '/refresh';
            }
            if (clientId && scope) {
                sessionStorage.setItem("__token_init", Date.now());
                sessionStorage.removeItem("access_token");
                sessionStorage.setItem("__auth_process", "true");
                window.open(accountsUrl + "?" + "scope" + "=" + scope + "&"+ "client_id" +"=" + clientId + "&response_type=token&state=zohocrmclient&redirect_uri=" + redirectUrl);
                ["granted_for_session", "access_token","expires_in","expires_in_sec","location","api_domain","state","__token_init","__auth_process"].forEach(function (k) {
                    var isKeyExists = localStorage.hasOwnProperty(k);
                    if(isKeyExists){
                        sessionStorage.setItem(k, localStorage[k]);
                    }
                    localStorage.removeItem(k);
                });
                valueInStore = sessionStorage.getItem("access_token");
            }
        }
        if(token != null && valueInStore != 'undefined'){
            token.accessToken = valueInStore;
        }
        return token.accessToken;
    }

    async makeAPICall(requestDetails) {
        return new Promise(function (resolve, reject) {
            var body, xhr, i;
            body = requestDetails.body || null;
            xhr = new XMLHttpRequest();
            xhr.withCredentials = true;
            xhr.open(requestDetails.method, requestDetails.uri, true);
            for (i in requestDetails.headers) {
                xhr.setRequestHeader(i, requestDetails.headers[i]);
            }
            xhr.send(body);
            xhr.onreadystatechange = function() {
                if(xhr.readyState == 4) {
                    resolve(xhr);
                }
            }
        })
    }
}
Copiedresponse = invokeurl
[
	url: "https://www.zohoapis.com/crm/v2/Leads/search?criteria=((Last_Name:equals:Burns%5C%2CB)and(First_Name:starts_with:M))"
	type: GET
	connection:"crm_oauth_connection"
];
info response;

Sample Response

Copied{
    "data": [
        {
            "Account": null,
            "Owner": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Company": "Company",
            "Email": "burns.mary@xyz.com",
            "$currency_symbol": "Rs.",
            "Visitor_Score": null,
            "Last_Activity_Time": "2019-02-19T12:05:23+05:30",
            "Industry": "ERP",
            "$converted": false,
            "$process_flow": false,
            "Street": "4 B Blue Ridge Blvd",
            "Zip_Code": "48116",
            "id": "3652397000000190367",
            "$approved": true,
            "$approval": {
                "delegate": false,
                "approve": false,
                "reject": false,
                "resubmit": false
            },
            "First_Visited_URL": null,
            "Days_Visited": null,
            "Created_Time": "2018-11-14T15:31:28+05:30",
            "$editable": true,
            "City": "Brighton",
            "No_of_Employees": 0,
            "Campaigns_Lookup": null,
            "State": "MI",
            "Country": "Livingston",
            "Last_Visited_Time": null,
            "Created_By": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Annual_Revenue": 200000,
            "Secondary_Email": null,
            "Description": null,
            "Number_Of_Chats": null,
            "Rating": null,
            "Website": null,
            "Twitter": null,
            "Average_Time_Spent_Minutes": null,
            "Associated_Contacts": null,
            "Salutation": "Ms.",
            "First_Name": "Mary",
            "Lead_Status": "Contacted",
            "Full_Name": "Ms. Mary Burns",
            "Record_Image": null,
            "Modified_By": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Skype_ID": "Mary-burns",
            "Phone": "555-555-5555",
            "Email_Opt_Out": true,
            "Designation": "Team Lead",
            "Modified_Time": "2019-02-19T12:05:23+05:30",
            "$converted_detail": {},
            "Mobile": "555-555-5555",
            "Prediction_Score": null,
            "First_Visited_Time": null,
            "Last_Name": "Burns,B",
            "Referrer": null,
            "Lead_Source": "Twitter",
            "Tag": [
                {
                    "name": "Pharma",
                    "id": "3652397000000371014"
                },
                {
                    "name": "Agricultural",
                    "id": "3652397000000371015"
                }
            ],
            "Fax": null
        }
    ],
    "info": {
        "per_page": 200,
        "count": 1,
        "page": 1,
        "more_records": false
    }
}

Request Details: email

Request URL:

https://www.zohoapis.com/crm/v2/{module_api_name}/search?email={{email_here}}

Attributes
  • emailstring

    Performs module search by email. All the email fields of a particular module will be searched and listed.

Sample Request to Search by email

Copiedcurl "https://www.zohoapis.com/crm/v2/Leads/search?email=newcrmapi@zoho.com"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
CopiedZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
String Email="newcrmapi@zoho.com";//email to search with
int page=1;//page number
int perpage=200;//records per page		
BulkAPIResponse response=moduleIns.searchByEmail(Email,page,perpage);//to get the record ,if any parameter(except email) is not needed set null
List<ZCRMRecord> records=(List <ZCRMRecord> )response.getData();
Copied$moduleIns=ZCRMRestClient::getInstance()->getModuleInstance("Leads");  //To get module instance
$response=$moduleIns->searchRecordsByEmail("newcrmapi@zoho.com",1,200);  //To get module records that match the Email address
$records=$response->getData();  //To get response data
Copieddef search_records_by_email(self):
    try:
        module_ins = zcrmsdk.ZCRMModule.get_instance('Contacts')
        resp = module_ins.search_records_by_email('steve@xyz.com')
        print(resp.status_code)
        resp_info = resp.info
        print(resp_info.count)
        print(resp_info.page)
        print(resp_info.per_page)
        print(resp_info.is_more_records)
        record_ins_arr = resp.data
        for record_ins in record_ins_arr:
            print(record_ins.entity_id)
            print(record_ins.created_by.id)
            print(record_ins.modified_by.id)
            print(record_ins.owner.id)
            print(record_ins.created_by.name)
            print(record_ins.created_time)
            print(record_ins.modified_time)
            print(record_ins.get_field_value('Email'))  # To get particular field value
        field_data = record_ins.field_data
        for key in field_data:
            print(key + ":" + str(field_data[key]))
            print("\n\n")
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)  
        print(ex.error_message) 
        print(ex.error_code) 
        print(ex.error_details) 
        print(ex.error_content)
Copiedresponse = invokeurl
[
	url: "https://www.zohoapis.com/crm/v2/Leads/search?email=newcrmapi@zoho.com"
	type: GET
	connection:"crm_oauth_connection"
];
info response;

Sample Response

Copied{
    "data": [
        {
            "Account": null,
            "Owner": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Company": null,
            "Email": "newcrmapi@zoho.com",
            "$currency_symbol": "Rs.",
            "Visitor_Score": null,
            "Last_Activity_Time": "2019-03-22T11:10:55+05:30",
            "Industry": "ASP",
            "$converted": false,
            "$process_flow": false,
            "Street": "Street",
            "Zip_Code": "Zip_Code",
            "id": "3652397000000415002",
            "$approved": true,
            "$approval": {
                "delegate": false,
                "approve": false,
                "reject": false,
                "resubmit": false
            },
            "First_Visited_URL": null,
            "Days_Visited": null,
            "Created_Time": "2019-01-10T13:04:32+05:30",
            "$editable": true,
            "City": "City",
            "No_of_Employees": 100,
            "State": "State",
            "Country": "Country",
            "Last_Visited_Time": null,
            "Created_By": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Annual_Revenue": 100000,
            "Secondary_Email": "newcrmapi@zoho.com",
            "Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.",
            "Number_Of_Chats": null,
            "Rating": "Acquired",
            "Website": "crm.zoho.com",
            "Twitter": "Twitter",
            "Average_Time_Spent_Minutes": null,
            "Associated_Contacts": null,
            "Salutation": "Mr.",
            "First_Name": "First_Name",
            "Lead_Status": "Contacted",
            "Full_Name": "Mr. First_Name Last_Name",
            "Record_Image": null,
            "Modified_By": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Skype_ID": "Skype_ID",
            "Phone": "98883434559",
            "Email_Opt_Out": false,
            "Designation": "Designation",
            "Modified_Time": "2019-03-22T11:10:55+05:30",
            "$converted_detail": {},
            "Mobile": "98883434559",
            "Prediction_Score": null,
            "First_Visited_Time": null,
            "Last_Name": "Last_Name",
            "Referrer": null,
            "Lead_Source": "Twitter",
            "Tag": [],
            "Fax": "Fax"
        }
    ],
    "info": {
        "per_page": 200,
        "count": 1,
        "page": 1,
        "more_records": false
    }
}

Request Details: phone

Request URL:

https://www.zohoapis.com/crm/v2/{module_api_name}/search?phone={{phone_number_here}}

Attributes
  • phonestring

    Performs module search by phone number. All the phone fields of a particular module will be searched and listed.

Sample Request to Search by Phone

Copiedcurl "https://www.zohoapis.com/crm/v2/Leads/search?phone=98883434559
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
CopiedZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
String phone="98883434559";//phone to search with
int page=1;//page number
int perpage=200;//records per page		
BulkAPIResponse response=moduleIns.searchByPhone(phone,page,perpage);//to get the record ,if any parameter(except phone) is not needed set null
List<ZCRMRecord> records=(List <ZCRMRecord> )response.getData();
Copied$moduleIns=ZCRMRestClient::getInstance()->getModuleInstance("Leads");  //To get module instance
$response=$moduleIns->searchRecordsByPhone(98883434559,1,200);  //To get module records that match the phone number
$records=$response->getData();  //To get response data
Copieddef search_records_by_phone(self):
    try:
        module_ins = zcrmsdk.ZCRMModule.get_instance('Leads')
        resp = module_ins.search_records_by_phone('98883434559')
        print(resp.status_code)
        resp_info = resp.info
        print(resp_info.count)
        print(resp_info.page)
        print(resp_info.per_page)
        print(resp_info.is_more_records)
        record_ins_arr = resp.data
            for record_ins in record_ins_arr:
                print(record_ins.entity_id)
                print(record_ins.created_by.id)
                print(record_ins.modified_by.id)
                print(record_ins.owner.id)
                print(record_ins.created_by.name)
                print(record_ins.created_time)
                print(record_ins.modified_time)
                print(record_ins.get_field_value('Email'))  # To get particular field value
            field_data = record_ins.field_data
            for key in field_data:
                print(key + ":" + str(field_data[key]))
                print("\n\n")
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)  
        print(ex.error_message) 
        print(ex.error_code) 
        print(ex.error_details) 
        print(ex.error_content)
Copiedresponse = invokeurl
[
	url: "https://www.zohoapis.com/crm/v2/Leads/search?phone=98883434559"
	type: GET
	connection:"crm_oauth_connection"
];
info response;

Sample Response

Copied{
    "data": [
        {
            "Account": null,
            "Owner": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Company": null,
            "Email": "newcrmapi@zoho.com",
            "$currency_symbol": "Rs.",
            "Visitor_Score": null,
            "Last_Activity_Time": "2019-03-22T11:10:55+05:30",
            "Industry": "ASP",
            "$converted": false,
            "$process_flow": false,
            "Street": "Street",
            "Zip_Code": "Zip_Code",
            "id": "3652397000000415002",
            "$approved": true,
            "$approval": {
                "delegate": false,
                "approve": false,
                "reject": false,
                "resubmit": false
            },
            "First_Visited_URL": null,
            "Days_Visited": null,
            "Created_Time": "2019-01-10T13:04:32+05:30",
            "$editable": true,
            "City": "City",
            "No_of_Employees": 100,
            "State": "State",
            "Country": "Country",
            "Last_Visited_Time": null,
            "Created_By": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Annual_Revenue": 100000,
            "Secondary_Email": "newcrmapi@zoho.com",
            "Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.",
            "Number_Of_Chats": null,
            "Rating": "Acquired",
            "Website": "crm.zoho.com",
            "Twitter": "Twitter",
            "Average_Time_Spent_Minutes": null,
            "Associated_Contacts": null,
            "Salutation": "Mr.",
            "First_Name": "First_Name",
            "Lead_Status": "Contacted",
            "Full_Name": "Mr. First_Name Last_Name",
            "Record_Image": null,
            "Modified_By": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Skype_ID": "Skype_ID",
            "Phone": "98883434559",
            "Email_Opt_Out": false,
            "Designation": "Designation",
            "Modified_Time": "2019-03-22T11:10:55+05:30",
            "$converted_detail": {},
            "Mobile": "98883434559",
            "Prediction_Score": null,
            "First_Visited_Time": null,
            "Last_Name": "Last_Name",
            "Referrer": null,
            "Lead_Source": "Twitter",
            "Tag": [],
            "Fax": "Fax"
        }
    ],
    "info": {
        "per_page": 200,
        "count": 1,
        "page": 1,
        "more_records": false
    }
}

Request Details: word

Request URL:

https://www.zohoapis.com/crm/v2/{module_api_name}/search?word={{search_word_here}}

Attributes
  • wordstring

    Performs global search by word.

Sample Request to Search by word

Copiedcurl "https://www.zohoapis.com/crm/v2/Leads/search?word=abc"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
CopiedZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
String searchtext="abc";//text to search with
int page=1;//page number
int perpage=50;//records per page		
BulkAPIResponse response=moduleIns.searchByText(searchtext,page,perpage);//to get the record ,if any parameter(except text) is not needed set null
List<ZCRMRecord> records=(List <ZCRMRecord> )response.getData();
Copied$moduleIns=ZCRMRestClient::getInstance()->getModuleInstance("Leads");  //To get module instance
$response=$moduleIns->searchRecords(abc,1,200);  //To get module records that match the search word
$records=$response->getData();  //To get response data
Copieddef search_records(self):
    try:
        module_ins = zcrmsdk.ZCRMModule.get_instance('Quotes')
        resp = module_ins.search_records('(Sub)')
        print(resp.status_code)
        resp_info = resp.info
        print(resp_info.count)
        print(resp_info.page)
        print(resp_info.per_page)
        print(resp_info.is_more_records)
        record_ins_arr = resp.data
        for record_ins in record_ins_arr:
            print(record_ins.entity_id)
            print(record_ins.created_by.id)
            print(record_ins.modified_by.id)
            print(record_ins.owner.id)
            print(record_ins.created_by.name)
            print(record_ins.created_time)
            print(record_ins.modified_time)
            print(record_ins.get_field_value('Email'))  # To get particular field value
            if record_ins.line_items is not None:
                for line_item in record_ins.line_items:
                    print("::::::LINE ITEM DETAILS::::::")
                    print(line_item.id)
                    print(line_item.product.lookup_label)
                    print(line_item.product.get_field_value('Product_Code'))
                    print(line_item.product.entity_id)
                    print(line_item.list_price)
                    print(line_item.quantity)
                    print(line_item.description)
                    print(line_item.total)
                    print(line_item.discount)
                    print(line_item.discount_percentage)
                    print(line_item.total_after_discount)
                    print(line_item.tax_amount)
                    print(line_item.net_total)
                    print(line_item.delete_flag)
                    if line_item.line_tax is not None:
                        for tax in line_item.line_tax:
                            print(":::::: TAX DETAILS ::::::")
                            print(tax.name)
                            print(tax.value)
                            print(tax.percentage)
            field_data = record_ins.field_data
            for key in field_data:
                print(key + ":" + str(field_data[key]))
                print("\n\n")
    except ZCRMException as ex:
        print ex.status_code
        print ex.error_message
        print ex.error_code
        print ex.error_details
        print ex.error_content
Copiedresponse = invokeurl
[
	url: "https://www.zohoapis.com/crm/v2/Leads/search?word=abc"
	type: GET
	connection:"crm_oauth_connection"
];
info response;

Sample Response

Copied{
    "data": [
        {
            "Owner": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Company": "Company1",
            "Email": null,
            "$currency_symbol": "Rs.",
            "Visitor_Score": null,
            "Last_Activity_Time": null,
            "Industry": null,
            "$converted": false,
            "$process_flow": false,
            "Street": null,
            "Zip_Code": null,
            "id": "3652397000000562046",
            "$approved": true,
            "$approval": {
                "delegate": false,
                "approve": false,
                "reject": false,
                "resubmit": false
            },
            "First_Visited_URL": null,
            "Days_Visited": null,
            "Created_Time": "2019-02-19T12:57:55+05:30",
            "$editable": true,
            "City": null,
            "No_of_Employees": null,
            "Campaigns_Lookup": null,
            "State": null,
            "Country": null,
            "Last_Visited_Time": null,
            "Created_By": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Annual_Revenue": null,
            "Secondary_Email": null,
            "Description": null,
            "Number_Of_Chats": null,
            "Rating": null,
            "Website": null,
            "Twitter": null,
            "Average_Time_Spent_Minutes": null,
            "Salutation": null,
            "First_Name": null,
            "Lead_Status": null,
            "Full_Name": "abc",
            "Record_Image": null,
            "Modified_By": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Skype_ID": null,
            "Phone": null,
            "Email_Opt_Out": false,
            "Designation": null,
            "Modified_Time": "2019-02-19T12:57:55+05:30",
            "$converted_detail": {},
            "Mobile": null,
            "Prediction_Score": null,
            "First_Visited_Time": null,
            "Last_Name": "abc",
            "Referrer": null,
            "Lead_Source": null,
            "Tag": [],
            "Fax": null
        },
        {
            "Owner": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Company": "abc",
            "Email": null,
            "$currency_symbol": "Rs.",
            "Visitor_Score": null,
            "Last_Activity_Time": "2019-02-19T12:06:28+05:30",
            "Industry": "ERP (Enterprise Resource Planning)",
            "$converted": false,
            "$process_flow": false,
            "Street": null,
            "Zip_Code": null,
            "id": "3652397000000538029",
            "$approved": true,
            "$approval": {
                "delegate": false,
                "approve": false,
                "reject": false,
                "resubmit": false
            },
            "First_Visited_URL": null,
            "Days_Visited": null,
            "Created_Time": "2019-02-14T18:19:22+05:30",
            "$editable": true,
            "City": "Albany",
            "No_of_Employees": null,
            "Campaigns_Lookup": null,
            "State": null,
            "Country": null,
            "Last_Visited_Time": null,
            "Created_By": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Annual_Revenue": null,
            "Secondary_Email": null,
            "Description": null,
            "Number_Of_Chats": null,
            "Rating": null,
            "Website": null,
            "Twitter": null,
            "Average_Time_Spent_Minutes": null,
            "Salutation": null,
            "First_Name": "Test1",
            "Lead_Status": "Contacted",
            "Full_Name": "Test1 Lead1",
            "Record_Image": null,
            "Modified_By": {
                "name": "Patricia Boyle",
                "id": "3652397000000186017"
            },
            "Skype_ID": null,
            "Phone": null,
            "Email_Opt_Out": true,
            "Designation": "Team Lead",
            "Modified_Time": "2019-02-19T12:06:28+05:30",
            "$converted_detail": {},
            "Mobile": null,
            "Prediction_Score": null,
            "First_Visited_Time": null,
            "Last_Name": "Lead1",
            "Referrer": null,
            "Lead_Source": "Advertisement",
            "Tag": [],
            "Fax": null
        }
    ],
    "info": {
        "per_page": 200,
        "count": 2,
        "page": 1,
        "more_records": false
    }
}

Other optional parameters

  • convertedstring

    To get the list of converted records. Default value is false.

    • true - get only converted records

    • false - get only non-converted records

    • both - get all records

  • approvedstring

    To get the list of approved records. Default value is true.

    • true - get only approved records

    • false - get only records which are not approved

    • both - get all records

  • pageinteger

    To get the list of records from the respective pages. Default value for page is 1.

  • per_pageinteger

    To get the list of records available per page. The default and the maximum possible value is 200.

Sample Request: To Search with a Single Criterion

Copiedcurl "https://www.zohoapis.com/crm/v2/Campaigns/search?criteria=Campaign_Name:equals:CRM&fields=Campaign_Name,Type"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Note
  • Only one of the mandatory parameters (criteria, email, phone, word) would work at one point of time. Furthermore, if two parameters are given simultaneously, preference will be given in the order criteria, email, phone, and word, and only one of them would work.

  • The page and per_page parameter is used to fetch records according to their position in the CRM. Let's assume that the user has to fetch 400 records. The maximum number of records that one can get for an API call is 200. So, for records above the 200th position, they cannot be fetched. By changing the values of the page (1, 2) and per_page (200) parameters, the user can fetch all 400 records using 2 API calls.

  • Usually, there is a delay in fetching the result of a search action. However, in a module-specific search, if you use one of the below mentioned fields (of the data type "string") in the criteria, you will get the response without any delay.
    Leads/Contacts - "Email" field
    Accounts - "Account_Name" field
    Potentials/Deals - "Deal_Name" field
    Campaigns - "Campaign_Name" field
    Cases - "Subject" field
    Solutions - "Solution_Title" field
    Products - "Product_Name" field
    Vendors - "Vendor_Name" field
    PriceBooks - "Price_Book_Name" field
    Quotes - "Subject" field
    SalesOrders - "Subject" field
    PurchaseOrders - "Subject" field
    Invoices - "Subject" field
    CustomModule - "Name" field

  • The value of the fields with sensitive health data will be retrieved only when Restrict Data access through API option in the compliance settings is disabled. If the option is enabled, the value will be null. Refer to HIPAA compliance for more details.

Possible Errors

  • MANDATORY_NOT_FOUNDHTTP 400

    mandatory param missing
    Resolution: Specify any of the mandatory parameters (criteria/email/phone/word) in your request.

  • INVALID_QUERYHTTP 400

    invalid query formed
    Resolution: The operators/field API names in your search query is invalid (or) The field specified is not available in the search module. Specify a valid search query.

  • INVALID_DATAHTTP 400

    provide atleast 2 letters for search
    Resolution: You have specified special characters in your search query. Specify a valid search query.

  • NOT_SUPPORTEDHTTP 400

    module not supported for search
    Resolution: The module you have specified is not supported for search operation. Refer to possible modules section above and specify a valid module API name.

  • INVALID_URL_PATTERNHTTP 404

    Please check if the URL trying to access is a correct one
    Resolution: The request URL specified is incorrect. Specify a valid request URL. Refer to request URL section above.

  • OAUTH_SCOPE_MISMATCHHTTP 401

    Unauthorized
    Resolution: Client does not have ZohoSearch.securesearch.READ scope. Create a new client with valid scope. Refer to scope section above.

  • NO_PERMISSIONHTTP 403

    Permission denied to read
    Resolution: The user does not have permission to read records. Contact your system administrator.

  • INTERNAL_ERRORHTTP 500

    Internal Server Error
    Resolution: Unexpected and unhandled exception in the server. Contact support team.

  • INVALID_REQUEST_METHODHTTP 400

    The http request method type is not a valid one
    Resolution: You have specified an invalid HTTP method to access the API URL. Specify a valid request method. Refer to endpoints section above.

  • AUTHORIZATION_FAILEDHTTP 400

    User does not have sufficient privilege to read module details.
    Resolution: The user does not have the permission to retrieve module details. Contact your system administrator.

  • INVALID_QUERYHTTP 400

    Cannot use the restricted field
    Resolution: You cannot add a restricted field in the search criteria. Refer to HIPAA compliance for more details.

Sample Response

Copied{
    "data": [
        {
            "Type": "Trade Show",
            "Campaign_Name": "CRM",
            "id": "3652397000002247003"
        }
    ],
    "info": {
        "per_page": 200,
        "count": 1,
        "page": 1,
        "more_records": false
    }
}