Insert Records

Purpose

To add new entities to a module.

Request Details

Request URL

{api-domain}/crm/{version}/{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 Space > APIs > API Names > {{Module}}. Choose “Fields” from the “Filter By” drop-down.

  • The trigger input can be workflow, approval, or blueprint. 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.

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2.1/Leads"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-d "@newlead.json"
-X POST
4.0.04.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
 */
$record1->addFieldValue(Leads::City(), "City");
$record1->addFieldValue(Leads::LastName(), "FROm PHP");
$record1->addFieldValue(Leads::FirstName(), "First Name");
$record1->addFieldValue(Leads::Company(), "KKRNP");
$record1->addFieldValue(Vendors::VendorName(), "Vendor Name");
$record1->addFieldValue(Deals::Stage(), new Choice("Clo"));
$record1->addFieldValue(Deals::DealName(), "deal_name");
$record1->addFieldValue(Deals::Description(), "deals description");
$record1->addFieldValue(Deals::ClosingDate(), new \DateTime("2021-06-02"));
$record1->addFieldValue(Deals::Amount(), 50.7);
$record1->addFieldValue(Campaigns::CampaignName(), "Campaign_Name");
$record1->addFieldValue(Solutions::SolutionTitle(), "Solution_Title");
$record1->addFieldValue(Accounts::AccountName(), "Account_Name");
$record1->addFieldValue(Cases::CaseOrigin(), new Choice("AutomatedSDK"));
$record1->addFieldValue(Cases::Status(), new Choice("AutomatedSDK"));
/*
 * 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("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())));
$record1->addKeyValue("Subject", "From PHP");
$taxes = array();
$tax = new Tax();
$tax->setValue("Sales Tax - 20.0 %");
array_push($taxes, $tax);
$record1->addKeyValue("Tax", $taxes);
$record1->addKeyValue("Product_Name", "AutomatedSDK");
$imageUpload = new ImageUpload();
$imageUpload->setEncryptedId("ae9c7cefa418aec1d6a5cc2d9ab35c32c868f35aa764283fe160f1ca5d9fc777");
$record1->addKeyValue("Image_Upload", [$imageUpload]);
$fileDetails = array();
$fileDetail1 = new FileDetails();
$fileDetail1->setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32dd6c9909d3d45a7d43f4f5997f98fef9");
array_push($fileDetails, $fileDetail1);
$fileDetail2 = new FileDetails();
$fileDetail2->setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c32cf8c21acc735a439b1e84e92ec8454d7");
array_push($fileDetails, $fileDetail2);
$fileDetail3 = new FileDetails();
$fileDetail3->setFileId("ae9c7cefa418aec1d6a5cc2d9ab35c3207c8e1a4448a63b609f1ba7bd4aee6eb");
array_push($fileDetails, $fileDetail3);
$record1->addKeyValue("File_Upload", $fileDetails);
/** Following methods are being used only by Inventory modules */
$vendorName = new $recordClass();
$vendorName->addFieldValue(Vendors::id(), "34770617247001");
$record1->addFieldValue(Purchase_Orders::VendorName(), $vendorName);
$dealName = new $recordClass();
$dealName->addFieldValue(Deals::id(), "34770614995070");
$record1->addFieldValue(Sales_Orders::DealName(), $dealName);
$contactName = new $recordClass();
$contactName->addFieldValue(Contacts::id(), "34770614977055");
$record1->addFieldValue(Purchase_Orders::ContactName(), $contactName);
$accountName = new $recordClass();
$accountName->addKeyValue("name", "automatedAccount");
$record1->addFieldValue(Quotes::AccountName(), $accountName);
$record1->addKeyValue("Discount", 10.5);
$inventoryLineItemList = array();
$inventoryLineItem = new $recordClass();
$lineItemProduct = new LineItemProduct();
$lineItemProduct->setId("34770615356009");
$inventoryLineItem->addKeyValue("Product_Name", $lineItemProduct);
$inventoryLineItem->addKeyValue("Quantity", 1.5);
$inventoryLineItem->addKeyValue("Description", "productDescription");
$inventoryLineItem->addKeyValue("ListPrice", 10.0);
$inventoryLineItem->addKeyValue("Discount", "5%");
$productLineTaxes = array();
$productLineTax = new LineTax();
$productLineTax->setName("Sales Tax");
$productLineTax->setPercentage(20.0);
array_push($productLineTaxes, $productLineTax);
$inventoryLineItem->addKeyValue("Line_Tax", $productLineTaxes);
array_push($inventoryLineItemList, $inventoryLineItem);
$record1->addKeyValue("Quoted_Items", $inventoryLineItemList);
$record1->addKeyValue("Invoiced_Items", $inventoryLineItemList);
$record1->addKeyValue("Purchase_Items", $inventoryLineItemList);
$record1->addKeyValue("Ordered_Items", $inventoryLineItemList);
$lineTaxes = array();
$lineTax = new LineTax();
$lineTax->setName("Sales Tax");
$lineTax->setPercentage(20.0);
array_push($lineTaxes,$lineTax);
$record1->addKeyValue('$line_tax', $lineTaxes);
/** End Inventory **/
/** Following methods are being used only by Activity modules */
// Tasks,Calls,Events
$record1->addFieldValue(Tasks::Description(), "Test Task");
$record1->addKeyValue("Currency",new Choice("INR"));
$remindAt = new RemindAt();
$remindAt->setAlarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-03T12:30:00.05:30");
$record1->addFieldValue(Tasks::RemindAt(), $remindAt);
$whoId = new $recordClass();
$whoId->setId("34770614977055");
$record1->addFieldValue(Tasks::WhoId(), $whoId);
$record1->addFieldValue(Tasks::Status(),new Choice("Waiting for input"));
$record1->addFieldValue(Tasks::DueDate(), new \DateTime('2021-03-08'));
$record1->addFieldValue(Tasks::Priority(),new Choice("High"));
$record1->addKeyValue('$se_module', "Accounts");
$whatId = new $recordClass();
$whatId->setId("34770610207118");
$record1->addFieldValue(Tasks::WhatId(), $whatId);
/** Recurring Activity can be provided in any activity module*/
$recurringActivity = new RecurringActivity();
$recurringActivity->setRrule("FREQ=DAILY;INTERVAL=10;UNTIL=2020-08-14;DTSTART=2020-07-03");
$record1->addFieldValue(Events::RecurringActivity(), $recurringActivity);
// Events
$record1->addFieldValue(Events::Description(), "Test Events");
$startdatetime = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$record1->addFieldValue(Events::StartDateTime(), $startdatetime);
$participants = array();
$participant1 = new Participants();
$participant1->setParticipant("username@gmail.com");
$participant1->setType("email");
$participant1->setId("34770615902017");
array_push($participants, $participant1);
$participant2 = new Participants();
$participant2->addKeyValue("participant", "34770615844006");
$participant2->addKeyValue("type", "lead");
array_push($participants, $participant2);
$record1->addFieldValue(Events::Participants(), $participants);
$record1->addKeyValue('$send_notification', true);
$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);
$remindAt = date_create("2020-06-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get()));
$record1->addFieldValue(Events::RemindAt(), $remindAt);
$record1->addFieldValue(Events::CheckInStatus(), "PLANNED");
$remindAt = new RemindAt();
$remindAt->setAlarm("FREQ=NONE;ACTION=EMAILANDPOPUP;TRIGGER=DATE-TIME:2020-07-23T12:30:00+05:30");
$record1->addFieldValue(Tasks::RemindAt(), $remindAt);
$record1->addKeyValue('$se_module', "Leads");
$whatId = new $recordClass();
$whatId->setId("34770614381002");
$record1->addFieldValue(Events::WhatId(), $whatId);
$record1->addFieldValue(Tasks::WhatId(), $whatId);
$record1->addFieldValue(Calls::CallType(), new Choice("Outbound"));
$record1->addFieldValue(Calls::CallStartTime(), date_create("2020-07-02T11:03:06+05:30")->setTimezone(new \DateTimeZone(date_default_timezone_get())));
/** End Activity **/
/** Following methods are being used only by Price_Books modules */
$pricingDetails = array();
$pricingDetail1 = new PricingDetails();
$pricingDetail1->setFromRange(1.0);
$pricingDetail1->setToRange(5.0);
$pricingDetail1->setDiscount(2.0);
array_push($pricingDetails, $pricingDetail1);
$pricingDetail2 = new PricingDetails();
$pricingDetail2->addKeyValue("from_range", 6.0);
$pricingDetail2->addKeyValue("to_range", 11.0);
$pricingDetail2->addKeyValue("discount", 3.0);
array_push($pricingDetails, $pricingDetail2);
$record1->addFieldValue(Price_Books::PricingDetails(), $pricingDetails);
$record1->addKeyValue("Email", "user1223@zoho.com");
$record1->addFieldValue(Price_Books::Description(), "TEST");
$record1->addFieldValue(Price_Books::PriceBookName(), "book_name");
$record1->addFieldValue(Price_Books::PricingModel(), new Choice("Flat"));
$tagList = array();
$tag = new Tag();
$tag->setName("Testtask");
array_push($tagList, $tag);
//Set the list to Tags in Record instance
$record1->setTag($tagList);
//Add Record instance to the list
array_push($records, $record1);
//Set the list to Records in BodyWrapper instance
$bodyWrapper->setData($records);
$trigger = array("approval", "workflow", "blueprint");
$bodyWrapper->setTrigger($trigger);
//bodyWrapper.setLarId("34770610087515");
//Call createRecords method that takes BodyWrapper instance as parameter.
$response = $recordOperations->createRecords($moduleAPIName, $bodyWrapper);
Copied<?php

class InsertRecords
{
    public function execute(){
        $curl_pointer = curl_init();
        
        $curl_options = array();
        $url = "https://www.zohoapis.com/crm/v2.1/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"]="3477061000007420006";
        $recordObject["First_Name"]="3477061000007420006";
        $recordObject["State"]="FieldAPIValue";

        
        
        $recordArray[] = $recordObject;
        $requestBody["data"] =$recordArray;
        $curl_options[CURLOPT_POSTFIELDS]= json_encode($requestBody);
        $headersArray = array();
        
        $headersArray[] = "Authorization". ":" . "Zoho-oauthtoken " . "1000.30f3a589XXXXXXXXXXXXXXXXXXX4077.dc5XXXXXXXXXXXXXXXXXXXee9e7c171c";
        
        $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();
2.1.0
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
# Call create_records method that takes BodyWrapper instance and module_api_name as parameters
response = rr.create_records(module_api_name,body_wrapper)
Copiedrequire 'net/http'
require 'json'

class InsertRecords
    def execute
       
        url ="https://www.zohoapis.com/crm/v2.1/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.dfa7XXXXXXXXXXXXXXXXXX84f9665840.c176aeXXXXXXXXXXXX13f3d37a84d"
        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

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
    "Pipeline" - Single Line (mandatory when pipeline is enabled)

  • 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.
    Accepts only numeric characters and '+' (to add extensions). 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]+)+)?[;]?$
    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-\x40\x5B-\x5E\x60\x7B\x7D-\x7F]+(\.[^\x00-\x19\x22\x24-\x2C\x2E-\x2F\x3C\x3E\x40\x5B-\x5E\x60\x7B\x7D-\x7F]+)+(\/[^\x00-\x19\x22\x3C\x3E\x5E\x7B\x7D-\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".

Sample Input

Copied{
    "data": [
        {
            "Company": "Zylker",
            "Last_Name": "Daly",
            "First_Name": "Paul",
            "Email": "p.daly@zylker.com",
            "State": "Texas"
        },
        {
            "Company": "Villa Margarita",
            "Last_Name": "Dolan",
            "First_Name": "Brian",
            "Email": "brian@villa.com",
            "State": "Texas"
        }
    ],
    "lar_id": "3652397000002045001",
    "trigger": [
        "approval",
        "workflow",
        "blueprint"
    ]
}

Sample Response

Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "Modified_Time": "2020-05-21T11:30:57+05:30",
                "Modified_By": {
                    "name": "Shylaja  Sridhar",
                    "id": "3652397000000186017"
                },
                "Created_Time": "2020-05-21T11:30:57+05:30",
                "id": "3652397000002289022",
                "Created_By": {
                    "name": "Shylaja  Sridhar",
                    "id": "3652397000000186017"
                }
            },
            "message": "record added",
            "status": "success"
        }
    ]
}

This section explains the input JSON for pipeline, image upload, file upload, multi-select lookup, and multi-user lookup fields in the Deals module.

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2.1/Deals"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-d "@newquote.json"
-X POST
  • Pipelinestring

    The name of the Pipeline you want the record to be assigned to. Note that this key is mandatory when a pipeline is enabled for the Deals module. Also, it is mandatory to input the Stage for the deal record. Use the Get Pipelines API to get the name of the pipeline.

    In Layouts metadata API, the pick_list_values inside the maps key represent the stages that are available in the pipeline. You can only add a stage that is available in this list to a deal for that pipeline. The system throws an error otherwise.

  • Image_UploadJSON Array

    The API name of the image upload field in a module.

    • Encrypted_Idstring, mandatory

      The File_Id you received in the response when you added the image through the Files API.
      You can add multiple images to the image upload field while inserting a record. Refer to the example on the right pane for the JSON structure.

  • File_uploadJSON Array

    The API name of the file upload field in a module.

    • file_idstring, mandatory

      The file ID you received in the response when you added the file through the Files API.
      You can add multiple files to the file upload field while inserting a record. Refer to the example on the right pane for the JSON structure.

  • Multi-select lookup

    When you create a multi-select lookup field in a parent module to associate multiple records from a child module, a linking module gets created between the parent and the child. In the linking module, this data is arranged as two different lookup fields, one each for the parent and the child. To add values to the multi-select lookup field in the parent module, you must include the child module's lookup field's API name and specify the ID of the record in the child module that you want to associate with the parent.

    In this example, Listings is a multi-select lookup field in the Deals module (parent module) that associates the records in the Listings module (child module). Interested_Listings is the lookup field in the linking module. Refer to the example in the right pane for the JSON structure.

    • ListingsJSON Array
      Interested_ListingsJSON Object

      The API name of the lookup field in the linking module.

    • idString

      The unique ID of the record in the child module that you want to associate with the parent module.

  • Multi-user lookup

    The API name of the multi-user lookup field. Accepts the IDs of the users as individual JSON objects. Refer to the example for the JSON structure.

    • Multi-userJSON Array
      Multi-userJSON Object

      The API name of the multi-user lookup field.

    • idString

      The unique ID of the user you want to associate with the multi-user lookup field.

Sample Input

Copied{
    "data": [
        {
            "Deal_Name": "v2.1 Insert",
            "Stage": "Qualification",
            "Pipeline": "Standard (Standard)",
            "Image_Upload": [
                {
                    "Encrypted_Id": "2cceafa194d037b63f2000181dd81864f157209d250ab4a67473b91de8f0a2fa"
                }
            ],
           "File_upload": [
                {
                    "file_id": "2cceafa194d037b63f2000181dd81864fb2b5f97bc2aa6651ade5db7f630adfc"
                }
            ]
            "Listings": [
                {
                    "Interested_Listings": {
                        "id": "3652397000001978005"
                    }
                },
                {
                    "Interested_Listings": {
                        "id": "3652397000001978016"
                    }
                }
            ],
            "Multi_user": [
                {
                    "Multi_user": {
                        "name": "Patricia Boyle",
                        "id": "3652397000000186017"
                    }
                },
                {
                    "Multi_user": {
                        "name": "J Smith",
                        "id": "3652397000000281001"
                    }
                }
            ]
        }
    ]
}

Sample Response

Copied{
    "data": [
        {
            "code": "SUCCESS",
            "details": {
                "Modified_Time": "2021-01-15T12:51:27+05:30",
                "Modified_By": {
                    "name": "Patricia Boyle",
                    "id": "3652397000000186017"
                },
                "Created_Time": "2021-01-15T12:51:27+05:30",
                "id": "3652397000003852074",
                "Created_By": {
                    "name": "Patricia Boyle",
                    "id": "3652397000000186017"
                }
            },
            "message": "record added",
            "status": "success"
        }
    ]
}

Sample Input for the Inventory Modules

This section explains the various keys in the input body while inserting a record in any of the inventory modules (Quotes, Sales Orders, Purchase Orders, Invoices).
The line item details are given in the form of a subform. The parent key of this subform for Quotes, Sales Orders, Purchase Orders, and Invoices will be Quoted_Items, Ordered_Items, Purchased_Items, and Invoiced_Items, respectively. All the other keys of this subform are common to all the inventory modules.

This subform is mandatory while inserting a record in any of these inventory modules.

In addition to this subform, you must provide the other mandatory keys in that module in the input body.

We have given a sample for inserting a quote.

  • Subjectstring, mandatory

    Accepts up to 255 characters, and alphanumeric and special characters.

  • Quoted_ItemsJSON array, mandatory

    The details of the quote such as the product's name, price book's name, various taxes, discount, quantity etc,.
    Use the Fields Metadata API for the API name and data type of each of these keys.

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2.1/Quotes"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-d "@newquote.json"
-X POST

Sample Input

Copied{
    "data": [
        {
            "Subject": "Test quote v2.1",
            "Quoted_Items": [
                {
                    "Product_Name": {
                        "name": "ZCRM_Product",
                        "id": "3652397000000416001"
                    },
                    "$line_tax": [
                        {
                            "percentage": 1.5,
                            "name": "Common Tax"
                        }
                    ],
                    "Quantity": 100,
                    "Discount": 0,
                    "Price_Book_Name": {
                        "id": "3652397000000491235",
                        "name": "Price Book 1"
                    },
                    "Description": "description",
                    "Line_Tax": [
                        {
                            "percentage": 10,
                            "name": "Sales Tax"
                        },
                        {
                            "percentage": 1,
                            "name": "Vat"
                        }
                    ]
                }
            ]
        }
    ]
}

Sample Input to Insert a Call

You can insert a record for a scheduled, completed, and missed call.

  • Subjectstring, mandatory

    Accepts up to 255 characters, and alphanumeric and special characters.

  • Call_Typestring, mandatory

    The type of call. The possible values are Inbound, Outbound, or Missed.

  • Who_IdJSON object, mandatory for scheduled calls

    The name and ID of the contact you want to associate the call to.

  • What_IdJSON object, mandatory for scheduled calls

    The name and ID of the record (other than a Lead and Contact) you want to associate the call to.

  • Call_Start_TimeDateTime in ISO8601 format, mandatory for scheduled and completed calls

    The date and time at which the call started.

  • Call_Durationstring, mandatory for completed calls

    The time duration the call lasted for.

  • Call_Purposestring, optional

    The purpose of the call. Use the Fields Metadata API for the possible values of this field.

  • Outbound_Call_Statusstring, optional

    The status of the outbound call. The possible values are Scheduled, or Completed.

Sample Input to Insert a Call

Copied{
    "data": [
        {
            "Who_Id": {
                "name": "Patricia Boyle",
                "id": "3652397000000649013"
            },
            "Description": "Discussion ZCRM",
            "Call_Start_Time": "2021-02-23T13:30:00+05:30",
            "Subject": "Discussion",
            "Call_Type": "Outbound",
            "Outbound_Call_Status": "Completed",
            "Call_Duration": "10:00",
            "Call_Purpose": "Administrative"
        }
    ]
}

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

    Given Probability is not valid
    Resolution: The probability of winning a deal canot be less than 0% or greater than 100%. Specify a valid probability.

  • 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 202

    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.

  • MANDATORY_NOT_FOUNDHTTP 400

    Required field not found
    Resolution: One of the input keys has the invalid data type. Refer to Sample Attributes section above and specify valid input.

  • INVALID_DATAHTTP 400

    Invalid Data
    Resolution: You have not specified one or more mandatory fields. Refer to System-defined mandatory fields for each module section above.

  • 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 the 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 202

    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 202

    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": "2021-02-13T18:30:28+05:30",
                "Modified_By": {
                    "name": "Patricia Boyle",
                    "id": "3652397000000186017"
                },
                "Created_Time": "2021-02-11T12:29:31+05:30",
                "id": "3652397000003852172",
                "Created_By": {
                    "name": "Patricia Boyle",
                    "id": "3652397000000186017"
                }
            },
            "message": "record added",
            "status": "success"
        }
    ]
}