Delete Records

Purpose

To delete entities or records from a module.

Request URL

https://www.zohoapis.com/crm/v2/{module_api_name}?ids={EntityID}

module_api_name - The API name of the module

EntityID - The unique ID of the entity or record

Modules supported in Get List of Records are supported here.

Request Method

DELETE

Scope

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

Possible module namesPossible operation types
leads, accounts, contacts, deals, campaigns, tasks, cases, events, calls, solutions, products, vendors, pricebooks, quotes, salesorders, purchaseorders, invoices, custom, and notesALL - Full access to the record
WRITE - Edit records in the module
DELETE - Delete records in the module

Parameters

Parameter NameData TypeDescriptionPossible Values
ids (mandatory)IntegerSpecify the unique ID of the recordEntity IDs separated by commas. For example: 410405000002264040, 410405000002264025
wf_trigger (optional)BooleanRepresents if the workflow rules are to be triggered upon record deletion.
The value true triggers workflows. The value false does not trigger workflows. The default value is true.
true or false.

Note:

  • A maximum of 100 records can be deleted per API call.

  • By default, all the workflows related to this API will get executed.

  • All the subforms related to this API will get deleted.

Sample Request

In the request, the lead records with ids "410405000002264040" and "410405000002264025" will be deleted, and the workflow associated with the Leads module will get triggered.


				curl "https://www.zohoapis.com/crm/v2/Leads?ids=410405000002264040,410405000002264025&wf_trigger=true"
-X DELETE
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"			

Sample Response


				{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "410405000002264040"
            },
            "message": "record deleted",
            "status": "success"
        },
       {
            "code": "SUCCESS",
            "details": {
                "id": "410405000002264025"
            },
            "message": "record deleted",
            "status": "success"
        }
    ]
}			

Sample Request


				import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse.EntityResponse;
import com.zoho.crm.library.common.CommonUtil;
import com.zoho.crm.library.common.CommonUtil.SortOrder;
import com.zoho.crm.library.crud.ZCRMCustomView;
import com.zoho.crm.library.crud.ZCRMEventParticipant;
import com.zoho.crm.library.crud.ZCRMField;
import com.zoho.crm.library.crud.ZCRMInventoryLineItem;
import com.zoho.crm.library.crud.ZCRMLayout;
import com.zoho.crm.library.crud.ZCRMModule;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.crm.library.crud.ZCRMModuleRelation;
import com.zoho.crm.library.crud.ZCRMPickListValue;
import com.zoho.crm.library.crud.ZCRMPriceBookPricing;
import com.zoho.crm.library.crud.ZCRMRecord;
import com.zoho.crm.library.crud.ZCRMSection;
import com.zoho.crm.library.crud.ZCRMTag;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.crud.ZCRMTrashRecord;
import com.zoho.crm.library.exception.ZCRMException;

public class Module{
	public Module() throws Exception{
		ZCRMRestClient.initialize();
	}
	public void deleteRecords() throws Exception{
		ZCRMModule moduleIns=ZCRMRestClient.getInstance().getModuleInstance("Leads");//To get module instance,"Leads" is the module api name
		List<Long> entityIds=Arrays.asList(410405000002264040L,410405000002264025L);//410405000002264040L,410405000002264025L are the entity ids to delete
		BulkAPIResponse responses= moduleIns.deleteRecords(entityIds);//deleting the records
		List<EntityResponse> responseIns =  responses.getEntityResponses();
        System.out.println( " Code:"+responses.getStatusCode());
        for(EntityResponse responseIn: responseIns){
	         System.out.println( " Code:"+responseIn.getCode()); //To get http response code
	         System.out.println( "Status:"+ responseIn.getMessage()); //To get response status
	         System.out.println( "Message:"+ responseIn.getStatus()); //To get response message
	         if(responseIn.getErrorDetails()!=null)
	         System.out.println( " Code:"+responseIn.getErrorDetails().toString());
        }
	}
	public static void main(String[] args) throws Exception {
		Module obj=new Module();
		obj.deleteRecords();
		
	}
}			

Sample Response


				{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "410405000002264040"
            },
            "message": "record deleted",
            "status": "success"
        },
       {
            "code": "SUCCESS",
            "details": {
                "id": "410405000002264025"
            },
            "message": "record deleted",
            "status": "success"
        }
    ]
}			

Sample Request


				def delete_records(self):
        try:
            entityid_list = [3719520000000329001, 3719520000000326007]
            resp = ZCRMModule.get_instance('Leads').delete_records(entityid_list)
            print(resp.status_code)
            entity_responses = resp.bulk_entity_response
            for entity_response in entity_responses:
                print(entity_response.details)
                print(entity_response.status)
                print(entity_response.message)
                print(entity_response.code)
                print(entity_response.data.entity_id)

        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": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "410405000002264040"
            },
            "message": "record deleted",
            "status": "success"
        },
       {
            "code": "SUCCESS",
            "details": {
                "id": "410405000002264025"
            },
            "message": "record deleted",
            "status": "success"
        }
    ]
}			

Sample Request


				<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
require 'vendor/autoload.php';
class Module{
    public function __construct()
    {
        $configuration =array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
        ZCRMRestClient::initialize($configuration);
    }
   
    
    public function deleteRecords()
    {
        $moduleIns = ZCRMRestClient::getInstance()->getModuleInstance("Leads"); // to get the instance of the module
        $recordids = array(
            "410405000002264040",
            "410405000002264025"
        ); // to create an array of record ids
        $responseIn = $moduleIns->deleteRecords($recordids); // to delete the records
        
        foreach ($responseIn->getEntityResponses() as $responseIns) {
            echo "HTTP Status Code:" . $responseIn->getHttpStatusCode(); // To get http response code
            echo "Status:" . $responseIns->getStatus(); // To get response status
            echo "Message:" . $responseIns->getMessage(); // To get response message
            echo "Code:" . $responseIns->getCode(); // To get status code
            echo "Details:" . json_encode($responseIns->getDetails());
        }
    }
}
$obj =new Module();
$obj->deleteRecords();			

Sample Response


				{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "410405000002264040"
            },
            "message": "record deleted",
            "status": "success"
        },
       {
            "code": "SUCCESS",
            "details": {
                "id": "410405000002264025"
            },
            "message": "record deleted",
            "status": "success"
        }
    ]
}			

Sample Request


				List<long> entityIDs = new List<long> { 3372164000001622004, 3372164000001632009, 3372164000001622005 }; // list of record ids
ZCRMModule moduleIns = ZCRMModule.GetInstance("Products"); //module api name
BulkAPIResponse<ZCRMEntity> response = moduleIns.DeleteRecords(entityIDs);
List<EntityResponse> entityResponses = response.BulkEntitiesResponse; //entityResponses - list of EntityResponses instance			

Sample Response


				{
    "data": [
       {
            "code": "SUCCESS",
            "details": {
                "id": "410405000002264040"
            },
            "message": "record deleted",
            "status": "success"
        },
       {
            "code": "SUCCESS",
            "details": {
                "id": "410405000002264025"
            },
            "message": "record deleted",
            "status": "success"
        }
    ]
}