Skip to product menu
close
  • Recent Launches
    Press Space or Enter to display list of options
EXPLORE ALL PRODUCTS

Recent Launches

New

Payroll software with automated tax payments and filing.

Try now
New

Robotic process automation software to automate high-volume, rule-based tasks.

Try for free
New

Low-code IoT platform and solutions for connected businesses.

Try now
New

Business formation service to launch and grow your businesses.

Try now
New

Privacy-friendly application analytics solution.

Try for free

Sales

 
CRM

Comprehensive CRM platform for customer-facing teams.

CRM
 
Bigin

Simple CRM for small businesses moving from spreadsheets.

Bigin
 
Forms

Build online forms for every business need.

Forms
 
SalesIQ

Live chat app to engage and convert website visitors.

SalesIQ
 
Bookings

Appointment scheduling app for consultations with customers.

Bookings
 
Sign

Digital signature app for businesses.

Sign
 
RouteIQ

Comprehensive sales map visualization and optimal route planning solution.

RouteIQ
 
Thrive

Complete loyalty and affiliate management platform.

Thrive
 
Voice

Cloud Contact Center Software for businesses.

Voice
 
Suites
CRM Plus

Unified platform to deliver top-notch customer experience.

CRM Plus

Marketing

 
Social

All-in-one social media management software.

Social
 
Campaigns

Create, send, and track targeted email campaigns that drive sales.

Campaigns
 
Forms

Build online forms for every business need.

Forms
 
Survey

Design surveys to reach and interact with your audience.

Survey
 
Sites

Online website builder with extensive customisation options.

Sites
 
PageSense

Website conversion optimization and personalisation platform.

PageSense
 
Backstage

End-to-end event management software.

Backstage
 
Webinar

Webinar platform for webcasting online webinars.

Webinar
 
Marketing Automation

All-in-one marketing automation software.

Marketing Automation
 
LandingPage

Smart landing page builder to increase conversion rates

LandingPage
 
Publish

Manage all your local business listings on a single platform.

Publish
 
SalesIQ

Live chat app to engage and convert website visitors.

SalesIQ
 
Sign

Digital signature app for businesses.

Sign
 
Thrive

Complete loyalty and affiliate management platform.

Thrive
 
Voice

Cloud Contact Center Software for businesses.

Voice
 
NEW
LeadChain

Sync, manage, and convert leads across channels seamlessly.

LeadChain
 
NEW
CommunitySpaces

Online community platform for individuals and businesses to grow their network and brand.

CommunitySpaces
 
Suites
Marketing Plus

Unified marketing platform for marketing teams.

Marketing Plus

Commerce and POS

 
Commerce

eCommerce platform to manage and market your online store.

Commerce

Service

 
Desk

Helpdesk software to deliver great customer support.

Desk
 
Assist

Remote support and unattended remote access software.

Assist
 
Lens

Interactive remote assistance software with augmented reality.

Lens
 
FSM

End-to-end field service management platform for service businesses.

FSM
 
SalesIQ

Live chat app to engage and convert website visitors.

SalesIQ
 
Voice

Cloud Contact Center Software for businesses.

Voice
 
NEW
Solo

The all-in-one toolkit for solopreneurs.

Solo
 
Bookings

Appointment scheduling app for consultations with customers.

Bookings
 
Suites
Service Plus

Unified platform for customer service and support teams.

Service Plus

Finance

 
Books

Powerful accounting platform for growing businesses.

Books
 
FREE
Invoice

100% Free invoicing solution.

Invoice
 
Expense

Effortless expense reporting platform.

Expense
 
Inventory

Powerful stock management and inventory control software.

Inventory
 
Billing

End-to-end billing solution for your business.

Billing
 
Checkout

Collect payments online with custom branded pages.

Checkout
 
NEW
Payroll

Payroll software with automated tax payments and filing.

Payroll
 
NEW
Solo

The all-in-one toolkit for solopreneurs.

Solo
 
Practice

Practice management software for accounting firms.

Practice
 
Sign

Digital signature app for businesses.

Sign
 
Commerce

eCommerce platform to manage and market your online store.

Commerce
 
Suites
Finance Plus

All-in-one suite to manage your operations and finances.

Finance Plus

Email and Collaboration

 
Mail

Secure email service for teams of all sizes.

Mail
 
Meeting

Online meeting software for all your video conferencing & webinar needs.

Meeting
 
Writer

Word processor for focused writing and discussions.

Writer
 
Sheet

Spreadsheet software for collaborative teams.

Sheet
 
Show

Create, edit, and share slides with a sleek presentation app.

Show
 
Notebook

Beautiful home for all your notes.

Notebook
 
Cliq

Stay in touch with teams no matter where you are.

Cliq
 
Connect

Employee experience platform to communicate, engage, and build positive employee relations.

Connect
 
Bookings

Appointment scheduling app for consultations with customers.

Bookings
 
TeamInbox

Shared inboxes for teams.

TeamInbox
 
WorkDrive

Online file management for teams.

WorkDrive
 
Sign

Digital signature app for businesses.

Sign
 
Office Suite

Powerful collaborative work platform for teams.

Office Suite
 
Office Integrator

Built in document editors for web apps.

Office Integrator
 
ZeptoMail

Secure and reliable transactional email sending service.

ZeptoMail
 
Calendar

Online business calendar to manage events and schedule appointments.

Calendar
 
Learn

Knowledge and learning management platform.

Learn
 
Voice

Cloud Contact Center Software for businesses.

Voice
 
ToDo

Collaborative task management for individuals and teams.

ToDo
 
Tables

Work management tool to connect people, processes, and information.

Tables
 
FREE
PDF Editor

Collaborative online PDF editing tool.

PDF Editor
 
Suites
Workplace

Application suite built to improve team productivity and collaboration.

Workplace

Human Resources

 
People

Organize, automate, and simplify your HR processes.

People
 
Recruit

Intuitive recruiting platform built to provide hiring solutions.

Recruit
 
Expense

Effortless expense reporting platform.

Expense
 
Workerly

Manage temporary staffing with an employee scheduling solution.

Workerly
 
NEW
Payroll

Payroll software with automated tax payments and filing.

Payroll
 
Shifts

Employee scheduling and time tracking app.

Shifts
 
Sign

Digital signature app for businesses.

Sign
 
Suites
People Plus

Comprehensive HR platform for seamless employee experiences.

People Plus

Security and IT Management

 
Creator

Build custom apps to simplify business processes.

Creator
 
Directory

Workforce identity and access management solution for cloud businesses.

Directory
 
FREE
OneAuth

Secure multi-factor authenticator (MFA) for all your online accounts.

OneAuth
 
Vault

Online password manager for teams.

Vault
 
Catalyst

Pro-code platform to build and deploy your apps.

Catalyst
 
Toolkit

Complete resource for any admin-related lookup queries.

Toolkit
 
Lens

Interactive remote assistance software with augmented reality.

Lens
 
Assist

Remote support and unattended remote access software.

Assist
 
QEngine

Test automation software to build, manage, execute, and report testcases.

QEngine
 
NEW
RPA

Automate manual, tedious, and repetitive tasks easily.

RPA

BI and Analytics

 
Analytics

Modern self-service BI and analytics platform.

Analytics
 
Embedded BI

Embedded analytics and white label BI solutions, tailored for your needs.

Embedded BI
 
DataPrep

AI-powered data preparation service for your data-driven organization.

DataPrep
 
NEW
IoT

Harnessing IoT analytics for real-time operational intelligence.

IoT

Project Management

 
Projects

Manage, track, and collaborate on projects with teams.

Projects
 
Sprints

Planning and tracking tool for scrum teams.

Sprints
 
BugTracker

Automatic bug tracking software for managing bugs.

BugTracker
 
NEW
Solo

The all-in-one toolkit for solopreneurs.

Solo

Developer Platforms

 
Creator

Build custom apps to simplify business processes.

Creator
 
Flow

Automate business workflows by creating smart integrations.

Flow
 
Catalyst

Pro-code platform to build and deploy your apps.

Catalyst
 
Office Integrator

Built in document editors for web apps.

Office Integrator
 
ZeptoMail

Secure and reliable transactional email sending service.

ZeptoMail
 
QEngine

Test automation software to build, manage, execute, and report testcases.

QEngine
 
Tables

Work management tool to connect people, processes, and information.

Tables
 
NEW
RPA

Automate manual, tedious, and repetitive tasks easily.

RPA
 
NEW
Apptics

Application analytics for all apps.

Apptics
 
Embedded BI

Embedded analytics and white label BI solutions, tailored for your needs.

Embedded BI
 
NEW
IoT

Build, deploy, and scale IoT solutions for connected businesses.

IoT
 
DataPrep

AI-powered data preparation service for your data-driven organization.

DataPrep

IoT

 
NEW
IoT

Low-code IoT platform and solutions for connected businesses.

IoT

Search Result

 
CRM Plus

Unified platform to deliver top-notch customer experience.

Try now
CRM Plus
 
Service Plus

Unified platform for customer service and support teams.

Try now
Service Plus
 
Finance Plus

All-in-one suite to manage your operations and finances.

Try now
Finance Plus
 
People Plus

Comprehensive HR platform for seamless employee experiences.

Try now
People Plus
 
Workplace

Application suite built to improve team productivity and collaboration.

Try now
Workplace
 
Marketing Plus

Unified marketing platform for marketing teams.

Try now
Marketing Plus
 
All-in-one suite

Zoho One

The Operating System for Business

Run your entire business on Zoho with our unified cloud software, designed to help you break down silos between departments and increase organizational efficiency.

TRY ZOHO ONE
Zoho One
Zoho Marketplace

With over 2000 ready-to-use extensions across 40+ categories, connect your favorite business tools with the Zoho products you already use.

EXPLORE MARKETPLACE
Marketplace
Skip to main content

Insert Records API

Purpose

To add new entities to a module.

Request Details

Request URL

https://www.zohoapis.com/crm/v2/{module_api_name}

Supported modules

Leads, Accounts, Contacts, Deals, Campaigns, Tasks, Cases, Events, Calls, Solutions, Products, Vendors, Price Books, Quotes, Sales Orders, Purchase Orders, Invoices, and Custom

Header

Authorization: Zoho-oauthtoken d92d4xxxxxxxxxxxxx15f52

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 notes

Possible operation types

ALL - Full access to the record
WRITE - Edit records in the module
CREATE - Create records in the module

Note

  • To insert a single record, send only one JSON object in the input with the necessary keys and values.
  • The 'INVALID_DATA' error is thrown if the field value length is more than the maximum length defined for that field.
  • If an API is used inside a Function and the field value length exceeds the limit, then that function receives an error response from the API. For ex: If the max length for a "Text field" is defined as 10, then value given for it in API cannot be "12345678901", as it has 11 characters.
  • Duplicates are checked for every insert record API call based on unique fields.
  • A maximum of 100 records can be inserted per API call.
  • You must use only Field API names in the input. You can obtain the field API names from:
    • Fields metadata API (the value for the key “api_name” for every field). (Or)
    • Setup > Developer Hub > APIs and SDKs > API Names > {{Module}}. Choose “Fields” from the “Filter By” drop-down.
  • The trigger input can be workflow, approval, or blueprint, pathfinder, and orchestration(for the Journey Builder feature) . If "trigger" is not mentioned, the workflows, approvals and blueprints related to the API will get executed. Enter the trigger value as [] to not execute the workflows.
  • Records with Subform details can also be inserted to CRM using the Records API. Please look at Subforms API to learn more about adding subform information within a record.
  • The $approved key is used to create records in the approval mode. It is mostly used for leads and contacts procured from web forms. Specify the value as false to create the record in approval mode.
  • Refer to Response Structure for more details about the JSON keys, values, and their descriptions. You can also use the sample response of each module as the input when you insert, update, or upsert a record in that corresponding module.

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2/Leads"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-d "@newlead.json"
-X POST
3.0.08.0
Copied//API Name of the module to create records
String moduleAPIName = "Leads";

//Get instance of RecordOperations Class
RecordOperations recordOperations = new RecordOperations();

//Get instance of BodyWrapper Class that will contain the request body
BodyWrapper bodyWrapper = new BodyWrapper();

//List of Record instances
List < com.zoho.crm.api.record.Record > records = new ArrayList < com.zoho.crm.api.record.Record > ();

//Get instance of Record Class
com.zoho.crm.api.record.Record record1 = new com.zoho.crm.api.record.Record();

/*
 * Call addFieldValue method that takes two arguments
 * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
 * 2 -> Value
 */
//		record1.addFieldValue(Field.Leads.CITY, "City");
//		
record1.addFieldValue(Field.Leads.LAST_NAME, "Last Name");
//		
//		record1.addFieldValue(Field.Leads.FIRST_NAME, "First Name");
//		
//		record1.addFieldValue(Field.Leads.COMPANY, "KKRNP");

/*
 * Call addKeyValue method that takes two arguments
 * 1 -> A string that is the Field's API Name
 * 2 -> Value
 */
//		record1.addKeyValue("Custom_field", "Value");
//		
//		record1.addKeyValue("Custom_field_2", "value");
//		
//		record1.addKeyValue("Date_1", LocalDate.of(2021, 1, 13));
//		
//		record1.addKeyValue("Subject", "AutomatedSDK");

List < FileDetails > fileDetails = new ArrayList < FileDetails > ();

FileDetails fileDetail1 = new FileDetails();

fileDetail1.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32537b7c2400dadca8ff55f620c65357da");

fileDetails.add(fileDetail1);

FileDetails fileDetail2 = new FileDetails();

fileDetail2.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32e0063e7321b5b4ca878a934519e6cdb2");

fileDetails.add(fileDetail2);

FileDetails fileDetail3 = new FileDetails();

fileDetail3.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c323daf4780bfe0058133556f155795981f");

fileDetails.add(fileDetail3);

record1.addKeyValue("File_Upload", fileDetails);

/** Following methods are being used only by Inventory modules */

//		com.zoho.crm.api.record.Record dealName = new com.zoho.crm.api.record.Record();
//		
//		dealName.addFieldValue(Field.Deals.ID, 3477061000004995070L);
//		
//		record1.addFieldValue(Field.Sales_Orders.DEAL_NAME, dealName);
//		
//		com.zoho.crm.api.record.Record contactName = new com.zoho.crm.api.record.Record();
//		
//		contactName.addFieldValue(Field.Contacts.ID, 3477061000004977055L);
//		
//		record1.addFieldValue(Field.Purchase_Orders.CONTACT_NAME, contactName);
//		
//		com.zoho.crm.api.record.Record accountName = new com.zoho.crm.api.record.Record();
//		
//		accountName.addKeyValue("name", "automatedAccount");
//		
//		record1.addFieldValue(Field.Quotes.ACCOUNT_NAME, accountName);
//		
//		i
//		
//		List<InventoryLineItems> inventoryLineItemList = new ArrayList<InventoryLineItems>();
//		
//		InventoryLineItems inventoryLineItem = new InventoryLineItems();
//		
//		LineItemProduct lineItemProduct = new LineItemProduct();
//		
//		lineItemProduct.setId(3477061000005356009L);
//		
//		inventoryLineItem.setProduct(lineItemProduct);
//		
//		inventoryLineItem.setQuantity(1.5);
//		
//		inventoryLineItem.setProductDescription("productDescription");
//		
//		inventoryLineItem.setListPrice(10.0);
//		
//		inventoryLineItem.setDiscount("5.0");

//		inventoryLineItem.setDiscount("5.25%");
//		
//		List<LineTax> productLineTaxes = new ArrayList<LineTax>();
//		
//		LineTax productLineTax = new LineTax();
//		
//		productLineTax.setName("Tax1");
//		
//		productLineTax.setPercentage(20.0);
//		
//		productLineTaxes.add(productLineTax);
//		
//		inventoryLineItem.setLineTax(productLineTaxes);
//		
//		inventoryLineItemList.add(inventoryLineItem);
//
//		record1.addKeyValue("Product_Details", inventoryLineItemList);
//		
//		List<LineTax> lineTaxes = new ArrayList<LineTax>();
//		
//		LineTax lineTax = new LineTax();
//		
//		lineTax.setName("Tax1");
//		
//		lineTax.setPercentage(20.0);
//		
//		lineTaxes.add(lineTax);
//		
//		record1.addKeyValue("$line_tax", lineTaxes);

/** End Inventory **/

/** Following methods are being used only by Activity modules */

//Tasks
//		record1.addFieldValue(Field.Tasks.DESCRIPTION, "Test Task");
//		
//		record1.addKeyValue("Currency",new Choice("INR"));
//		
//		RemindAt remindAt = new RemindAt();
//		
//		remindAt.setAlarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-03T12:30:00+05:30");
//		
//		record1.addFieldValue(Field.Tasks.REMIND_AT, remindAt);
//		
//		com.zoho.crm.api.record.Record whoId = new com.zoho.crm.api.record.Record();
//		
//		whoId.setId(3477061000004977055L);
//		
//		record1.addFieldValue(Field.Tasks.WHO_ID, whoId);
//		
//		record1.addFieldValue(Field.Tasks.STATUS,new Choice("Waiting for input"));
//		
//		record1.addFieldValue(Field.Tasks.DUE_DATE, LocalDate.of(2021, 1, 13));
//		
//		record1.addFieldValue(Field.Tasks.PRIORITY,new Choice("High"));
//		
//		record1.addKeyValue("$se_module", "Accounts");
//		
//		com.zoho.crm.api.record.Record whatId = new com.zoho.crm.api.record.Record();
//		
//		whatId.setId(3477061000000207118L);
//		
//		record1.addFieldValue(Field.Tasks.WHAT_ID, whatId);

/** Recurring Activity can be provided in any activity module*/

//		RecurringActivity recurringActivity = new RecurringActivity();
//		
//		recurringActivity.setRrule("FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03");
//		
//		record1.addFieldValue(Field.Events.RECURRINGACTIVITY, recurringActivity);
//		
//Events
//		record1.addFieldValue(Field.Events.DESCRIPTION, "Test Events");
//		
//		OffsetDateTime startDateTime = OffsetDateTime.of(2020, 01, 02, 10, 00, 00, 00, ZoneOffset.of("+05:30")); 
//		
//		record1.addFieldValue(Field.Events.START_DATETIME, startDateTime);
//		
//		List<Participants> participants = new ArrayList<Participants>();
//		
//		Participants participant1 = new Participants();
//		
//		participant1.setParticipant("abc@gmail.com");
//		
//		participant1.setType("email");
//		
//		participant1.setId(3477061000005902017L);
//		
//		participants.add(participant1);
//		
//		Participants participant2 = new Participants();
//		
//		participant2.addKeyValue("participant", "3477061000005908033");
//		
//		participant2.addKeyValue("type", "lead");
//		
//		participants.add(participant2);
//		
//		record1.addFieldValue(Field.Events.PARTICIPANTS, participants);
//		
//		record1.addKeyValue("$send_notification", true);
//		
//		record1.addFieldValue(Field.Events.EVENT_TITLE, "New Automated Event");
//		
//		OffsetDateTime enddatetime = OffsetDateTime.of(2020, 05, 02, 10, 00, 00, 00, ZoneOffset.of("+05:30")); 
//		
//		record1.addFieldValue(Field.Events.END_DATETIME, enddatetime);
//		
//		OffsetDateTime remindAt = OffsetDateTime.of(2020, 05, 02, 05, 00, 00, 00, ZoneOffset.of("+05:30"));
//		
//		record1.addFieldValue(Field.Events.REMIND_AT, remindAt);
//		
//		record1.addFieldValue(Field.Events.CHECK_IN_STATUS, "PLANNED");
//		
//		record1.addKeyValue("$se_module", "Leads");
//		
//		com.zoho.crm.api.record.Record whatId = new com.zoho.crm.api.record.Record();
//		
//		whatId.setId(3477061000004381002);
//		
//		record1.addFieldValue(Field.Events.WHAT_ID, whatId);

/** End Activity **/

/** Following methods are being used only by Price_Books modules */
//		
//		List<PricingDetails> pricingDetails = new ArrayList<PricingDetails>();
//		
//		PricingDetails pricingDetail1 = new PricingDetails();
//		
//		pricingDetail1.setFromRange(1.0);
//		
//		pricingDetail1.setToRange(5.0);
//		
//		pricingDetail1.setDiscount(2.0);
//		
//		pricingDetails.add(pricingDetail1);
//		
//		PricingDetails pricingDetail2 = new PricingDetails();
//		
//		pricingDetail2.addKeyValue("from_range", 6.0);
//		
//		pricingDetail2.addKeyValue("to_range", 11.0);
//		
//		pricingDetail2.addKeyValue("discount", 3.0);
//		
//		pricingDetails.add(pricingDetail2);
//		
//		record1.addFieldValue(Field.Price_Books.PRICING_DETAILS, pricingDetails);
//		
//		record1.addKeyValue("Email", "raja.k12@zoho.com");
//		
//		record1.addFieldValue(Field.Price_Books.DESCRIPTION, "TEST");
//		
//		record1.addFieldValue(Field.Price_Books.PRICE_BOOK_NAME, "book_name");
//		
//		record1.addFieldValue(Field.Price_Books.PRICING_MODEL, new Choice("Flat"));

List < Tag > tagList = new ArrayList < Tag > ();

Tag tag = new Tag();

tag.setName("Testtask");

tagList.add(tag);

record1.setTag(tagList);

//Add Record instance to the list
records.add(record1);

//Set the list to Records in BodyWrapper instance
bodyWrapper.setData(records);

List < String > trigger = new ArrayList < String > ();

trigger.add("approval");

trigger.add("workflow");

trigger.add("blueprint");

bodyWrapper.setTrigger(trigger);

//bodyWrapper.setLarId("3477061000000087515");

HeaderMap headerInstance = new HeaderMap();

//Call createRecords method that takes moduleAPIName and BodyWrapper instance as parameter.
APIResponse < ActionHandler > response = recordOperations.createRecords(moduleAPIName, bodyWrapper, headerInstance);
Copiedimport javax.net.ssl.SSLContext;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpPost;
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.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.EntityUtils;
import org.json.JSONArray;
import org.json.JSONObject;
public class InsertRecordsAPI 
{
	@SuppressWarnings("deprecation")
	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");
			HttpUriRequest requestObj = new HttpPost(uriBuilder.build());
			HttpEntityEnclosingRequestBase requestBase = (HttpEntityEnclosingRequestBase) requestObj;
			JSONObject requestBody = new JSONObject();
			JSONArray recordArray = new JSONArray();
			JSONObject recordObject = new JSONObject();
			recordObject.put("Company", "Zylker");
			recordObject.put("Last_Name", "Daly");
			recordObject.put("First_Name", "Paul");
			recordObject.put("Email", "p.daly@zylker.com");
			recordObject.put("State", "Texas");
			recordArray.put(recordObject);
			recordObject = new JSONObject();
			recordObject.put("Company", "Villa Margarita");
			recordObject.put("Last_Name", "Dolan");
			recordObject.put("First_Name", "Brian");
			recordObject.put("Email", "brian@villa.com");
			recordObject.put("State", "Texas");
			recordArray.put(recordObject);
			requestBody.put("data", recordArray);
			JSONArray trigger = new JSONArray();
			trigger.put("approval");
			trigger.put("workflow");
			trigger.put("blueprint");
			requestBody.put("trigger", trigger);
			requestBase.setEntity(new StringEntity(requestBody.toString(), HTTP.UTF_8));
			requestObj.addHeader("Authorization", "Zoho-oauthtoken 1000.xxxxxxx.xxxxxxx");
			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();
		}
	}
}
3.0.07.x
Copied//Get instance of RecordOperations Class that takes moduleAPIName as parameter
$recordOperations = new RecordOperations();		
//Get instance of BodyWrapper Class that will contain the request body
$bodyWrapper = new BodyWrapper();
//List of Record instances
$records = array();
$recordClass = 'com\zoho\crm\api\record\Record';
//Get instance of Record Class
$record1 = new $recordClass();
/*
 * Call addFieldValue method that takes two arguments
 * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
 * 2 -> Value
 */
$field = new Field("");
$record1->addFieldValue(Leads::LastName(), "FROm PHP");
$record1->addFieldValue(Accounts::AccountName(), "Account_Name"); 
record1->addKeyValue("Date_1", new \DateTime('2021-03-08'));
$record1->addKeyValue("Date_Time_2", date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
$startdatetime = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$record1->addFieldValue(Events::StartDateTime(), $startdatetime);
$record1->addFieldValue(Events::EventTitle(), "From PHP");
$enddatetime = date_create("2020-07-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));		
$record1->addFieldValue(Events::EndDateTime(), $enddatetime);
$tagList = array();
$tag = new Tag();
$tag->setName("Testtask");
array_push($tagList, $tag);
//Set the list to Tags in Record instance
$record1->setTag($tagList);
$bodyWrapper->setData($records);
$trigger = array("approval", "workflow", "blueprint");
$bodyWrapper->setTrigger($trigger);
$headerInstance = new HeaderMap();
$response = $recordOperations->createRecords($moduleAPIName,$bodyWrapper,$headerInstance);
Copied<?php

class InsertRecords
{
    public function execute(){
        $curl_pointer = curl_init();
        
        $curl_options = array();
        $url = "https://www.zohoapis.com/crm/v2/Leads";
        
        $curl_options[CURLOPT_URL] =$url;
        $curl_options[CURLOPT_RETURNTRANSFER] = true;
        $curl_options[CURLOPT_HEADER] = 1;
        $curl_options[CURLOPT_CUSTOMREQUEST] = "POST";
        $requestBody = array();
        $recordArray = array();
        $recordObject = array();
        $recordObject["Company"]="FieldAPIValue";
        $recordObject["Last_Name"]="347706107420006";
        $recordObject["First_Name"]="34770617420006";
        $recordObject["State"]="FieldAPIValue";

        
        
        $recordArray[] = $recordObject;
        $requestBody["data"] =$recordArray;
        $curl_options[CURLOPT_POSTFIELDS]= json_encode($requestBody);
        $headersArray = array();
        
        $headersArray[] = "Authorization". ":" . "Zoho-oauthtoken " . "1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf";
        
        $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 InsertRecords())->execute();
3.0.08.x
Copied//Get instance of RecordOperations Class
RecordOperations recordOperations = new RecordOperations();
//Get instance of BodyWrapper Class that will contain the request body
BodyWrapper bodyWrapper = new BodyWrapper();
//List of Record instances
List<Com.Zoho.Crm.API.Record.Record> records = new List<Com.Zoho.Crm.API.Record.Record>();
//Get instance of Record Class
Com.Zoho.Crm.API.Record.Record record1 = new Com.Zoho.Crm.API.Record.Record();
/*
* Call addFieldValue method that takes two arguments
* 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
* 2 -> Value
*/
record1.AddFieldValue(Leads.CITY, "City");
record1.AddFieldValue(Leads.LAST_NAME, "Last Name");
record1.AddFieldValue(Leads.FIRST_NAME, "First Name");
record1.AddFieldValue(Leads.COMPANY, "KKRNP");
/*
* Call addKeyValue method that takes two arguments
* 1 -> A string that is the Field's API Name
* 2 -> Value
*/
record1.AddKeyValue("Custom_field", "Value");
record1.AddKeyValue("Custom_field_2", "value");
record1.AddKeyValue("Date_Time_2", new DateTimeOffset(new DateTime(2020, 05, 15, 12, 0, 0, DateTimeKind.Local)));
record1.AddKeyValue("Date_1", new DateTime(2021, 1, 13).Date);
record1.AddKeyValue("Subject", "AutomatedSDK");
List<FileDetails> fileDetails = new List<FileDetails>();
FileDetails fileDetail1 = new FileDetails();
fileDetail1.FileId = "ae9c7cefa418aec1d6a5cc2d9ab35c32537b7c2400dadca8ff55f620c65357da";
fileDetails.Add(fileDetail1);
FileDetails fileDetail2 = new FileDetails();
fileDetail2.FileId = "ae9c7cefa418aec1d6a5cc2d9ab35c32e0063e7321b5b4ca878a934519e6cdb2";
fileDetails.Add(fileDetail2);
FileDetails fileDetail3 = new FileDetails();
fileDetail3.FileId = "ae9c7cefa418aec1d6a5cc2d9ab35c323daf4780bfe0058133556f155795981f";
fileDetails.Add(fileDetail3);
record1.AddKeyValue("File_Upload", fileDetails);
//Products
record1.AddFieldValue(Products.PRODUCT_NAME, "Product_Name");
Com.Zoho.Crm.API.Record.Record vendorName = new Com.Zoho.Crm.API.Record.Record();
vendorName.AddFieldValue(Products.ID, 3477061000004996051);
record1.AddFieldValue(Products.VENDOR_NAME, vendorName);
record1.AddFieldValue(Products.PRODUCT_CATEGORY, new Choice<string>("Software"));
record1.AddFieldValue(Products.PRODUCT_ACTIVE, true);
record1.AddFieldValue(Products.SALES_START_DATE, new DateTime(2020, 10, 12));
record1.AddFieldValue(Products.SALES_END_DATE, new DateTime(2020, 12, 12));
record1.AddFieldValue(Products.TAXABLE, true);
List<Choice<string>> taxes = new List<Choice<string>>();
taxes.Add(new Choice<string>("MyTax22"));
taxes.Add(new Choice<string>("Sales Tax"));
taxes.Add(new Choice<string>("MyTax11"));
taxes.Add(new Choice<string>("Vat"));
taxes.Add(new Choice<string>("MyTax23"));
record1.AddFieldValue(Products.TAX, taxes);
/** Following methods are being used only by Inventory modules */
Com.Zoho.Crm.API.Record.Record dealName = new Com.Zoho.Crm.API.Record.Record();
dealName.AddFieldValue(Deals.ID, 3477061000004995070);
record1.AddFieldValue(Sales_Orders.DEAL_NAME, dealName);
Com.Zoho.Crm.API.Record.Record contactName = new Com.Zoho.Crm.API.Record.Record();
contactName.AddFieldValue(Contacts.ID, 3477061000004977055);
record1.AddFieldValue(Purchase_Orders.CONTACT_NAME, contactName);
Com.Zoho.Crm.API.Record.Record accountName = new Com.Zoho.Crm.API.Record.Record();
accountName.AddKeyValue("name", "automatedAccount");
record1.AddFieldValue(Quotes.ACCOUNT_NAME, accountName);
List<InventoryLineItems> inventoryLineItemList = new List<InventoryLineItems>();
InventoryLineItems inventoryLineItem = new InventoryLineItems();
LineItemProduct lineItemProduct = new LineItemProduct();
lineItemProduct.Id = 3477061000006611017;
inventoryLineItem.Product = lineItemProduct;
inventoryLineItem.Quantity = 1.5;
inventoryLineItem.ProductDescription = "productDescription";
inventoryLineItem.ListPrice = 10.0;
inventoryLineItem.Discount = "5.0";
inventoryLineItem.Discount = "5.25%";
List<LineTax> productLineTaxes = new List<LineTax>();
LineTax productLineTax = new LineTax();
productLineTax.Name = "MyTax22";
productLineTax.Percentage = 20.0;
productLineTaxes.Add(productLineTax);
inventoryLineItem.LineTax = productLineTaxes;
inventoryLineItemList.Add(inventoryLineItem);
record1.AddKeyValue("Product_Details", inventoryLineItemList);
List<LineTax> lineTaxes = new List<LineTax>();
LineTax lineTax = new LineTax();
lineTax.Name = "MyTax22";
lineTax.Percentage = 20.0;
lineTaxes.Add(lineTax);
record1.AddKeyValue("$line_tax", lineTaxes);
/** End Inventory **/
/** Following methods are being used only by Activity modules */
//Tasks
record1.AddFieldValue(Tasks.DESCRIPTION, "Test Task");
record1.AddKeyValue("Currency", new Choice<string>("INR"));
RemindAt remindAt = new RemindAt();
remindAt.Alarm = "FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-09-03T12:30:00+05:30";
record1.AddFieldValue(Tasks.REMIND_AT, remindAt);
Com.Zoho.Crm.API.Record.Record whoId = new Com.Zoho.Crm.API.Record.Record();
whoId.Id = 3477061000004977055;
record1.AddFieldValue(Tasks.WHO_ID, whoId);
record1.AddFieldValue(Tasks.STATUS, new Choice<string>("Waiting for input"));
record1.AddFieldValue(Tasks.DUE_DATE, new DateTime(2021, 1, 13));
record1.AddFieldValue(Tasks.PRIORITY, new Choice<string>("High"));
record1.AddKeyValue("$se_module", "Accounts");
record1.AddFieldValue(Tasks.SUBJECT, "Email1");
Com.Zoho.Crm.API.Record.Record whatId = new Com.Zoho.Crm.API.Record.Record();
whatId.Id = 3477061000000207118;
record1.AddFieldValue(Tasks.WHAT_ID, whatId);
/** Recurring Activity can be provided in any activity module*/
RecurringActivity recurringActivity = new RecurringActivity();
recurringActivity.Rrule = "FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03";
record1.AddFieldValue(Events.RECURRING_ACTIVITY, recurringActivity);
//Events
record1.AddFieldValue(Events.DESCRIPTION, "Test Events");
DateTimeOffset startDateTime = new DateTimeOffset(new DateTime(2020, 05, 15, 12, 0, 0, DateTimeKind.Local));
record1.AddFieldValue(Events.START_DATETIME, startDateTime);
List<Participants> participants = new List<Participants>();
Participants participant1 = new Participants();
participant1.Participant = "raja@gmail.com";
participant1.Type = "email";
participant1.Id = 3477061000005902017;
participants.Add(participant1);
Participants participant2 = new Participants();
participant2.AddKeyValue("participant", "3477061000007078158");
participant2.AddKeyValue("type", "lead");
participants.Add(participant2);
record1.AddFieldValue(Events.PARTICIPANTS, participants);
record1.AddKeyValue("$send_notification", true);
record1.AddFieldValue(Events.EVENT_TITLE, "New Automated Event");
DateTimeOffset enddatetime = new DateTimeOffset(new DateTime(2020, 09, 15, 12, 0, 0, DateTimeKind.Local));
record1.AddFieldValue(Events.END_DATETIME, enddatetime);
DateTimeOffset remindAt1 = new DateTimeOffset(new DateTime(2020, 08, 15, 12, 0, 0, DateTimeKind.Local));
record1.AddFieldValue(Events.REMIND_AT, remindAt1);
record1.AddFieldValue(Events.CHECK_IN_STATUS, "PLANNED");
record1.AddKeyValue("$se_module", "Leads");
Com.Zoho.Crm.API.Record.Record whatId1 = new Com.Zoho.Crm.API.Record.Record();
whatId1.Id = 3477061000004381002;
record1.AddFieldValue(Events.WHAT_ID, whatId1);
/** End Activity **/
/** Following methods are being used only by Price_Books modules */
List<PricingDetails> pricingDetails = new List<PricingDetails>();
PricingDetails pricingDetail1 = new PricingDetails();
pricingDetail1.FromRange = 1.0;
pricingDetail1.ToRange = 5.0;
pricingDetail1.Discount = 2.0;
pricingDetails.Add(pricingDetail1);
PricingDetails pricingDetail2 = new PricingDetails();
pricingDetail2.AddKeyValue("from_range", 6.0);
pricingDetail2.AddKeyValue("to_range", 11.0);
pricingDetail2.AddKeyValue("discount", 3.0);
pricingDetails.Add(pricingDetail2);
record1.AddFieldValue(Price_Books.PRICING_DETAILS, pricingDetails);
record1.AddKeyValue("Email", "raja.k126@zoho.com");
record1.AddFieldValue(Price_Books.DESCRIPTION, "TEST");
record1.AddFieldValue(Price_Books.PRICE_BOOK_NAME, "book_name");
record1.AddFieldValue(Price_Books.PRICING_MODEL, new Choice<string>("Flat1"));
List<Tag> tagList = new List<Tag>();
Tag tag = new Tag();
tag.Name = "Testtask";
tagList.Add(tag);
record1.Tag = tagList;
//Add Record instance to the list
records.Add(record1);
//Set the list to Records in BodyWrapper instance
bodyWrapper.Data = records;
List<string> trigger = new List<string>();
trigger.Add("approval");
trigger.Add("workflow");
trigger.Add("blueprint");
bodyWrapper.Trigger = trigger;
//bodyWrapper.LarId = "3477061000000087515";
HeaderMap headerInstance = new HeaderMap();
//Call CreateRecords method that takes moduleAPIName and BodyWrapper instance as parameter.
APIResponse<ActionHandler> response = recordOperations.CreateRecords(moduleAPIName, bodyWrapper,headerInstance);
Copiedusing System;
using System.IO;
using System.Net;
using System.Text;
using Newtonsoft.Json.Linq;
namespace Com.Zoho.Crm.API.Sample.RestAPI.Records
{
    public class InsertRecordsAPI
    {
        public static void InsertRecords()
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://www.zohoapis.com/crm/v2/Leads");
            request.Method = "POST";
            request.Headers["Authorization"] = "Zoho-oauthtoken 1000.abfeXXXXXXXXXXX2asw.XXXXXXXXXXXXXXXXXXsdc2";
            JObject requestBody = new JObject();
            JArray recordArray = new JArray();
            JObject recordObject = new JObject();
            recordObject.Add("Company", "Zylker");
            recordObject.Add("Last_Name", "Daly");
            recordObject.Add("First_Name", "Paul");
            recordObject.Add("Email", "p.daly@zylker.com");
            recordObject.Add("State", "Texas");
            recordArray.Add(recordObject);
            recordObject = new JObject();
            recordObject.Add("Company", "Villa Margarita");
            recordObject.Add("Last_Name", "Dolan");
            recordObject.Add("First_Name", "Brian");
            recordObject.Add("Email", "brian@villa.com");
            recordObject.Add("State", "Texas");
            recordArray.Add(recordObject);
            requestBody.Add("data", recordArray);
            JArray trigger = new JArray();
            trigger.Add("approval");
            trigger.Add("workflow");
            trigger.Add("blueprint");
            requestBody.Add("trigger", trigger);
            string dataString = requestBody.ToString();
            var data = Encoding.UTF8.GetBytes(dataString);
            int dataLength = data.Length;
            request.ContentLength = dataLength;
            using (var writer = request.GetRequestStream())
            {
                writer.Write(data, 0, dataLength);
            }
            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);
        }
    }
}
3.0.03.x.x
Copied# Get instance of RecordOperations Class
record_operations = RecordOperations()
# Get instance of BodyWrapper Class that will contain the request body
request = BodyWrapper()
# List to hold Record instances
records_list = []
# Get instance of Record Class
record = ZCRMRecord()
# Value to Record's fields can be provided in any of the following ways
"""
Call add_field_value method that takes two arguments
Import the zcrmsdk.src.com.zoho.crm.api.record.field file
1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the
displayed list.
2 -> Value
"""
record.add_field_value(Field.Leads.last_name(), 'Python SDK')
record.add_field_value(Field.Leads.first_name(), 'New')
record.add_field_value(Field.Leads.company(), 'Zoho')
record.add_field_value(Field.Leads.city(), 'City')
record.add_field_value(Field.Leads.salutation(), Choice('Prof.'))
record.add_key_value('Multi_Select_1', [Choice('Test2'), Choice('Test1')])
record.add_key_value('External', 'Test1')
"""
Call add_key_value method that takes two arguments
1 -> A string that is the Field's API Name
2 -> Value
"""
record.add_key_value('Custom_field', 'Value')
record.add_key_value('Custom_field_2', 12)
record.add_key_value('Date', date(2020, 4, 9))
record.add_key_value('Discounted', 23.34)
tax_name = [Choice('Vat'), Choice('Sales Tax')]
record.add_key_value("Tax", tax_name)
record.add_key_value("Product_Name", "AutomatedSDK")
file_details = []
file_detail = FileDetails()
file_detail.set_file_id('479f0f5eebf0fb982f99e3832b35d23e29f67c2868ee4c789f22579895383c8')
file_details.append(file_detail)
record.add_key_value('File_Upload', file_details)
"""
Following methods are being used only by Inventory modules
"""
deal_name = ZCRMRecord()

deal_name.add_field_value(Field.Deals.id(), 3477061000011067033)

record.add_field_value(Field.Sales_Orders.deal_name(), deal_name)

contact_name = ZCRMRecord()

contact_name.add_field_value(Field.Contacts.id(), 3477061000010346007)

record.add_field_value(Field.Sales_Orders.contact_name(), contact_name)

account_name = ZCRMRecord()

account_name.add_field_value(Field.Accounts.id(), 3477061000011067025)

record.add_field_value(Field.Sales_Orders.account_name(), account_name)

record.add_key_value("Discount", 10.5)

inventory_line_item_list = []

inventory_line_item = InventoryLineItems()

line_item_product = LineItemProduct()

# line_item_product.set_id(3477061000011217004)

line_item_product.add_key_value("Products_External", "TestExternalLead121")

inventory_line_item.set_product(line_item_product)

inventory_line_item.set_quantity(3.0)

inventory_line_item.set_product_description('productDescription')

inventory_line_item.set_list_price(10.0)

inventory_line_item.set_discount('5.90')

product_line_taxes = []

product_line_tax = LineTax()

product_line_tax.set_name('Tax1')

product_line_tax.set_percentage(12.0)

product_line_taxes.append(product_line_tax)

inventory_line_item_list.append(inventory_line_item)

record.add_key_value('Product_Details', inventory_line_item_list)

record.add_field_value(Field.Quotes.subject(), "Python- testing")

line_taxes = []

line_tax = LineTax()

line_tax.set_name('Total-Tax')

line_tax.set_percentage(5.0)

line_taxes.append(line_tax)

record.add_key_value("$line_tax", line_taxes)

vendor_name = ZCRMRecord()

vendor_name.set_id(1234)

record.add_field_value(Field.Purchase_Orders.vendor_name(), vendor_name)

"""
End Inventory
"""

"""
Following methods are being used only by Activity modules
"""
record.add_field_value(Field.Tasks.description(), "New Task")

record.add_key_value('Currency', Choice('INR'))

remind_at = RemindAt()

remind_at.set_alarm("FREQ=NONE;ACTION=POPUP;TRIGGER=DATE-TIME:2021-01-18T12:45:00+05:30")

record.add_field_value(Field.Tasks.remind_at(), remind_at)

record.add_field_value(Field.Tasks.subject(), "Python - testing")

record.add_field_value(Field.Calls.reminder(), Choice("5 mins"))

record.add_field_value(Field.Calls.call_type(), Choice("Outbound"))

record.add_field_value(Field.Calls.call_start_time(), datetime(2020,12,1,1,1,1))

who_id = ZCRMRecord()

who_id.set_id(3477061000010346007)

record.add_field_value(Field.Tasks.who_id(), who_id)

record.add_field_value(Field.Tasks.status(), Choice('Waiting for Input'))

record.add_field_value(Field.Tasks.due_date(), date(2020, 10, 10))

record.add_field_value(Field.Tasks.priority(), Choice('High'))

what_id = ZCRMRecord()

what_id.set_id(3477061000011067025)

record.add_field_value(Field.Tasks.what_id(), what_id)

record.add_key_value("$se_module", "Accounts")

# Recurring Activity can be provided in any activity module

recurring_activity = RecurringActivity()

recurring_activity.set_rrule('FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03')

record.add_field_value(Field.Events.recurring_activity(), recurring_activity)

record.add_field_value(Field.Events.description(), "My Event")

start_date_time = datetime.fromisoformat('2020-07-03T12:30:00+05:30')

record.add_field_value(Field.Events.start_datetime(), start_date_time)

participants_list = []

participant = Participants()

participant.set_participant('test@gmail.com')

participant.set_type('email')

participants_list.append(participant)

participant = Participants()

participant.set_participant('3477061000010346007')

participant.set_type('contact')

participants_list.append(participant)

record.add_field_value(Field.Events.participants(), participants_list)

record.add_key_value("$send_notification", True)

record.add_field_value(Field.Events.event_title(), "New Automated Event")

end_date_time = datetime(2020, 9, 3, 10, 10, 10)

record.add_field_value(Field.Events.end_datetime(), end_date_time)

remind_at_value = datetime(2020, 7, 3, 8, 10, 10)

record.add_field_value(Field.Events.remind_at(), remind_at_value)

record.add_field_value(Field.Events.check_in_status(), 'PLANNED')

what_id = ZCRMRecord()

what_id.set_id(3477061000011218001)

record.add_field_value(Field.Events.what_id(), what_id)

record.add_key_value("$se_module", "Leads")

"""
End Activity
"""

"""
Following methods are being used only by Price_Books module
"""
pricing_details_list = []

pricing_detail = PricingDetails()

pricing_detail.set_from_range(1.0)

pricing_detail.set_to_range(5.0)

pricing_detail.set_discount(2.0)

pricing_details_list.append(pricing_detail)

pricing_detail = PricingDetails()

pricing_detail.add_key_value('from_range', 6.0)

pricing_detail.add_key_value('to_range', 11.0)

pricing_detail.add_key_value('discount', 3.0)

pricing_details_list.append(pricing_detail)

record.add_field_value(Field.Price_Books.pricing_details(), pricing_details_list)

record.add_key_value("Email", "abc@zoho.com")

record.add_field_value(Field.Price_Books.description(), "My Price Book")

record.add_field_value(Field.Price_Books.price_book_name(), 'book_name')

record.add_field_value(Field.Price_Books.pricing_model(), Choice('Flat'))

"""
End of Price_Books
"""
# Used when GDPR is enabled
data_consent = Consent()
data_consent.set_consent_remarks("Approved.")\
data_consent.set_consent_through('Email')
data_consent.set_contact_through_email(True)
data_consent.set_contact_through_social(False)
record.add_key_value('Data_Processing_Basis_Details', data_consent)
tags_list = []
tag = Tag()
tag.set_name("My Record")
tags_list.append(tag)
# Add Record instance to the list
records_list.append(record)
# Set the list to data in BodyWrapper instance
request.set_data(records_list)
trigger = ["approval", "workflow", "blueprint"]
# Set the list containing the trigger operations to be run
request.set_trigger(trigger)
lar_id = '3409643000002157065'
# Set the larId
request.set_lar_id(lar_id)
process = ["review_process"]
# Set the array containing the process to be run
request.set_process(process)
header_instance = HeaderMap()
header_instance.add(CreateRecordsHeader.x_external, "Quotes.Product_Details.product.Products_External")
# Call create_records method that takes module_api_name, BodyWrapper instance and header_instance as parameters
response = record_operations.create_records(module_api_name, request, header_instance)
Copieddef insert_records():
    import requests
    import json

    url = 'https://www.zohoapis.com/crm/v2/Leads'

    headers = {
        'Authorization': 'Zoho-oauthtoken 1000.04be928e4a96XXXXXXXXXXXXX68.0b9eXXXXXXXXXXXX60396e268',
    }

    request_body = dict()
    record_list = list()

    record_object_1 = {
        'Company': 'Zylker',
        'Email': 'p.daly@zylker.com',
        'Last_Name': 'Daly',
        'First_Name': 'Paul',
        'Lead_Status': 'Contacted',
    }

    record_object_2 = {
        'Last_Name': 'Dolan',
        'First_Name': 'Brian',
        'Email': 'brian@villa.com',
        'Company': 'Villa Margarita'
    }

    record_list.append(record_object_1)

    record_list.append(record_object_2)

    request_body['data'] = record_list

    trigger = [
        'approval',
        'workflow',
        'blueprint'
    ]

    request_body['trigger'] = trigger

    response = requests.post(url=url, headers=headers, data=json.dumps(request_body).encode('utf-8'))

    if response is not None:
        print("HTTP Status Code : " + str(response.status_code))

        print(response.json())

insert_records()
1.0.010.x
Copied//Get instance of RecordOperations Class
let recordOperations = new RecordOperations();
//Get instance of BodyWrapper Class that will contain the request body
let request = new BodyWrapper();
//Array to hold Record instances
let recordsArray = [];
//Get instance of Record Class
let record = new Record();
/* Value to Record's fields can be provided in any of the following ways */
/*
 * Call addFieldValue method that takes two arguments
 * Import the "zcrmsdk/core/com/zoho/crm/api/record/field" file
 * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
 * 2 -> Value
 */
record.addFieldValue(Field.Leads.LAST_NAME, "Node JS SDK");
record.addFieldValue(Field.Leads.FIRST_NAME, "Node");
record.addFieldValue(Field.Leads.COMPANY, "ZCRM");
record.addFieldValue(Field.Leads.CITY, "City");
/*
 * Call addKeyValue method that takes two arguments
 * 1 -> A string that is the Field's API Name
 * 2 -> Value
 */
record.addKeyValue("Custom_field", "Value");
record.addKeyValue("Custom_field_2", "value");
record.addKeyValue("Date_1", new Date(2020,10,20));
record.addKeyValue("Subject", "AutomatedSDK");
let fileDetails = [];
let fileDetail = new FileDetails();
fileDetail.setFileId("479f0f5eebf0fb982f99e3832b35d23e29f67c2868ee4c789f22579895383c8");
fileDetails.push(fileDetail);
fileDetail = new FileDetails();
fileDetail.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32e0063e7321b5b4ca878a934519e6cdb2");
fileDetails.push(fileDetail);
fileDetail = new FileDetails();
fileDetail.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c323daf4780bfe0058133556f155795981f");
fileDetails.push(fileDetail);
record.addKeyValue("File_Upload_1", fileDetails);
//Used when GDPR is enabled
let dataConsent = new Consent();
dataConsent.setConsentRemarks("Approved.");
dataConsent.setConsentThrough("Email");
dataConsent.setContactThroughEmail(true);
dataConsent.setContactThroughSocial(false);
record.addKeyValue("Data_Processing_Basis_Details", dataConsent);
/** Following methods are being used only by Inventory modules */
let dealName = new Record();
dealName.addFieldValue(Field.Deals.ID, "3409643000002000001");
record.addFieldValue(Field.Sales_Orders.DEAL_NAME, dealName);
let contactName = new Record();
contactName.addFieldValue(Field.Contacts.ID, "3409643000001074007");
contactName.addFieldValue(Field.Sales_Orders.CONTACT_NAME, contactName);
let accountName = new Record();
accountName.addFieldValue(Field.Accounts.ID, "3409643000000692007");
record.addFieldValue(Field.Sales_Orders.ACCOUNT_NAME, accountName);
record.addKeyValue("Discount", 10.5);
let inventoryLineItemArray = [];
let inventoryLineItem = new InventoryLineItems();
let lineItemProduct = new LineItemProduct();
lineItemProduct.setId(3409643000000986033n);
inventoryLineItem.setProduct(lineItemProduct);
inventoryLineItem.setQuantity(3);
inventoryLineItem.setProductDescription("productDescription");
inventoryLineItem.setListPrice(10.0);
inventoryLineItem.setDiscount("5.90");
let productLineTaxes = [];
let productLineTax = new LineTax();
productLineTax.setName("Tax1");
productLineTax.setPercentage(20.0);
productLineTaxes.push(productLineTax);
inventoryLineItem.setLineTax(productLineTaxes);
inventoryLineItemArray.push(inventoryLineItem);
record.addKeyValue("Product_Details", inventoryLineItemArray);
let lineTaxes = [];
let lineTax = new LineTax();
lineTax.setName("Tax1");
lineTax.setPercentage(20.0);
lineTaxes.push(lineTax);
record.addKeyValue("$line_tax", lineTaxes);
/** End Inventory **/
/** Following methods are being used only by Activity modules */
record.addFieldValue(Field.Tasks.DESCRIPTION, "New Task");
record.addKeyValue("Currency", new Choice("INR"));
let remindAt = new RemindAt();
remindAt.setAlarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-03T12:30:00+05:30");
record.addFieldValue(Field.Tasks.REMIND_AT, remindAt);
let whoId = new Record();
whoId.setId(3409643000000836001n);
record.addFieldValue(Field.Tasks.WHO_ID, whoId);
record.addFieldValue(Field.Tasks.STATUS, new Choice("Waiting for Input"));
record.addFieldValue(Field.Tasks.DUE_DATE, new Date(2020,10,10));
record.addFieldValue(Field.Tasks.PRIORITY, new Choice("High"));
let whatId = new Record();
whatId.setId(3409643000000692007n);
record.addFieldValue(Field.Tasks.WHAT_ID, whatId);
record.addKeyValue("$se_module", "Accounts");
/** Recurring Activity can be provided in any activity module*/
let recurringActivity = new RecurringActivity();
recurringActivity.setRrule("FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03");
record.addFieldValue(Field.Events.RECURRING_ACTIVITY, recurringActivity);
record.addFieldValue(Field.Events.DESCRIPTION, "My Event");
let startDateTime = new Date('October 15, 2020 05:35:32');
record.addFieldValue(Field.Events.START_DATETIME, startDateTime);
let participantsArray = [];
let participant = new Participant();
participant.setParticipant("test@gmail.com");
participant.setType("email");
participantsArray.push(participant);
participant = new Participant();
participant.setParticipant("3409643000000836001");
participant.setType("Contact");
participantsArray.push(participant);
record.addFieldValue(Field.Events.PARTICIPANTS, participantsArray);
record.addKeyValue("$send_notification", true);
record.addFieldValue(Field.Events.EVENT_TITLE, "New Automated Event");
let endDateTime = new Date('November 15, 2020 05:35:32');
record.addFieldValue(Field.Events.END_DATETIME, endDateTime);
let remindAt1 = new Date('October 15, 2020 04:35:32');
record.addFieldValue(Field.Events.REMIND_AT, remindAt1);
record.addFieldValue(Field.Events.CHECK_IN_STATUS, "PLANNED");
whatId = new Record();
whatId.setId(3409643000002157023n);
record.addFieldValue(Field.Tasks.WHAT_ID, whatId);
record.addKeyValue("$se_module", "Leads");
/** End Activity **/
/** Following methods are being used only by Price_Books module */
let pricingDetailsArray = [];
let pricingDetail = new PricingDetails();
pricingDetail.setFromRange(1.0);
pricingDetail.setToRange(5.0);
pricingDetail.setDiscount(2.0);
pricingDetailsArray.push(pricingDetail);
pricingDetail = new PricingDetails();
pricingDetail.addKeyValue("from_range", 6.0);
pricingDetail.addKeyValue("to_range", 11.0);
pricingDetail.addKeyValue("discount", 3.0);
pricingDetailsArray.push(pricingDetail);
record.addFieldValue(Field.Price_Books.PRICING_DETAILS, pricingDetailsArray);
record.addKeyValue("Email", "z1@zoho.com");
record.addFieldValue(Field.Price_Books.DESCRIPTION, "TEST");
record.addFieldValue(Field.Price_Books.PRICE_BOOK_NAME, "book_name");
record.addFieldValue(Field.Price_Books.PRICING_MODEL, new Choice("Flat"));
/** End of Price_Books */
let tagsArray = [];
let tag = new Tag();
tag.setName("Testtask");
tagsArray.push(tag);
//Add Record instance to the array
recordsArray.push(record);
//Set the array to data in BodyWrapper instance
request.setData(recordsArray);
let trigger = [];
trigger.push("approval");
trigger.push("workflow");
trigger.push("blueprint");
//Set the array containing the trigger operations to be run
request.setTrigger(trigger);
let larId = "3409643000002157065";
//Set the larId
request.setLarId(larId);
let process = ["review_process"];
//Set the array containing the process to be run
request.setProcess(process);
//Get instance of HeaderMap Class
let headerInstance = new HeaderMap();
//Call createRecords method that takes BodyWrapper instance and moduleAPIName as parameters
let response = await recordOperations.createRecords(moduleAPIName, request,headerInstance);
Copiedasync function insertRecords() {
    const got = require("got");

    let url = 'https://www.zohoapis.com/crm/v2/Leads'

    let headers = {
        Authorization : "Zoho-oauthtoken 1000.354df3680XXXXXXXXXXXXX3.aae0efXXXXXXXXXXXXXXXXXX9"
    }

    let requestBody = {}
    let recordArray = []

    let recordObject1 = {
        'Company': 'Zylker',
        'Email': 'p.daly@zylker.com',
        'Last_Name': 'Daly',
        'First_Name': 'Paul',
        'Lead_Status': 'Contacted',
    }

    let recordObject2 = {
        'Last_Name': 'Dolan',
        'First_Name': 'Brian',
        'Email': 'brian@villa.com',
        'Company': 'Villa Margarita'
    }

    recordArray.push(recordObject1)
    recordArray.push(recordObject2)

    requestBody['data'] = recordArray

    let trigger = ['approval', 'workflow', 'blueprint']
    requestBody['trigger'] = trigger

    let requestDetails = {
        method : "POST",
        headers : headers,
        body : JSON.stringify(requestBody),
        encoding: "utf8",
        throwHttpErrors : false
    };
    
    let response = await got(url, requestDetails)
    
    if(response != null) {
        console.log(response.statusCode);
        console.log(response.body);
    }
}
insertRecords()
2.02.x.x
Copied# List to hold Record instances
records = []
# Get instance of Record Class
record = Record::Record.new
# """
# Call add_field_value method that takes two arguments
# 1 -> Call Field "::" and choose the module from the displayed list and press "." and choose the field name from the displayed list.
# 2 -> Value
# """
if module_api_name.downcase == 'Leads'.downcase
  record.add_field_value(Record::Field::Leads.Last_name, 'asdad')
  record.add_field_value(Record::Field::Leads.City, 'City')
  record.add_field_value(Record::Field::Leads.First_name, 'First Name')
  record.add_field_value(Record::Field::Leads.Company, 'KKRNP')
end

# file = Record::FileDetails.new
# file.file_id = "f46166fa14ce16c6e2622b3ce82830759c6334275dc8a317539bbda39a6ca056"
# files = [file]

# """
# Call add_key_value method that takes two arguments
# 1 -> A string that is the Field's API Name
# 2 -> Value
# """

if module_api_name == 'Contacts'
  file_details = []

  file_detail =  Record::FileDetails.new

  file_detail.file_id = '479f0f5eebf0fb982f99e3832b35d23e29f67c2868ee4c789f22579895383c8'

  file_details.push(file_detail)

  record.add_key_value('File_Upload_1', file_details)
end

# """
# Following methods are being used only by Inventory modules
# """
if %w[Quotes Sales_Orders Purchase_Orders Invoices].include? module_api_name
  line_item_product = Record::LineItemProduct.new
  line_item_product.id = 3_524_033_000_003_659_082
  inventory_line_item = Record::InventoryLineItems.new
  inventory_line_item.product = nil
  inventory_line_item.list_price = 10.0
  inventory_line_item.discount = '5.0'
  inventory_line_item.quantity = 123.2
  line_tax = Record::LineTax.new
  line_tax.name = 'Tax1'
  line_tax.percentage = 20.0
  line_taxes = [line_tax]
  inventory_line_item.line_tax = line_taxes
  inventory_line_items = [inventory_line_item]
  record.add_key_value('Product_Details', inventory_line_items)
  record.add_key_value('Subject', 'asd')
end
# """
# Following methods are being used only by Activity modules
# """
if %w[Tasks Events Calls].include? module_api_name
  remind_at = Record::RemindAt.new
  remind_at.alarm = 'FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-03T12:30:00+05:30'
  who_id =  Record::Record.new
  who_id.id = 3_524_033_000_003_429_023
  record.add_field_value(Record::Field::Tasks.Who_id, who_id)
  participant_record = Record::Participants.new
  participant_record.participant = 'asdasd@gmail.com'
  participant_record.type = 'email'
  record.add_field_value(Record::Field::Events.Event_title, 'New Automated Event')
  endtime = DateTime.new(2019, 8, 10, 4, 11, 9, '+03:00')
  record.add_field_value(Record::Field::Events.End_datetime, endtime)
  starttime = DateTime.new(2019, 8, 10, 4, 10, 9, '+03:00')
  record.add_field_value(Record::Field::Events.Start_datetime, starttime)

  participants = [participant_record]
  record.add_field_value(Record::Field::Events.Start_datetime, starttime)

  recurring_activity = Record::RecurringActivity.new

  recurring_activity.rrule = 'FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03'
  record.add_field_value(Record::Field::Events.Recurring_activity, recurring_activity)
end

if module_api_name == 'Price_Books'
  pricing_detail_record = Record::PricingDetails.new
  pricing_detail_record.from_range = 1.0
  pricing_detail_record.to_range = 1.0
  pricing_detail_record.discount = 1.0
  pricing_detail_records = [pricing_detail_record]
  record.add_key_value('Price_Book_Name', 'assd')
  record.add_field_value(Record::Field::Price_Books.Pricing_details, pricing_detail_records)
  record.add_field_value(Record::Field::Price_Books.Pricing_model, Util::Choice.new('Flat'))
end
# # Get instance of BodyWrapper Class that will contain the request body
records.push(record)
trigger = []
trigger.push('approval')

trigger.push('workflow')

trigger.push('blueprint')
# Get instance of BodyWrapper Class that will contain the request body
body_wrapper = Record::BodyWrapper.new
# Set the list to data in BodyWrapper instance
body_wrapper.data = records
# Set the lar_id in BodyWrapper instance
body_wrapper.lar_id = '213123131'
#set trigger
body_wrapper.trigger = trigger
process = ['review_process']
body_wrapper.process = process
# # Get instance of RecordOperations Class
rr = Record::RecordOperations.new
# Get instance of HeaderMap Class
hm = HeaderMap.new
# Call create_records method that takes BodyWrapper instance and module_api_name as parameters
response = rr.create_records(module_api_name,body_wrapper,hm)
Copiedclass InsertRecords
    def execute
       
        url ="https://www.zohoapis.com/crm/v2/Leads"
        url = URI(url)
        req = Net::HTTP::Post.new(url.request_uri)
        http = Net::HTTP.new(url.host, url.port)
        http.use_ssl = true
        headers={}
        headers["Authorization"]="Zoho-oauthtoken 1000.354df3680XXXXXXXXXXXXX3.aae0efXXXXXXXXXXXXXXXXXX9"
        headers&.each { |key, value| req.add_field(key, value) }
       
        request_body = {};
        record_array = [];
        record_object = {};
        record_object["FieldAPIName"] = "FieldAPIValue";  
        record_object["Company"]="FieldAPIValue";
        record_object["Last_Name"]="3477061000007420006";
        record_object["First_Name"]="3477061000007420006";
        record_object["State"]="FieldAPIValue";    
        record_array = [record_object];
        request_body["data"] =record_array; 
        request_json = request_body.to_json
        req.body = request_json.to_s
        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

InsertRecords.new.execute
1.0.0ES6
Copied//Get instance of RecordOperations Class
let recordOperations = new ZCRM.Record.Operations();
//Get instance of BodyWrapper Class that will contain the request body
let request = new ZCRM.Record.Model.BodyWrapper();
//Array to hold Record instances
let recordsArray = [];
//Get instance of Record Class
let record = new ZCRM.Record.Model.Record();
/* Value to Record's fields can be provided in any of the following ways */
/*
 * Call addFieldValue method that takes two arguments
 * 1 -> Call Field "." and choose the module from the displayed list and press "." and choose the field name from the displayed list.
 * 2 -> Value
 */
record.addFieldValue(ZCRM.Record.Model.Field.Leads.LAST_NAME, "JS SDK");
record.addFieldValue(ZCRM.Record.Model.Field.Leads.FIRST_NAME, "JS");
record.addFieldValue(ZCRM.Record.Model.Field.Leads.COMPANY, "ZCRM");
record.addFieldValue(ZCRM.Record.Model.Field.Leads.CITY, "City");
/*
 * Call addKeyValue method that takes two arguments
 * 1 -> A string that is the Field's API Name
 * 2 -> Value
 */
record.addKeyValue("Custom_field", "Value");
record.addKeyValue("Custom_field_2", "value");
record.addKeyValue("Date_1", new Date(2020,10,20));
record.addKeyValue("Subject", "AutomatedSDK");
let fileDetails = [];
let fileDetail = new ZCRM.Record.Model.FileDetails();
fileDetail.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32e98a84dfc2df549e9a46a78e8a27d753");
fileDetails.push(fileDetail);
fileDetail = new ZCRM.Record.Model.FileDetails();
fileDetail.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32e0063e7321b5b4ca878a934519e6cdb2");
fileDetails.push(fileDetail);
fileDetail = new ZCRM.Record.Model.FileDetails();
fileDetail.setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c323daf4780bfe0058133556f155795981f");
fileDetails.push(fileDetail);
record.addKeyValue("File_Upload", fileDetails);
// Used when GDPR is enabled
let dataConsent = new ZCRM.Record.Model.Consent();
dataConsent.setConsentRemarks("Approved.");
dataConsent.setConsentThrough("Email");
dataConsent.setContactThroughEmail(true);
dataConsent.setContactThroughSocial(false);
record.addKeyValue("Data_Processing_Basis_Details", dataConsent);
/** Following methods are being used only by Inventory modules */
let dealName = new ZCRM.Record.Model.Record();
dealName.addFieldValue(ZCRM.Record.Model.Field.Deals.ID, 3477067850014n);
record.addFieldValue(ZCRM.Record.Model.Field.Sales_Orders.DEAL_NAME, dealName);
let contactName = new ZCRM.Record.Model.Record();
contactName.addFieldValue(ZCRM.Record.Model.Field.Contacts.ID, 34096431074007n);
contactName.addFieldValue(ZCRM.Record.Model.Field.Sales_Orders.CONTACT_NAME, contactName);
let accountName = new ZCRM.Record.Model.Record();
accountName.addFieldValue(ZCRM.Record.Model.Field.Accounts.ID, 34770617969021n);
record.addFieldValue(ZCRM.Record.Model.Field.Sales_Orders.ACCOUNT_NAME, accountName);
record.addKeyValue("Discount", 10.5);
let inventoryLineItemArray = [];
let inventoryLineItem = new ZCRM.Record.Model.InventoryLineItems();
let lineItemProduct = new ZCRM.Record.Model.LineItemProduct();
lineItemProduct.setId(34770617247012n);
inventoryLineItem.setProduct(lineItemProduct);
inventoryLineItem.setQuantity(3);
inventoryLineItem.setProductDescription("productDescription");
inventoryLineItem.setListPrice(10.0);
inventoryLineItem.setDiscount("5.90");
let productLineTaxes = [];
let productLineTax = new ZCRM.Record.Model.LineTax();
productLineTax.setName("MyTax11");
productLineTax.setPercentage(20.0);
productLineTaxes.push(productLineTax);
inventoryLineItem.setLineTax(productLineTaxes);
inventoryLineItemArray.push(inventoryLineItem);
record.addKeyValue("Product_Details", inventoryLineItemArray);
let lineTaxes = [];
let lineTax = new ZCRM.Record.Model.LineTax();
lineTax.setName("MyTax1122");
lineTax.setPercentage(20.0);
lineTaxes.push(lineTax);
record.addKeyValue("$line_tax", lineTaxes);
/** End Inventory **/
/** Following methods are being used only by Activity modules */
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.DESCRIPTION, "New Task");
record.addKeyValue("Currency", new Choice("INR"));
let remindAt = new ZCRM.Record.Model.RemindAt();
remindAt.setAlarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2021-07-03T12:30:00+05:30");
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.REMIND_AT, remindAt);
let whoId = new ZCRM.Record.Model.Record();
whoId.setId(34770617955002n);
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.WHO_ID, whoId);
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.STATUS, new Choice("Waiting for Input"));
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.DUE_DATE, new Date(2020,10,10));
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.PRIORITY, new Choice("High"));
let whatId = new ZCRM.Record.Model.Record();
whatId.setId(34770617969021n);
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.WHAT_ID, whatId);
record.addKeyValue("$se_module", "Accounts");
/** Recurring Activity can be provided in any activity module*/
let recurringActivity = new ZCRM.Record.Model.RecurringActivity();
recurringActivity.setRrule("FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03");
record.addFieldValue(ZCRM.Record.Model.Field.Events.RECURRING_ACTIVITY, recurringActivity);
record.addFieldValue(ZCRM.Record.Model.Field.Events.DESCRIPTION, "My Event");
let startDateTime = new Date('October 15, 2020 05:35:32');
record.addFieldValue(ZCRM.Record.Model.Field.Events.START_DATETIME, startDateTime);
let participantsArray = [];
let participant = new ZCRM.Record.Model.Participants();
participant.setParticipant("test@gmail.com");
participant.setType("email");
participantsArray.push(participant);
participant = new ZCRM.Record.Model.Participants();
participant.setParticipant("34770617634005");
participant.setType("contact");
participantsArray.push(participant);
record.addFieldValue(ZCRM.Record.Model.Field.Events.PARTICIPANTS, participantsArray);
record.addKeyValue("$send_notification", true);
record.addFieldValue(ZCRM.Record.Model.Field.Events.EVENT_TITLE, "New Automated Event");
let endDateTime = new Date('November 15, 2020 05:35:32');
record.addFieldValue(ZCRM.Record.Model.Field.Events.END_DATETIME, endDateTime);
let remindAt1 = new Date('October 15, 2020 04:35:32');
record.addFieldValue(ZCRM.Record.Model.Field.Events.REMIND_AT, remindAt1);
record.addFieldValue(ZCRM.Record.Model.Field.Events.CHECK_IN_STATUS, "PLANNED");
whatId = new ZCRM.Record.Model.Record();
whatId.setId(34770619074373n);
record.addFieldValue(ZCRM.Record.Model.Field.Tasks.WHAT_ID, whatId);
record.addKeyValue("$se_module", "Leads");
/** End Activity **/
/** Following methods are being used only by Price_Books module */
let pricingDetailsArray = [];
let pricingDetail = new ZCRM.Record.Model.PricingDetails();
pricingDetail.setFromRange(1.0);
pricingDetail.setToRange(5.0);
pricingDetail.setDiscount(2.0);
pricingDetailsArray.push(pricingDetail);
pricingDetail = new ZCRM.Record.Model.PricingDetails();
pricingDetail.addKeyValue("from_range", 6.0);
pricingDetail.addKeyValue("to_range", 11.0);
pricingDetail.addKeyValue("discount", 3.0);
pricingDetailsArray.push(pricingDetail);
record.addFieldValue(ZCRM.Record.Model.Field.Price_Books.PRICING_DETAILS, pricingDetailsArray);
record.addKeyValue("Email", "z2@zoho.com");
record.addFieldValue(ZCRM.Record.Model.Field.Price_Books.DESCRIPTION, "TEST");
record.addFieldValue(ZCRM.Record.Model.Field.Price_Books.PRICE_BOOK_NAME, "book_name");
record.addFieldValue(ZCRM.Record.Model.Field.Price_Books.PRICING_MODEL, new Choice("Flat"));
/** End of Price_Books */
let tagsArray = [];
let tag = new ZCRM.Tag.Model.Tag();
tag.setName("Testtask");
tagsArray.push(tag);
record.setTag(tagsArray);
//Add Record instance to the array
recordsArray.push(record);
//Set the array to data in BodyWrapper instance
request.setData(recordsArray);
let trigger = [];
trigger.push("approval");
trigger.push("workflow");
trigger.push("blueprint");
//Set the array containing the trigger operations to be run
request.setTrigger(trigger);
let larId = "34096432157065";
//Set the larId
request.setLarId(larId);
let process = ["review_process"];
//Set the array containing the process to be run
request.setProcess(process);
//Call createRecords method that takes BodyWrapper instance and moduleAPIName as parameters
let response = await recordOperations.createRecords(moduleAPIName, request);
Copiedvar listener = 0;
class InsertRecordsAPI {

	async insertRecords()	{
		var url = "https://www.zohoapis.com/crm/v2/Leads"
        var parameters = new Map()
        var headers = new Map()
        var token = {
            clientId:"1000.NPY9M1V0XXXXXXXXXXXXXXXXXXXF7H",
            redirectUrl:"http://127.0.0.1:5500/redirect.html",
            scope:"ZohoCRM.users.ALL,ZohoCRM.bulk.read,ZohoCRM.modules.ALL,ZohoCRM.settings.ALL,Aaaserver.profile.Read,ZohoCRM.org.ALL,profile.userphoto.READ,ZohoFiles.files.ALL,ZohoCRM.bulk.ALL,ZohoCRM.settings.variable_groups.ALL"
        }
        var accesstoken = await new InsertRecordsAPI().getToken(token)
        headers.set("Authorization", "Zoho-oauthtoken " + accesstoken)
        var requestMethod = "POST"
        var reqBody = {"data":[{"Last_Name":"Lead_changed","Email":"newcrmapi@zoho.com","Company":"abc","Lead_Status":"Contacted"},{"Last_Name":"New Lead","Email":"newlead@zoho.com","Company":"abc","Lead_Status":"Contacted"}],"trigger":["approval","workflow","blueprint"]}
        var params = "";
        parameters.forEach(function(value, key) {
            if (parameters.has(key)) {
                if (params) {
                    params = params + key + '=' + value + '&';
                }
                else {
                    params = key + '=' + value + '&';
                }
            }
        });
        var apiHeaders = {};
        if(headers) {
            headers.forEach(function(value, key) {
                apiHeaders[key] = value;
            });
        }
        if (params.length > 0){
            url = url + '?' + params.substring(0, params.length - 1);
        }
        var requestObj = {
            uri : url,
            method : requestMethod,
            headers : apiHeaders,
            body : JSON.stringify(reqBody),
            encoding: "utf8",
            allowGetBody : true,
			throwHttpErrors : false
        };
        var result = await new InsertRecordsAPI().makeAPICall(requestObj);
        console.log(result.status)
        console.log(result.response)
	}

    async getToken(token) {

        if(listener == 0) {

            window.addEventListener("storage", function(reponse) {
                if(reponse.key === "access_token" && (reponse.oldValue != reponse.newValue || reponse.oldValue == null)){
                    location.reload();
                }
                if(reponse.key === "access_token"){

                    sessionStorage.removeItem("__auth_process");
                }
            }, false);
            listener = 1;
            if(sessionStorage.getItem("__auth_process")) {
                sessionStorage.removeItem("__auth_process");
            }
        }
        ["granted_for_session", "access_token","expires_in","expires_in_sec","location","api_domain","state","__token_init","__auth_process"].forEach(function (k) {
            var isKeyExists = localStorage.hasOwnProperty(k);
            if(isKeyExists) {
                sessionStorage.setItem(k, localStorage[k]);
            }
            localStorage.removeItem(k);
        });
        var valueInStore = sessionStorage.getItem("access_token");
        var tokenInit = sessionStorage.getItem("__token_init");
        if(tokenInit != null && valueInStore != null && Date.now() >= parseInt(tokenInit) + 59 * 60 * 1000){ // check after 59th minute
            valueInStore = null;
            sessionStorage.removeItem("access_token");
        }

        var auth_process = sessionStorage.getItem("__auth_process");
        if ((valueInStore == null && auth_process == null) || (valueInStore == 'undefined' && (auth_process == null || auth_process == "true"))) {
            var accountsUrl = "https://accounts.zoho.com/oauth/v2/auth"
            var clientId;
            var scope;
            var redirectUrl;
            if(token != null) {
                clientId = token.clientId;
                scope = token.scope;
                redirectUrl = token.redirectUrl;
            }

            var fullGrant = sessionStorage.getItem("full_grant");
            var grantedForSession = sessionStorage.getItem("granted_for_session");
            if(sessionStorage.getItem("__token_init") != null && ((fullGrant != null && "true" == full_grant) || (grantedForSession != null && "true" == grantedForSession))) {
                accountsUrl += '/refresh';
            }
            if (clientId && scope) {
                sessionStorage.setItem("__token_init", Date.now());
                sessionStorage.removeItem("access_token");
                sessionStorage.setItem("__auth_process", "true");
                window.open(accountsUrl + "?" + "scope" + "=" + scope + "&"+ "client_id" +"=" + clientId + "&response_type=token&state=zohocrmclient&redirect_uri=" + redirectUrl);
                ["granted_for_session", "access_token","expires_in","expires_in_sec","location","api_domain","state","__token_init","__auth_process"].forEach(function (k) {
                    var isKeyExists = localStorage.hasOwnProperty(k);
                    if(isKeyExists){
                        sessionStorage.setItem(k, localStorage[k]);
                    }
                    localStorage.removeItem(k);
                });
                valueInStore = sessionStorage.getItem("access_token");
            }
        }
        if(token != null && valueInStore != 'undefined'){
            token.accessToken = valueInStore;
        }
        return token.accessToken;
    }

    async makeAPICall(requestDetails) {
        return new Promise(function (resolve, reject) {
            var body, xhr, i;
            body = requestDetails.body || null;
            xhr = new XMLHttpRequest();
            xhr.withCredentials = true;
            xhr.open(requestDetails.method, requestDetails.uri, true);
            for (i in requestDetails.headers) {
                xhr.setRequestHeader(i, requestDetails.headers[i]);
            }
            xhr.send(body);
            xhr.onreadystatechange = function() {
                if(xhr.readyState == 4) {
                    resolve(xhr);
                }
            }
        })
    }
}
CopiedSyntax:
zoho.crm.bulkCreate(<module String>,<dataList List>,<optionalDataMap Map>,<connectionName String>,<userAccess Boolean>);
mandatory : module,dataList

Sample Request:
resp = zoho.crm.bulkCreate("Price_Books", [{"Owner": {"id": "7000000031553"},"Active": true,"Pricing_Details": [{"to_range": 5,"discount": 0,"from_range": 1},{"to_range": 11,"discount": 1,"from_range": 6},{"to_range": 17,"discount": 2,"from_range": 12},{"to_range": 23,"discount": 3,"from_range": 18},{"to_range": 29,"discount": 4,"from_range": 24}],"Pricing_Model": "Differential","Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.","Price_Book_Name": "Price_Book_Name oops1"},{"Owner": {"id": "7000000031553"},"Active": true,"Pricing_Details": [{"to_range": 5,"discount": 0,"from_range": 1},{"to_range": 11,"discount": 1,"from_range": 6},{"to_range": 17,"discount": 2,"from_range": 12},{"to_range": 23,"discount": 3,"from_range": 18},{"to_range": 29,"discount": 4,"from_range": 24}],"Pricing_Model": "Differential","Description": "Design your own layouts that align your business processes precisely. Assign them to profiles appropriately.","Price_Book_Name": "Price_Book_Name oops2"}]);

Show full

Show less

In the request, "@newlead.json" contains the sample input data.

System-defined mandatory fields for each module

While inserting records there are a few system-defined mandatory fields that you need to mention. Inorder to successfully insert records in Zoho CRM, make sure you enter user-defined mandatory fields too.

  • Leads

    "Last_Name" - Single Line

  • Contacts

    "Last_Name" - Single Line

  • Accounts

    "Account_Name" - Single Line

  • Deals

    "Deal_Name"- Single Line
    "Stage" - Picklist

  • Tasks

    "Subject" - Multi Line

  • Calls

    "Subject" - Multi Line
    "Call_Type" - Picklist
    "Call_Start_Time" - Date/Time
    "Call_Duration" - Single Line

  • Events

    "Event_Title"- Single Line
    "Start_DateTime" - Date/Time
    "End_DateTime" - Date/Time

  • Products

    "Product_Name" - Single Line

  • Quotes

    "Subject"- Single Line
    "Quoted_Items" - Line item subform

  • Invoices

    "Subject"- Single Line
    "Invoiced_Items" - Line item subform

  • Campaigns

    "Campaign_Name" - Single Line

  • Vendors

    "Vendor_Name"- Single Line

  • Price Books

    "Price_Book_Name"- Single Line
    "Pricing_Details"- JSON Array with "from_range", "to_range", "discount"

  • Cases

    "Case_Origin" - Picklist
    "Status"- Picklist
    "Subject" - Single Line

  • Solutions

    "Solution_Title"- Single Line

  • Purchase Orders

    "Subject"- Single Line
    "Vendor_Name"- Lookup
    "Purchased_Items" - Line item subform

  • Sales Orders

    "Subject"- Single Line
    "Ordered_Items" - Line item subform

Sample Attributes

The following table gives you specific details about each field type in Zoho CRM and their limitations. The JSON type and the data type of the field-types are extracted from fields metadata API.

Note

The regex patterns listed below use the Unicode representation. Please refer to this link to check if this is supported in your preferred language.

  • Single Linestring

    Accepts up to 255 characters, and alphanumeric and special characters.
    Example:"Last_Name": "Mike O'Leary"

  • Multi Linestring

    Small - accepts up to 2000 characters.
    Large - accepts up to 32000 characters.
    You will not be able to use this field to create custom views, reports or other filters. Accepts alphanumeric and special characters.
    Example:"Multi_Line_1": "This is the first line \n Now for the second Line"

  • Emailstring

    Accepts valid email IDs. The regex in Zoho CRM to validate the email fields is:
    ^[\+\-\p{L}\p{M}\p{N}_]([\p{L}\p{M}\p{N}!#$%&'*+\-\/=?^_`{|}~.]*)@(?=.{4,256}$)(([\p{L}\p{N}\p{M}]+)(([\-_]*[\p{L}\p{M}\p{N}])*)[.])+[\p{L}\p{M}]{2,22}$
    Example:"Email_1": "p.boyle@zylker.com"

  • Phonestring

    Accepts up to 30 characters. This limit may vary based on the value configured in 'Number of characters allowed' in the properties pop-up of the field, in UI.
    The regex pattern in Zoho CRM to validate this field's value is ^([+]?)(?![.-])(?>(?>[.-]?[ ]?[\da-zA-Z]+)+|([ ]?((?![.-])(?>[ .-]?[\da-zA-Z]+)+)(?![.])([ -]?[\da-zA-Z]+)?)+)+(?>(?>([,]+)?[;]?[\da-zA-Z]+)+(([#][\da-zA-Z]+)+)?)?[#;]?$
    Example:"Phone_1": "9900000000"
    "Phone_1":"91(987)654321"

  • Pickliststring

    You can either pass an existing pick list value or add a new one. The pick list value accepts all alphanumeric and special characters.
    Example:"Industry": "automobile"

  • Multi-select picklistJSON array

    You can either pass existing pick list values or add a new one. The pick list value accepts all alphanumeric and special characters..
    Example:"Courses_Opted": [
    "Analytics",
    "Big data"
    ]

  • Datestring

    Accepts date in yyyy-MM-dd format.
    Example: "Date_1": "2017-08-16"

  • Date/Timestring

    Accepts date and time in yyyy-MM-ddTHH:mm:ss±HH:mm format.
    Example: "Date_Time": "2017-08-16T14:32:23+05:30".
    Date_Time is in the ISO8601 format and the time zone is the current user's time zone.

  • Numberinteger

    Accepts numbers up to 9 digits. This limit may vary based on the value configured in 'Maximum digits allowed' in the properties pop-up of the field, in UI. Accepts only numeric values.

  • Currencydouble

    Before decimal point - accepts numbers up to 16 digits. This limit may vary based on the value configured in 'Maximum digits allowed' in the properties pop-up of the field, in UI.
    After decimal point - accepts precision up to 9 digits. This limit may vary based on the value configured in 'Number of decimal paces' in the properties pop-up of the field, in UI. Accepts only numeric values.
    Example:"Annual_Revenue": 250000.90

  • Decimaldouble

    Before decimal point - accepts numbers up to 16 digits. This limit may vary based on the value configured in 'Maximum digits allowed' in the properties pop-up of the field, in UI.
    After decimal point - accepts precision up to 9 digits. This limit may vary based on the value configured in 'Number of decimal places' in the properties pop-up of the field, in UI.
    Accepts only numeric values..
    Example:"Decimal_1": 250000.50

  • Percentdouble

    Accepts numbers up to 5 digits and only numeric values.
    Example:"Percentage": 25

  • Long Integerstring

    Accepts numbers up to 18 digits. This limit may vary based on the value configured in 'Maximum digits allowed' in the properties pop-up of the field, in UI. Accepts only numeric values.
    Example:"EAN_Code":"0012345600012"

  • Checkboxboolean

    Accepts only Boolean values (true,false)
    Example:"Email_Opt_Out": true

  • URLstring

    Accepts valid URLs. The regex pattern in Zoho CRM to validate this field's value is:
    ^(http:\\/\\/www.|https:\\/\\/www.|ftp:\\/\\/www.|www.|http:\\/\\/|https:\\/\\/|ftp:\\/\\/|){1}[^\\x00-\\x19\\x22-\\x27\\x2A-\\x2C\\x2E-\\x2F\\x3A-\\x3F\\x5B-\\x5E\\x60\\x7B\\x7D-\\x7F]+(\\.[^\\x00-\\x19\\x22\\x24-\\x2C\\x2E-\\x2F\\x3C\\x3E\\x40\\x5B-\\x5E\\x60\\x7B\\x7D-\\x7F]+)+([\\/\\?].*)*$
    Example:"URL": "https://www.zylker.com"

  • LookupJSON object

    Accepts unique ID of the record, which you can get through Get Records API.
    Example:"Lookup" : {
    "id" : "425248000000104001"
    }

  • UserJSON object

    This is a default look-up field to users in Zoho CRM.
    Example:"User":
    {
    "name":"Patricia Boyle",
    "id":"4150868000000623001"
    }

  • lar_idstring

    The unique ID of the lead assignment rule you want to trigger while inserting the lead. Use the Get Assignment Rules API to obtain the lar_id. This key must be given parallel to the key "data".

  • LayoutJSON Object

    The ID represents the unique ID of the layout. You can get your layout IDs from the Metadata Layouts API.

    Note

    • You must provide the layout ID field if you want to
      • include the layout specific mandatory fields in the API-level mandatory check
      • include only the fields that are defined in your layout for API- level processing and ignore the rest
  • apply_feature_executionJSON array

    Use this array to apply an existing layout rule when you create a record. Layout rules allow you to show a section, certain fields, set mandatory fields, or show a subform. However, you can only trigger the "Set Mandatory Field" option through the API. Specify the value layout_rules for the key name to apply a layout rule to the record. Note that you must give this key parallel to "data".
    Ensure that the input body includes all the keys required to satisfy the criteria in the layout rule. The system throws an error, otherwise. For example, if the layout rule triggers when the Lead_Source is Employee Referral, and you have mandated the Company field, then the system throws the MANDATORY_NOT_FOUND error if you fail to give the Company key in the input.

  • skip_feature_executionJSON array

    By default, if a Cadence is configured for a module, it will be executed automatically when you create a record via API. This key lets you skip the execution of the Cadences feature during record creation. 
    Specify "cadences" as the value for the "name" key to skip Cadences execution for the record. Ensure you include this key alongside the "data" key in your request. The supported value for the "name" key is "cadences".

Sample Input

Copied{
    "data": [
        {
            "Layout": {
                "id": "5725767000000091055"
            },
            "Lead_Source": "Employee Referral",
            "Company": "ABC",
            "Last_Name": "Daly",
            "First_Name": "Paul",
            "Email": "p.daly@zylker.com",
            "State": "Texas",
            "$wizard_connection_path": [
                "5725767000000091055"
            ],
            "Wizard": {
                "id": "5725767000000526319"
            }
        },
        {
            "Layout": {
                "id": "5725767000000091055"
            },
            "Lead_Source": "Trade Show",
            "Company": "ABC",
            "Last_Name": "Dolan",
            "First_Name": "Brian",
            "Email": "brian@villa.com",
            "State": "Texas"
        }
    ],
    "apply_feature_execution": [
        {
            "name": "layout_rules"
        }
    ],
    "skip_feature_execution": [
        {
            "name": "cadences"
        }
    ],
    "trigger": [
        "approval",
        "workflow",
        "blueprint"
    ]
}

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_DATAHTTP 400

    Invalid Data
    Resolution: One of the input keys is specified in the wrong format. Refer to Sample Attributes section above and specify valid input.

  • INVALID_DATAHTTP 400

    Invalid Data
    Resolution: The record passed isn't a JSON object. Refer to Sample Input section and specify valid input.

  • INVALID_DATAHTTP 400

    Invalid Data
    Resolution: There is a data type mismatch in one of the input keys is specified. Refer to Sample Attributes section above and specify valid input.

  • INVALID_DATAHTTP 400

    Invalid data has been provided for the "name" key in the "skip_feature_execution" property 
    Resolution: Specify the supported value for the "name" key. The supported value is "cadences".

  • MANDATORY_NOT_FOUNDHTTP 400
    • You have not specified one or more mandatory fields.
      Resolution: You must specify all the mandatory fields of the module including the layout-specific ones, if you want to execute the layout rule.
    • The required key is missing in the "skip_feature_execution" property 
      Resolution: Specify the "name" key with the valid value "cadences".
  • INVALID_DATAHTTP 400

    Invalid Data
    Resolution: One of the input keys has the invalid data type. Refer to Sample Attributes section above and specify valid input.

  • 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}.CREATE scope. Create a new client with valid scope. Refer to scope section above.

  • NO_PERMISSIONHTTP 403

    Permission denied to add records
    Resolution: The user does not have permission to add records. Contact your system administrator.

  • INTERNAL_ERRORHTTP 500

    Internal Server Error
    Resolution: Unexpected and unhandled exception in 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 add records
    Resolution: The user does not have the permission to add records. Contact your system administrator.

  • DUPLICATE_DATAHTTP 400

    duplicate data
    Resolution: You have specified a duplicate value for one or more unique fields. Refer to Fields Metadata API to know the unique fields.

  • LIMIT_EXCEEDEDHTTP 400

    Only 50 participants can be added to an event.
    Resolution: You can add only a maximum of 50 participants to an event. Ensure that the number of participants you add does not exceed 50.

Sample Response

Copied{
  "data": [
    {
      "code": "SUCCESS",
      "details": {
        "Modified_Time": "2019-05-02T11:17:33+05:30",
        "Modified_By": {
          "name": "Patricia Boyle",
          "id": "554023000000235011"
        },
        "Created_Time": "2019-05-02T11:17:33+05:30",
        "id": "554023000000527002",
        "Created_By": {
          "name": "Patricia Boyle",
          "id": "554023000000235011"
        }
      },
      "message": "record added",
      "status": "success"
    },
    {
      "code": "SUCCESS",
      "details": {
        "Modified_Time": "2019-05-02T11:17:33+05:30",
        "Modified_By": {
          "name": "Patricia Boyle",
          "id": "554023000000235011"
        },
        "Created_Time": "2019-05-02T11:17:33+05:30",
        "id": "554023000000527003",
        "Created_By": {
          "name": "Patricia Boyle",
          "id": "554023000000235011"
        }
      },
      "message": "record added",
      "status": "success"
    }
  ]
}