Kaizen #56 - Upsert Records #API

Kaizen #56 - Upsert Records #API

Hello everyone!
Welcome back to another week of Kaizen.
In this post, we will discuss the Upsert Records API.

1. The purpose of upsert records API
Using the upsert records API, you can either insert or update records in a module. When you fire an upsert call, the system checks for duplicate records based on the duplicate check field's values. If the record is already present, it gets updated. If not, the record is inserted.


2. The duplicate check fields
There are two types of duplicate check fields:

2a. The system-defined duplicate check fields
These are the default unique fields. When you upsert a record, the system checks for duplicate entries in these fields.

Module-wise system-defined duplicate check fields
Module
System-defined duplicate check field
Leads
Email
Accounts
Account_Name
Contacts
Email
Deals
Deal_Name
Campaigns
Campaign_Name
Cases
Subject
Solutions
Solution_Title
Products
Product_Name
Vendors
Vendor_Name
PriceBooks
Price_Book_Name
Quotes
Subject
SalesOrders
Subject
PurchaseOrders
Subject
Invoices
Subject

2b. The user-defined unique fields
The fields for which "Do not allow duplicate values" is enabled. Click here to know more. Note that you can only set fields with the following field-types as unique— Single Line, Email, Phone, Number, Long Integer, and URL.

3. The duplicate_check_field array
You can set the order in which the system checks for duplicate records by specifying the duplicate_check_field array in the input. You can add only the system-defined duplicate check fields and user-defined unique fields to the duplicate_check_field array. For instance, in the example below, "Email" is the system-defined duplicate check field, and "Phone" and "Fax" are the user-defined unique fields for the Leads module.

"duplicate_check_fields": [
    "Email",
    "Phone",
    "Fax"
  ]

If you do not specify the duplicate_check_field array, the system checks for duplicate records in the following order:
  1. System-defined duplicate check fields
  2. User-defined unique fields
4. How does duplicate check work?
Consider a case where the user has configured two unique fields unique1 and unique2 for a module (user-defined unique fields), and Email is a system-defined unique field.
The following table explains how the duplicate check happens for different user inputs to the duplicate_check_fields array.
User Input to the "duplicate_check_fields" Array
Duplicate Check Order
unique1
unique1, unique2
unique2
unique2, unique1
unique1, unique2
unique1, unique2
Email
Email, unique1, unique2
No input
System-defined duplicate check field for that module followed by unique fields. That is, Email, unique1, unique2

If you do not specify the system-defined duplicate check fields in the array, the system will ignore them and check only for user-defined unique fields.

5. Upserting a record via API

OAuth Scope
The scope to access the Deals module via API is:
ZohoCRM.modules.{module_api_name}.{operation_type}

The operation type can be ALL, WRITE, or CREATE.
Click here to know more about the scopes.

Request URL: {{api-domain}}/crm/v2/Leads/upsert
Request Method: POST

Sample Input
{
    "data": [
        {
            "Last_Name": "Frey (Sample)",
            "Email": "frey@sample.com",
            "Company": "abc",
            "Lead_Status": "Contacted"
        },
        {
            "Last_Name": "New Lead",
            "First_Name": "CRM Lead",
            "Email": "newlead@zoho.com",
            "Lead_Status": "Attempted to Contact",
            "Mobile": "7685635434"
        }
    ],
    "duplicate_check_fields": [
        "Email",
        "Mobile"
    ]
}

Sample Response


Note:
You can insert or update a maximum of 100 records per API call.

We hope you found this post useful.
Write to us at support@zohocrm.com if you have any questions, or let us know in the comment section.

Cheers!

    Access your files securely from anywhere







                            Zoho Developer Community





                                                  Use cases

                                                  Make the most of Zoho Desk with the use cases.

                                                   
                                                    

                                                  eBooks

                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                   
                                                    

                                                  Videos

                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                   
                                                    

                                                  Webinar

                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                   
                                                    
                                                  • Desk Community Learning Series


                                                  • Meetups


                                                  • Ask the Experts


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner




                                                            • Sticky Posts

                                                            • Kaizen #197: Frequently Asked Questions on GraphQL APIs

                                                              🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
                                                            • Kaizen #198: Using Client Script for Custom Validation in Blueprint

                                                              Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
                                                            • Celebrating 200 posts of Kaizen! Share your ideas for the milestone post

                                                              Hello Developers, We launched the Kaizen series in 2019 to share helpful content to support your Zoho CRM development journey. Staying true to its spirit—Kaizen Series: Continuous Improvement for Developer Experience—we've shared everything from FAQs
                                                            • Kaizen #193: Creating different fields in Zoho CRM through API

                                                              🎊 Nearing 200th Kaizen Post – We want to hear from you! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
                                                            • Client Script | Update - Introducing Commands in Client Script!

                                                              Have you ever wished you could trigger Client Script from contexts other than just the supported pages and events? Have you ever wanted to leverage the advantage of Client Script at your finger tip? Discover the power of Client Script - Commands! Commands


                                                            Manage your brands on social media



                                                                  Zoho TeamInbox Resources



                                                                      Zoho CRM Plus Resources

                                                                        Zoho Books Resources


                                                                          Zoho Subscriptions Resources

                                                                            Zoho Projects Resources


                                                                              Zoho Sprints Resources


                                                                                Qntrl Resources


                                                                                  Zoho Creator Resources



                                                                                      Zoho CRM Resources

                                                                                      • CRM Community Learning Series

                                                                                        CRM Community Learning Series


                                                                                      • Kaizen

                                                                                        Kaizen

                                                                                      • Functions

                                                                                        Functions

                                                                                      • Meetups

                                                                                        Meetups

                                                                                      • Kbase

                                                                                        Kbase

                                                                                      • Resources

                                                                                        Resources

                                                                                      • Digest

                                                                                        Digest

                                                                                      • CRM Marketplace

                                                                                        CRM Marketplace

                                                                                      • MVP Corner

                                                                                        MVP Corner







                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now


                                                                                            Zoho Show Resources


                                                                                              Zoho Writer Writer

                                                                                              Get Started. Write Away!

                                                                                              Writer is a powerful online word processor, designed for collaborative work.

                                                                                                Zoho CRM コンテンツ








                                                                                                  Nederlandse Hulpbronnen


                                                                                                      ご検討中の方




                                                                                                            • Recent Topics

                                                                                                            • Fixed asset management

                                                                                                              I want to know if there is any individual module for fixed assets management
                                                                                                            • One time sale item in billing automatically detects as service

                                                                                                              if i have some items which i don't want to add in my "item" list because its sold only for one time. but when i type item name in invoice, it (system) automatically takes it as a service and despite of HSN , it shows SAC code to be entered. if its selectable i.e. either item or service , it would be very helpful and a must have feature.
                                                                                                            • Project template after project creation

                                                                                                              How can I apply a project template AFTER the project has been created?
                                                                                                            • convert the project to templet

                                                                                                              i have some deployment ME product for different customer , i need to create a fixed template for use it rather then keeping creating this template every time
                                                                                                            • Is there a notification API when a new note is addeding

                                                                                                              Trying to push to Cliq, or email notification when there's a new note added in module. How to implement this?
                                                                                                            • Seriously - Create multiple contacts for leads, (With Company as lead) Zoho CRM

                                                                                                              In Zoho CRM, considering a comapny as a lead, you need us to allow addition of more than one contact. Currently the Lead Section is missing "Add contact" feature which is available in "Accounts". When you know that a particular lead can have multiple
                                                                                                            • Related Module in Sharing Rules

                                                                                                              Zoho CRM team recently added the feature to filter records by Related Records It will be really beneficial if we can have this feature for Sharing Rules as well
                                                                                                            • Assignment Thresholds Resetting After Lead Conversion

                                                                                                              Hello everyone, We're facing an issue with Zoho CRM's lead assignment thresholds that makes them unsuitable for our workflow. I'm hoping to find a potential workaround or solution from the community. Here’s our current process: A new lead is created automatically
                                                                                                            • Vendor Signatures Needed for Purchase Orders

                                                                                                              Hello everyone, We have a unique requirement that necessitates that Vendors & Suppliers formally acknowledge our Purchase Orders upon receipt. I was hoping that there would be an option to do so in Zoho Books, but that does not appear to be the case.
                                                                                                            • Export Invoices to XML file

                                                                                                              Namaste! ZOHO suite of Apps is awesome and we as Partner, would like to use and implement the app´s from the Financial suite like ZOHO Invoice, but, in Portugal, we can only use certified Invoice Software and for this reason, we need to develop/customize on top of ZOHO Invoice to create an XML file with specific information and after this, go to the government and certified the software. As soon as we have for example, ZOHO CRM integrated with ZOHO Invoice up and running, our business opportunities
                                                                                                            • Zoho CRM Analytics - Allow To Reorder Dashboards

                                                                                                              I would like to suggest that you add the ability to reorder dashboards in the Analytics Module. I can see that this has been requested some time ago, the latest 9 years ago. I am not sure if this is a big or small endeavor, but such a small fix can go
                                                                                                            • Territory view for custom modules?

                                                                                                              I have recently activated territories however I can't seem to find how to use territories for custom modules? These modules have territories:  Contacts /  Accounts / Opportunities These modules don't have territories:   Buildings (custom module) and 
                                                                                                            • Zoho Books - How to Invoke a Custom Function in Schedulers

                                                                                                              We have multiple schedulers that send emails to customers in batches. Currently, we are maintaining the same code across several schedulers. Is it possible to use a custom function inside a scheduler script? If yes, how can we invoke the custom function
                                                                                                            • Adding a developer for editing the client application with a single user license

                                                                                                              Hi, I want to know that I as a developer I developed one application and handed over to the customer who is using the application on a single user license. Now after6 months customer came back to me and needs some changes in the application. Can a customer
                                                                                                            • additional accounts

                                                                                                              If I brought 5 emails to my account. Can I later buy additional emails.
                                                                                                            • Approval Process Comments

                                                                                                              Is it possible to view the comments entered during the approval or rejection of a record in the approval process? If not, is there a way to require a field to be completed upon approval or rejection?
                                                                                                            • Login for test case

                                                                                                              Had a few questions regarding authentication test cases and couldn't find an answer in the the docs. 1. If an app like Zoho Creator requires authentication before providing access, do I need to create a login function and add it to each test case? 2.
                                                                                                            • Zoho / Outlook Calendar sync

                                                                                                              The current Marketplace -> Microsoft -> Meetings integration needs 2 changes. 1. The current language for the Two-Way sync option should be changed. It currently states, "Sync both your Zoho CRM Calendar and Office 365 Calendar meetings with each other."
                                                                                                            • Collaps Notes

                                                                                                              There are times when long/large notes are added to a record i.e. Accounts or Deals etc. Currently, the full note is displayed in the notes related list section. It would be great if by default only 5 to 10 rows of the note are displayed when the note
                                                                                                            • GST Slabs Redefined: Stay Compliant Using Zoho Books!

                                                                                                              Hello Everyone! The Government of India is rolling out new GST rates, a major reform aimed at simplifying the current tax structure starting 22 September 2025. GST will move from four slabs (5%, 12%, 18%, 28%) to two main slabs (5% and 18%), plus a special
                                                                                                            • Form Rules for Suburb Categories to alternate landing pages or Making a Fields Contents ALL CAPS

                                                                                                              I need to send differentform submissions to two to three different thank-you URLs (for Meta/Google pixels) depending on which suburb a user selects in a form. I have ~400 suburbs split into two categories (A and B, based on business value). Current challenges:
                                                                                                            • Please make it easier to Pause syncing

                                                                                                              right now it takes 3 clicks to get there. sounds silly, but can you make it just 2 clicks to get it done instead? thats how dropbox does it, 2 clicks to pause instead of 3.
                                                                                                            • Customer members area

                                                                                                              Does FSM support a customer members area? If not what do you propose we use if we want the data used in FSM for customers to give them an area / login to see past orders, create new orders and general announcements.
                                                                                                            • Zoho Books-Accounting on the Go Series!

                                                                                                              Dear users, Continuing in the spirit of our 'Function Fridays' series, where we've been sharing custom function scripts to automate your back office operations, we're thrilled to introduce our latest initiative – the 'Zoho Books-Accounting on the Go Series'.
                                                                                                            • Record Logged in User while using CRM lookup field

                                                                                                              Is it possible, while using the Zoho CRM lookup field, to automatically use the user account logged into Zoho CRM in a hidden field? I was hoping to add employee accounts to my current plan. But would like a record on the Form submission of who submitted
                                                                                                            • Desktop app doesn't support notecards created on Android

                                                                                                              Hi, Does anybody have same problem? Some of last notecards created on Android app (v. 6.6) doesn't show in desktop app (v. 3.5.5). I see these note cards but whith they appear with exclamation mark in yellow triangle (see screenshot) and when I try to
                                                                                                            • Notes created in mobile can no longer be accessed in desktop

                                                                                                              Working with a 2013 Mac running OS 10.14.6; Desktop Notebook version 4.5.3. Using Motorola Moto G Power 5G - 2024; Android app version 6.7 I have been using Notebook for some years. Starting several weeks ago, the notes newly created ion the phone can
                                                                                                            • Function #49: Manage varying installment payments using Zoho Books

                                                                                                              . Hello everyone, and welcome back to our series! Last week, we discussed automating the collection of fixed installment payments in Zoho Books. But what if your payment structure involves charging varying percentages of the invoice total as installments?
                                                                                                            • Open Sans Font in Zoho Books is not Open Sans.

                                                                                                              Font choice in customising PDF Templates is very limited, we cannot upload custom fonts, and to make things worse, the font names are not accurate. I selected Open Sans, and thought the system was bugging, but no, Open Sans is not Open Sans. The real
                                                                                                            • Zoho Writer - Option to Export as .zdoc format

                                                                                                              I've noticed that it's not possible to export a Zoho Writer Document in the .zdoc format. Isn't zdoc, Zoho Writer's own format? My use case is that I sometimes need to create quite complex documents with floating elements, which sometimes need to become
                                                                                                            • Is it possible for contacts to "Re-enter" a workflow in Zoho Campaign?

                                                                                                              We are currently working on a way to automatically add users to from one list to other lists based on specific criteria, but can't seem to find a native way of doing this so we are trying to use Workflows to do this. So, for example, if a user's status is set to "Active," then they should be added to the list "Active Users." If the same user's status is then set to "Paused," they should be added to the list "Paused Users" and removed from the list "Active Users." This works fine for the first go
                                                                                                            • Bulk upload images and specifications to products

                                                                                                              Hi, Many users have asked this over the years and I am also asking the same. Is there any way in which we can bulk upload product (variant) images and product specifications. The current way to upload/select image for every variant is too cumbersome.
                                                                                                            • Out of Office for Just One of My Alias Email

                                                                                                              Can I set up the Out of Office Reply for Just One of my Alias Email Addresses?
                                                                                                            • Can I map multiple Surveys into the CRM using the same fields?

                                                                                                              Hello, We are a healthcare practice that offers two distinct services (Nutrition and Primary Care). We use Zoho Survey for our lead generation form (Get Started Survey), which allows people to express interest in one of the two services and even allows
                                                                                                            • Dealing with API responses where integers have more than 16 digits

                                                                                                              Hi there How do I deal with an api response contaning an int or float with more than 16 digits (before any decimal places for a float). I constantly receive the response "Unable to cast the 'BigInteger' value into a 'BIGINT' value because the input is
                                                                                                            • Can not add fields to a Section

                                                                                                              I feel like I'm missing something obvious: I can add new Sections to my form but I can not add fields to the Sections. I've tried fields already on the form as well as dragging and dropping new fields into the Section but nothing will go into it. What
                                                                                                            • Elevate your CX delivery using CommandCenter 2.0: Simplified builder; seamless orchestration

                                                                                                              Most businesses want to create memorable customer experiences—but they often find it hard to keep them smooth, especially as they grow. To achieve a state of flow across their processes, teams often stitch together a series of automations using Workflow
                                                                                                            • To Zoho customers and partners: how do you use Linked Workspaces?

                                                                                                              Hello, I'm exploring how we can set up and use Linked Workspaces and would like to hear from customers and partners about your use cases and experience with them. I have a Zoho ticket open, because my workspace creation fails. In the meantime, how is
                                                                                                            • [Webinar] Automate sales and presales workflows with Writer

                                                                                                              Sales involves sharing a wide range of documents with customers across the presales, sales, and post-sales stages: NDAs, quotes, invoices, sales orders, and delivery paperwork. Generating and managing these documents manually slows down the overall sales
                                                                                                            • Can't change form's original name in URL

                                                                                                              Hi all, I have been duplicating + editing forms for jobs regarding the same department to maintain formatting + styling. The issue I've not run into is because I've duplicated it from an existing form, the URL doesn't seem to want to update with the new
                                                                                                            • Next Page