Get List of Deleted Records
Purpose
To get the list of deleted records.
Endpoints
Request Details
Request URL
{api-domain}/crm/{version}/{module_api_name}/deleted
Supported modules
Leads, Accounts, Contacts, Deals, Campaigns, Tasks, Cases, Events, Calls, Solutions, Products, Vendors, Price Books, Quotes, Sales Orders, Purchase Orders, Invoices, Custom, and Activities
Header
Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52
If-Modified-Since: Use this header to get the list of recently modified records. Example: 2019-07-25T15:26:49+05:30
Scope
scope=ZohoCRM.modules.ALL
(or)
scope=ZohoCRM.modules.{module_name}.{operation_type}
Possible module names
leads, accounts, contacts, deals, campaigns, tasks, cases, events, calls, solutions, products, vendors, pricebooks, quotes, salesorders, purchaseorders, invoices, custom, and activities
Possible operation types
ALL - Full access to the record
READ - Get records in the module
Parameters
- typestring, optional
Specify the type of deleted records you want to retrieve.
Possible values -- all: To get the list of all deleted records. This is the default value.
- recycle: To get the list of deleted records from recycle bin.
- permanent: To get the list of permanently deleted records.
- pageinteger, optional
To get the list of records from the respective pages. Default value for page is 1.
Possible values: Positive integers only - per_pageinteger, optional
To get the list of records available per page. The default and the maximum possible value is 200.
Possible values: Positive integers only
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 using the page (1, 2) and per_page (200) parameter, the user can fetch all 400 records using 2 API calls.
- Using this API, you can fetch records that have been temporarily deleted or moved to the recycle bin up to 60 days from the date of deletion. Similarly, records that have been permanently deleted can be retrieved up to 120 days from the date of deletion.
Sample Request
Copiedcurl "https://www.zohoapis.com/crm/v2.1/Leads/deleted?type=all"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
CopiedString moduleAPIName = "Leads";
//Get instance of RecordOperations Class
RecordOperations recordOperations = new RecordOperations();
//Get instance of ParameterMap Class
ParameterMap paramInstance = new ParameterMap();
paramInstance.add(GetDeletedRecordsParam.TYPE, "permanent"); //all, recycle, permanent
paramInstance.add(GetDeletedRecordsParam.PAGE, 1);
paramInstance.add(GetDeletedRecordsParam.PER_PAGE, 2);
//Get instance of HeaderMap Class
HeaderMap headerInstance = new HeaderMap();
OffsetDateTime ifModifiedSince = OffsetDateTime.of(2020, 05, 02, 12, 00, 30, 00, ZoneOffset.of("+05:30"));
headerInstance.add(GetDeletedRecordsHeader.IF_MODIFIED_SINCE, ifModifiedSince);
//Call getDeletedRecords method that takes moduleAPIName, headerInstance and paramInstance as parameter
APIResponse < DeletedRecordsHandler > response = recordOperations.getDeletedRecords(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 GetListofDeletedRecords
{
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/deleted");
uriBuilder.addParameter("type", "recycle");
uriBuilder.addParameter("page", "1");
uriBuilder.addParameter("per_page", "5");
HttpUriRequest requestObj = new HttpGet(uriBuilder.build());
requestObj.addHeader("Authorization", "Zoho-oauthtoken 1000.xxxxxxx.xxxxxxx");
requestObj.addHeader("If-Modified-Since", "2020-05-15T12:00:00+05:30");
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();
}
}
}
Copied//Get instance of RecordOperations Class
$recordOperations = new RecordOperations();
//Get instance of ParameterMap Class
$paramInstance = new ParameterMap();
$paramInstance->add(GetDeletedRecordsParam::type(), "recycle");//all, recycle, permanent
$paramInstance->add(GetDeletedRecordsParam::page(), 1);
$paramInstance->add(GetDeletedRecordsParam::perPage(), 2);
//Get instance of HeaderMap Class
$headerInstance = new HeaderMap();
$ifModifiedSince = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$headerInstance->add(GetDeletedRecordsHeader::IfModifiedSince(), $ifModifiedSince);
//Call getDeletedRecords method that takes paramInstance, headerInstance and moduleAPIName as parameter
$response = $recordOperations->getDeletedRecords($moduleAPIName,$paramInstance, $headerInstance);
Copied<?php
class GetListofDeletedRecords{
public function execute(){
$curl_pointer = curl_init();
$curl_options = array();
$url = "https://www.zohoapis.com/crm/v2/Leads/deleted?";
$parameters = array();
$parameters["id"]="3524033000006020011";
$parameters["per_page"]="2";
$parameters["page"]="1";
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.30f3a589XXXXXXXXXXXXXXXXXXX4077.dc5XXXXXXXXXXXXXXXXXXXee9e7c171c";
$headersArray[] = "If-Modified-Since".":"."2020-10-12T17:59:50+05:30";
$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 GetListofDeletedRecords())->execute();
Copied//Get instance of RecordOperations Class
RecordOperations recordOperations = new RecordOperations();
//Get instance of ParameterMap Class
ParameterMap paramInstance = new ParameterMap();
paramInstance.Add(GetDeletedRecordsParam.TYPE, "permanent");//all, recycle, permanent
paramInstance.Add(GetDeletedRecordsParam.PAGE, 1);
paramInstance.Add(GetDeletedRecordsParam.PER_PAGE, 2);
//Get instance of HeaderMap Class
HeaderMap headerInstance = new HeaderMap();
DateTimeOffset ifModifiedSince = new DateTimeOffset(new DateTime(2020, 05, 15, 12, 0, 0, DateTimeKind.Local));
headerInstance.Add(GetDeletedRecordsHeader.IF_MODIFIED_SINCE, ifModifiedSince);
//Call GetDeletedRecords method that takes moduleAPIName, headerInstance and paramInstance as parameter
APIResponse<DeletedRecordsHandler> response = recordOperations.GetDeletedRecords(moduleAPIName, paramInstance, headerInstance);
Copiedusing System;
using System.IO;
using System.Net;
using System.Xml;
using Newtonsoft.Json;
namespace Com.Zoho.Crm.API.Sample.RestAPI.Records
{
public class GetListofDeletedRecords
{
public static void GetDeletedRecords()
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.zohoapis.com/crm/v2/Leads/deleted?type=recycle&page=1");
request.Method = "GET";
request.Headers["Authorization"] = "Zoho-oauthtoken 1000.abfeXXXXXXXXXXX2asw.XXXXXXXXXXXXXXXXXXsdc2";
string IfModifiedSince = JsonConvert.SerializeObject("2020-05-15T12:00:00+05:30");
IfModifiedSince = IfModifiedSince.Replace("\\", "");
IfModifiedSince = IfModifiedSince.Replace("\"", "");
DateTime dateConversion = XmlConvert.ToDateTime(IfModifiedSince, XmlDateTimeSerializationMode.Utc);
request.IfModifiedSince = dateConversion;
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);
}
}
}
Copied# Get instance of RecordOperations Class
record_operations = RecordOperations()
# Get instance of ParameterMap Class
param_instance = ParameterMap()
# Possible parameters for Get Deleted Records operation
param_instance.add(GetDeletedRecordsParam.page, 1)
param_instance.add(GetDeletedRecordsParam.per_page, 200)
# can be all/recycle/permanent
param_instance.add(GetDeletedRecordsParam.type, 'permanent')
param_instance.add(GetDeletedRecordsParam.page, 2)
param_instance.add(GetDeletedRecordsParam.per_page, 10)
# Get instance of HeaderMap Class
header_instance = HeaderMap()
# Possible headers for Get Deleted Records operation
header_instance.add(GetDeletedRecordsHeader.if_modified_since, datetime.fromisoformat('2020-01-15T10:35:32+05:30'))
# Call getDeletedRecords method that takes param_instance, header_instance and module_api_name as parameter
response = record_operations.get_deleted_records(module_api_name, param_instance, header_instance)
Copieddef get_list_of_deleted_records():
import requests
url = 'https://www.zohoapis.com/crm/v2/Leads/deleted'
headers = {
'Authorization': 'Zoho-oauthtoken 1000.04be928e4a96XXXXXXXXXXXXX68.0b9eXXXXXXXXXXXX60396e268',
'If-Modified-Since': '2020-03-19T17:59:50+05:30'
}
parameters = {
'page': 1,
'per_page': 30,
'type': 'permanent'
}
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())
get_list_of_deleted_records()
Copied//Get instance of RecordOperations Class
let recordOperations = new RecordOperations();
//Get instance of ParameterMap Class
let paramInstance = new ParameterMap();
/* Possible parameters for Get Deleted Records operation */
//can be all/recycle/permanent
await paramInstance.add(GetDeletedRecordsParam.TYPE, "permanent");
await paramInstance.add(GetDeletedRecordsParam.PAGE, 1);
await paramInstance.add(GetDeletedRecordsParam.PER_PAGE, 200);
//Get instance of HeaderMap Class
let headerInstance = new HeaderMap();
/* Possible headers for Get Deleted Records operation */
await headerInstance.add(GetDeletedRecordsHeader.IF_MODIFIED_SINCE, new Date('January 15, 2020 10:35:32'));
//Call getDeletedRecords method that takes paramInstance, headerInstance and moduleAPIName as parameter
let response = await recordOperations.getDeletedRecords(moduleAPIName, paramInstance, headerInstance);
Copiedasync function getListOfDeletedRecords() {
const got = require("got");
let url = 'https://www.zohoapis.com/crm/v2/Leads/deleted'
let headers = {
Authorization : "Zoho-oauthtoken 1000.354df3680XXXXXXXXXXXXX3.aae0efXXXXXXXXXXXXXXXXXX9"
}
let parameters = {
'page': 1,
'per_page': 30,
'type': 'permanent'
}
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);
}
}
getListOfDeletedRecords()
Copied# Get instance of RecordOperations Class
ro = Record::RecordOperations.new
# Get instance of HeaderMap Class
hm = HeaderMap.new
# record_id = 3524033000005495066
# Possible headers for Get Deleted Records operation
hm.add(Record::RecordOperations::GetDeletedRecordsHeader.If_modified_since, DateTime.new(2019, 8, 10, 4, 10, 9, '+03:00'))
# field_names =["Company","Email"]
# field_names.each do |field_name|
# end
# Get instance of HeaderMap Class
hm = HeaderMap.new
# Call getDeletedRecords method that takes param_instance, header_instance and module_api_name as parameter
response = ro.get_deleted_records(module_api_name,pm, hm)
Copiedrequire 'net/http'
require 'json'
class GetListofDeletedRecords
def execute
parameters ={}
parameters["id"]="3524033000006020011";
parameters["per_page"]="2";
parameters["page"]="1";
query_string = parameters.to_a.map { |x| "#{x[0]}=#{x[1]}" }.join('&')
url= "https://www.zohoapis.com/crm/v2/Leads/deleted"
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.dfa7XXXXXXXXXXXXXXXXXX84f9665840.c176aeXXXXXXXXXXXX13f3d37a84d"
headers["If-Modified-Since"]="2019-10-12T17:59:50+05:30"
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
GetListofDeletedRecords.new.execute
Copiedresponse = invokeurl
[
url: "https://www.zohoapis.com/crm/v2.1/Leads/deleted?type=all"
type: GET
connection:"crm_oauth_connection"
];
info response;
Response JSON keys
- deleted_byJSON object
Represents the name and ID of the user who deleted the current record.
- idstring
Represents the unique ID of the deleted record.
- display_namestring
Represents the display name of the deleted record.
- typestring
Represents the type of the deleted record. The value can be: all, recycle, or permanent.
- created_byJSON object
Represents the name and ID of the user who created the current record.
- deleted_timestring
Represents the date and time at which the record was deleted.
Possible Errors
- INVALID_MODULEHTTP 400
The module name given seems to be invalid
Resolution: You have specified an invalid module name or there is no tab permission, or the module could have been removed from the available modules. Specify a valid module API name. - INVALID_MODULEHTTP 400
The given module is not supported in API
Resolution: The modules such as Documents and Projects are not supported in the current API. (This error will not be shown, once these modules are been supported). 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 ZohoCRM.modules.{module_name}.READ. 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 retrieve deleted 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 records
Resolution: The user does not have the permission to retrieve deleted records. Contact your system administrator. - PATTERN_NOT_MATCHEDHTTP 400
Please check whether the input values are correct
Resolution: The value specified for the 'type' parameter is incorrect. Refer to parameters section above and specify a valid parameter value. - NO CONTENTHTTP 204
No Content
Resolution: There are no records available. Please refer the notes section to check the timeframe limits in which you can fetch the deleted records.
Sample Response
Copied{
"data": [
{
"deleted_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000099071",
"display_name": "Patricia",
"type": "recycle",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"deleted_time": "2015-06-19T11:19:38+05:30"
},
{
"deleted_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"id": "410888000000094004",
"display_name": "Patricia",
"type": "recycle",
"created_by": {
"name": "Patricia Boyle",
"id": "410888000000086001"
},
"deleted_time": "2015-04-07T17:43:33+05:30"
},
{
"deleted_by": null,
"id": "410888000000680013",
"display_name": null,
"type": "permanent",
"created_by": null,
"deleted_time": "2016-10-26T11:44:15+05:30"
},
{
"deleted_by": null,
"id": "410888000000680009",
"display_name": null,
"type": "permanent",
"created_by": null,
"deleted_time": "2016-10-26T11:44:15+05:30"
}
],
"info": {
"per_page": 200,
"count": 4,
"page": 1,
"more_records": false
}
}