Add Tags to Multiple Records

Purpose

To add tags to multiple records simultaneously.

Request URL

https://www.zohoapis.com/crm/v2/{module_api_name}/actions/add_tags?ids={entity_id1}&tag_names={tag1},{tag2}

Request Method

POST

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, and customALL - Full data access
WRITE - Edit tag data
CREATE - Create tag data

Parameters

Parameter NameData TypeDescription
tag_namesStringSpecify the names of the tags to be added.
over_writeBooleanSpecify if the existing tags are to be overwritten. Default value is false.
ids
(mandatory)
IntegerSpecify the unique ID of the record

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2/Contacts/actions/add_tags?ids=1234567890,123456789&tag_names=From Email,High Priority&over_write=true"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"

Sample Response

Copied{
    "data": [
       {
            "code": "FAILURE",
            "details": {
                "id": "2445013000000402006"
            },
            "message": "tags not updated successfully",
            "status": "error"
        },
       {
            "code": "SUCCESS",
            "details": {
                "id": "2445013000000141005",
                "tags": [
                    "From Email",
                    "High Priority"
                ]
            },
            "message": "tags updated successfully",
            "status": "success"
        }
    ],
    "wf_scheduler": "false",
    "success_count": "1"
}

Sample Request

CopiedZCRMModule moduleIns = ZCRMModule.getInstance("Leads"); // module api name
List<String> tagNames = new ArrayList<String>();
tagNames.add("From Email");
tagNames.add("High Priority");
List<Long> recordIds = new ArrayList<Long>();
recordIds.add(3719520000000329001L);
recordIds.add(3719520000000326007L);
BulkAPIResponse response = moduleIns.addTagsToRecords(recordIds, tagNames); //recordIds list of record id, tagNames list of tag names
List<ZCRMRecord> records = (List<ZCRMRecord>) response.getData(); //records - list of ZCRMRecord instances
List<EntityResponse> entityResponses = response.getEntityResponses(); // entityResponses - list of EntityResponse instance

Sample Response

Copied{
    "data": [
       {
            "code": "FAILURE",
            "details": {
                "id": "3719520000000329001"
            },
            "message": "tags not updated successfully",
            "status": "error"
        },
       {
            "code": "SUCCESS",
            "details": {
                "id": "3719520000000326007",
                "tags": [
                    "From Email",
                    "High Priority"
                ]
            },
            "message": "tags updated successfully",
            "status": "success"
        }
    ],
    "wf_scheduler": "false",
    "success_count": "1"
}

Sample Request

Copied    def add_tag_multiple_records(self):
        try:
            tag_names = ["4", "5"]
            record_ids = ["3719520000000320001", "3719520000000318001"]
            resp = ZCRMModule.get_instance("Leads").add_tags_to_multiple_records(tag_names, record_ids)
            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)
                for tag in entity_response.data.tag_list:
                    print(tag.name)
        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

Copied{
    "data": [
       {
            "code": "FAILURE",
            "details": {
                "id": "2445013000000402006"
            },
            "message": "tags not updated successfully",
            "status": "error"
        },
       {
            "code": "SUCCESS",
            "details": {
                "id": "2445013000000141005",
                "tags": [
                    "From Email",
                    "High Priority"
                ]
            },
            "message": "tags updated successfully",
            "status": "success"
        }
    ],
    "wf_scheduler": "false",
    "success_count": "1"
}

Sample Request

Copied/** Add Tags to Multiple records */
$zcrmModuleIns = ZCRMModule::getInstance("Leads");
$tagNames = array("Name7","Name8");
$recordids = array("3372164000001494008","3372164000001295433");
$bulkAPIResponse = $zcrmModuleIns->addTagsToRecords($recordids, $tagNames); //$recordids array of record id, $tagName array of tag names
$records = $bulkAPIResponse->getData(); //$records - array of ZCRMRecord instances

Sample Response

Copied{
    "data": [
       {
            "code": "FAILURE",
            "details": {
                "id": "2445013000000402006"
            },
            "message": "tags not updated successfully",
            "status": "error"
        },
       {
            "code": "SUCCESS",
            "details": {
                "id": "2445013000000141005",
                "tags": [
                    "From Email",
                    "High Priority"
                ]
            },
            "message": "tags updated successfully",
            "status": "success"
        }
    ],
    "wf_scheduler": "false",
    "success_count": "1"
}

Sample Request

CopiedZCRMModule moduleIns = ZCRMModule.GetInstance("Leads"); // module api name
List<string> tagNames = new List<string>{ "Name7", "Name8" };
List<long> recordIds = new List<long>{3372164000001494008,3372164000001295433};
BulkAPIResponse<ZCRMRecord> response = moduleIns.AddTagsToRecords(recordIds, tagNames); //recordIds list of record id, tagNames list of tag names
List<ZCRMRecord> records = response.BulkData; //records - list of ZCRMRecord instances
List<EntityResponse> entityResponses = response.BulkEntitiesResponse; // entityResponses - list of EntityResponse instance

Sample Response

Copied{
    "data": [
       {
            "code": "FAILURE",
            "details": {
                "id": "2445013000000402006"
            },
            "message": "tags not updated successfully",
            "status": "error"
        },
       {
            "code": "SUCCESS",
            "details": {
                "id": "2445013000000141005",
                "tags": [
                    "From Email",
                    "High Priority"
                ]
            },
            "message": "tags updated successfully",
            "status": "success"
        }
    ],
    "wf_scheduler": "false",
    "success_count": "1"
}