Get List of Deleted Records
Purpose
To get the list of deleted records.
Request URL
https://www.zohoapis.com/crm/v2/{module_api_name}/deleted
module_api_name - The API name of the module
Modules supported in Get List of Records are supported here.
Request Method
GET
Scope
scope=ZohoCRM.modules.all
(or)
scope=ZohoCRM.modules.{module_name}.{operation_type}
| Possible module names | Possible operation types |
|---|---|
| leads, accounts, contacts, deals, campaigns, tasks, cases, events, calls, solutions, products, vendors, pricebooks, quotes, salesorders, purchaseorders, invoices, activities, custom, and notes | ALL - Full access to the record READ - Get records in the module |
Request Headers
| Header Name | Data Type | Description | Example |
|---|---|---|---|
| If-Modified-Since(optional) | DateTime(ISO 8601 format) | To get the list of recently deleted records | 2019-07-25T15:26:49+05:30 |
Parameters
| Parameter Name | Data Type | Description |
|---|---|---|
| module (mandatory) | String | Specify the module API name |
| type | String | All To get the list of all deleted records Recycle To get the list of deleted records from recycle bin Permanent To get the list of permanently deleted records |
| page (optional) | Integer | To get the list of records from the respective pages. Default value for page is 1. |
| per_page (optional) | Integer | To get the list of records available per page. Default value for per page is 200. |
Note:
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, 3 and 4) and per_page (100) parameter, the user can fetch all 400 records using 4 API calls.
Possible Errors
| HTTP Status | Error Code | Message | Reason |
|---|---|---|---|
| 400 | INVALID_DATA | Invalid data | Invalid type param value given. |
Sample Request
curl "https://www.zohoapis.com/crm/v2/Leads/deleted?type=All"
-X GET
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf" Sample Response
{
"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
}
} Sample Request
ZCRMModule module = ZCRMModule.getInstance("Leads"); //module api name
BulkAPIResponse response = module.getDeletedRecords();
List<ZCRMRecord> deletedRecords = (List<ZCRMRecord>) response.getData();
List<ZCRMTrashRecord> recycleBinRecords = (List<ZCRMTrashRecord>) module.getRecycleBinRecords().getData();
List<ZCRMTrashRecord> permenantDeleteRecords = (List<ZCRMTrashRecord>) module.getPermanentlyDeletedRecords().getData(); Sample Response
{
"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
}
} Sample Response
To get all the deleted Records
$response=ZCRMModule::getInstance($moduleAPIName)->getAllDeletedRecords(); // $moduleAPIName - APIName of the module.
To get All the recyclebin records
$response=ZCRMModule::getInstance($moduleAPIName)->getRecycleBinRecords();
To get all the records which got deleted permanently
$response=ZCRMModule::getInstance($moduleAPIName)->getPermanentlyDeletedRecords();
$records=$response->getData();
try{
foreach ($records as $record){
echo $record->getEntityId();
echo $record->getDisplayName();
echo $record->getType();
$createdBy=$record->getCreatedBy();
$deletedBy=$record->getDeletedBy();
if($createdBy!=null)
{
echo $createdBy->getId();
}
if($deletedBy!=null)
{
echo $deletedBy->getId();
}
echo $record->getDeletedTime();
}
}
catch (ZCRMException $ex)
{
echo $ex->getMessage();
echo $ex->getExceptionCode();
echo $ex->getFile();
} Sample Response
{
"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
}
} Sample Request
def get_deleted_records(self, delete_type):
try:
module_ins = ZCRMModule.get_instance('Leads')
if delete_type == 'permanent':
resp = module_ins.get_permanently_deleted_records()
elif delete_type == 'recycle':
resp = module_ins.get_recyclebin_records()
else:
resp = module_ins.get_all_deleted_records()
print(resp.status_code)
trash_record_ins_arr = resp.data
resp_info = resp.info
print(resp_info.count)
print(resp_info.page)
print(resp_info.per_page)
print(resp_info.is_more_records)
for record_ins in trash_record_ins_arr:
print(record_ins.id)
print(record_ins.type)
print(record_ins.display_name)
if record_ins.created_by is not None:
print(record_ins.created_by.id)
if record_ins.deleted_by is not None:
print(record_ins.deleted_by.id)
print(record_ins.deleted_time)
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) Sample Response
{
"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
}
} Sample Request
ZCRMModule moduleIns = ZCRMModule.GetInstance("Leads"); //module api name
BulkAPIResponse<ZCRMTrashRecord> response = moduleIns.GetAllDeletedRecords();
List<ZCRMTrashRecord> deletedRecords = response.BulkData; // deletedRecords - list of ZCRMTrashRecord instance both recyclebin records and permanently deleted records
List<ZCRMTrashRecord> recycleBinRecords = moduleIns.GetRecycleBinRecords().BulkData; // To get All the recyclebin records
List<ZCRMTrashRecord> permenantDeleteRecords = moduleIns.GetPermanentlyDeletedRecords().BulkData; //To get all the records which got deleted permanently Sample Response
{
"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
}
}