Delete Records

Purpose

To delete entities or records from a module.

Request Details

Request URL

https://www.zohoapis.com/bigin/v1/{module_api_name}?ids={record_id1,record_id2,..}

Scope

scope=ZohoBigin.modules.ALL
(or)
scope=scope=ZohoBigin.modules.{module_name}.{operation_type}

Possible module names

Accounts(companies in Bigin), contacts, deals, tasks, events, calls, products, 

Possible operation types

ALL - Full access to the record
DELETE - Delete records in the module

Parameters

  • idsstring, mandatory

    Specify the unique ID of the record that you want to delete.
    Possible values: Entity IDs separated by commas.
    For example: 410405000002264040, 410405000002264025.

  • wf_triggerboolean, optional

    Represents if the workflow rules are to be triggered upon record deletion. The default value is true.
    Possible values - true: triggers associated workflows; false: does not trigger associated workflows.

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

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

Sample Request

Copiedcurl "https://www.zohoapis.com/bigin/v1/Contacts?ids=410405000002264040,410405000002264025&wf_trigger=true"
-X DELETE
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copiedimport 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();
		
	}
}
Copieddef 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)
Copied<?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();
CopiedList<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
Copiedresponse = invokeurl
[
	url: "https://www.zohoapis.com/crm/v2/Leads?ids=410405000002264040,410405000002264025&wf_trigger=true"
	type: DELETE
	connection:"crm_oauth_connection"
];
info response;

 

Sample Response

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