Kaizen 202 - Answering Your Questions | Testing and Using REST APIs in Widgets

Kaizen 202 - Answering Your Questions | Testing and Using REST APIs in Widgets



Hello Developers!

Welcome back to a fresh week of Kaizen! 

Thank you for your active participation in sharing feedback and queries for the 200th milestone. This week, we will look at the following queries related to widget:
  • Widget Testing 
  • Using REST API in Canvas Widgets: Make HTTP calls in widgets (e.g., to external tax or product APIs)
Here are the queries that we have already answered for you from this milestone:
  1. Kaizen #200 - Answering Your Questions | Token generation using the Python SDK
  2. Kaizen #201 - Answering Your Questions | Webhooks, Functions, and Schedules

Widget Testing

One of the queries we received was simply stated
Quote
Widget Testing
 without any specific context. Since the user has not provided detailed input, we are assuming this is about how to test a widget during development.

You can test your Zoho CRM widget locally using the Zoho CLI. Run the following command from the root directory of your widget project:

zet run

This launches the widget on a local server where you can validate the UI and functionality before pushing it live.


Since the localhost connection opens in a new tab and is not private, you will need to manually authorize it. 

Click Advanced, then choose Proceed to 127.0.0.1 (unsafe) to continue. 

Notes
Note

If your widget needs to access data from your Zoho CRM organization, such as fetching or updating records, it must be deployed within a Zoho CRM iframe. To do this, you should upload the widget through the Zoho CRM Widgets setup page.

We recommend using the sandbox environment in such cases before deploying the widget to your production environment.

Making HTTP Calls from Widget

Following is a query we received from a user:
Quote
Using REST API in Canvas Widgets: Make HTTP calls in widgets (e.g., to external tax or product APIs)
Yes. You can make HTTP requests to external services from any type of Zoho CRM widget using the ZOHO.CRM.HTTP object from the Widget JS SDK.

Canvas Widget - What's Supported? 

Though full widget support within Canvas is on our roadmap, currently, you can invoke widgets from a Canvas view using Client Script. This lets you render widgets inside fly-outs or pop-ups. Here is a quick start guide on how you can achieve it:

Create a Widget

1. Create a widget project and code your logic using Zoho CLI as explained in our widget help page.

2. In Zoho CRM Developer Hub, create a new widget and set the type as Button.



Create a Client Script

3. Navigate to Client Scripts in Developer Hub and click New Script.

4. You can create your script either in the Modules or Commands category based on your use case. 

For assistance, refer to the step-by-step guide on Creating Client Script and Commands.



In the Category Details section, ensure to select Canvas as the page type. Canvas views are supported in the following page contexts: List, Detail, Create, and Clone. 

Choose the one that aligns with where your widget needs to appear.


5. Here is the sample script to render widget in a pop-up

ZDK.Client.openPopup({
api_name: 'Canvas_Widget',
type: 'widget',
animation_type: 4, 
height: '450px',
width: '450px',
},
{
data: 'sample data to be passed to "PageLoad" event of widget'
}); 

Here is the sample script to render widget in a fly-out

ZDK.Client.createFlyout('myFlyout', { 
animation_type: 4, 
height: '600px', 
width: '500px'
}
);
ZDK.Client.getFlyout('myFlyout').open({ api_name: 'Canvas_Widget', type: 'widget' });

For detailed guidance, check out our Client API documentation on Pop-up and Fly-out.

You can also check out the Kaizen #99 on Rendering Widgets using Client Script for a detailed guide based on a real-time use case. 

Using REST APIs from External Applications

The ZOHO.CRM.HTTP object enables you to make secure API calls directly from the Zoho CRM widget. It acts as a proxy, routing requests through Zoho servers, which eliminates the need for external applications to support CORS.

While this SDK is primarily used for integrating third-party services, it also supports Zoho CRM API calls. This provides you with greater flexibility to:
  • Customize header and parameter structures
  • Maintain a consistent calling pattern for both internal and external APIs within the widget.
Here is a basic syntax of the SDK:

ZOHO.CRM.HTTP.<method>({
  url: "<request-url>",
  headers: {
       // Request headers as Key-value pairs
    "Authorization": "Bearer <token>" // example
  },
  params: {
    // Request params as Key-value pairs

   "ids": "1234567890" // example
  },
  body: "<stringified JSON>", // Required for POST, PUT and PATCH
})
.then(function(response) {
  console.log("Response:", response);
});

Supported Methods
  • ZOHO.CRM.HTTP.get({ ... })
  • ZOHO.CRM.HTTP.post({ ... })
  • ZOHO.CRM.HTTP.put({ ... })
  • ZOHO.CRM.HTTP.patch({ ... })
  • ZOHO.CRM.HTTP.delete({ ... })
For more detail check out the HTTP method section of JS SDK help page.

Samples using Zoho CRM Contact Roles API

Let us explore a complete CRUD (Create, Read, Update, Delete) example using Zoho CRM’s Contact Roles API.

These structures have to be used within the JS function where you are executing your code logic. 

POST Contact Roles


// Prepare the API request
        var request = {
          url: "https://www.zohoapis.com/crm/v8/Contacts/roles",
          headers: {
            Authorization: "Zoho-oauthtoken 1000.XXXXXXXXXXXXXXXXXXX265bcf20e4"
          },
          body: {
            "contact_roles": [
              {
                "name": "Sales Lead",
                "sequence_number": 1
              }
            ]
          }
        };
         // Make API call 
        ZOHO.CRM.HTTP.post(request).then(function(data) {
          console.log(data);
 })

GET Contact Roles


// Prepare the API request
var request = {
          url: "https://www.zohoapis.com/crm/v8/Contacts/roles",
          headers: {
            Authorization: "Zoho-oauthtoken 1000.XXXXXXXXXXXXXXXXXXX265bcf20e4"
          }
        };
        // Make API call 
        ZOHO.CRM.HTTP.get(request)
          .then(function(response) {
 console.log(response);
})

UPDATE Contact Roles

// Prepare the API request
        var request = {
          headers: {
            Authorization: "Zoho-oauthtoken 1000.XXXXXXXXXXXXXXXXXXX265bcf20e4"
          },
          body: {
            "contact_roles": [
              {
                "name": "Evaluator",
                "id": "5545974000000006871"
              }
            ]
          }
        };
        // Make API call 
        ZOHO.CRM.HTTP.put(request).then(function(data) {
          console.log(data);
 })

DELETE Contact Roles


// Prepare the API request
        var request = {
          params: {
            ids: "5545974000002617002"
          },
          headers: {
            Authorization: "Zoho-oauthtoken 1000.XXXXXXXXXXXXXXXXXXX265bcf20e4"
          }
        };
        // Make API call 
        ZOHO.CRM.HTTP.delete(request).then(function(data) {
          console.log(data);
 })

We hope you found this post useful. 

Let us know if you have any questions in the comments or drop us an email at support@zohocrm.com.

Cheers!

------------------------------------------------------------------------------------------------------------------------

Related Reading


------------------------------------------------------------------------------------------------------------------------
    • 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
    • Recent Topics

    • portal.assignUserInProfile - Não esta adicionando

      Estou encontrando problema com este comando portal.assignUserInProfile Não esta incluindo o usuário no portal Alguém pode me dizer o que pode ser thisapp.portal.assignUserInProfile("teste@gmail.com","Customer");
    • CRM emails vs Campaigns

      Please help me understand this. I am having a difficult understanding of "Campaigns" sent through CRM (real emails) or Zoho One (blast "potentially junk" emails) This is what I currently think emails sent via CRM are "real" emails sent through linked real personal email accounts and therefore are more likely to get delivered.  We use this for critical updates for our "Approved " accounts and certain other preferred statuses emails via Campaigns are sent through the Zoho server (like MailChimp, Campaign
    • Setting up property management in Zoho Books

      Hi, I run a property management business that manages property complexes. There are multiple owners, some owning more than one property on the same complex. My role is to manage the fees they pay for maintenance of common areas, such as the swimming pool
    • Reverse proxy

      We have a web application in the creator platform. When I launch a particular DNS, I would like that DNS to redirect to the web page of the application in creator app. Has anyone achieved it and if yes, please share how to do it.
    • Still client need to download .exe?

      Hello, the client for use zoho assist need everytime download .exe file and launch it?
    • Splitting a ticket's entire thread

      Hi, When you split a ticket it only splits the individual reply that you clicked "Split as new ticket" on. Is it not possible to split the entire ticket thread from that point into the new ticket (every reply from the split point forward)? Or is there
    • Editing the text on the Help Center home page

      Is it possible to edit the "Welcome to Help Center" message anywhere? This one: We'd like to be able to tailor it a little more ourselves.
    • WHMCS for Zoho Flow

      Can we use WHMCS for Zoho flow?
    • Online meetings through Calendar Booking form with options

      This is great to see and particularly for those users who don't have Zoho BOOKINGS. The shame of it all though is that it could have been better. Why do we have to set up separate booking forms for each type of meeting and for each online conferencing
    • Agents permission per department

      Hi Team, can I setup permission for each agent what they can do in each department, for example I want account department agents to only have view access to support department tickets and not allowed to assign or reply to clients. I am sure this would
    • CRM notes

      I want to be able to add notes to a task that do not necessarily get rolled up into an account or contact.   For example, I tasks to work on a Court Order for John Doe divorce account.  There might be lots of updates (in the form of notes) that employees
    • Introducing parent-child ticketing in Zoho Desk [Early access]

      Hello Zoho Desk users! We have introduced the parent-child ticketing system to help customer service teams ensure efficient resolution of issues involving multiple, related tickets. You can now combine repetitive and interconnected tickets into parent-child
    • Function #8: Add additional charges to invoices

      Here goes one of the highly sought-after custom functions in Zoho Books. If you find yourself needing to apply additional charges to customers on their invoices (say credit card surcharges, or fuel charges applicable to customers from a certain region,
    • Alternative / optional Position

      How do you create an alternative position or an optional position (article) in offers?
    • جمود في الصفحة عند حفظ عمل

      عندما اقوم باضافة ايقونة الى صفحة النموذج تجمد الصفحة ولا تعمل وتصبح مثل المظلة احدث الصفحة لا تعمل انتظر قليلا لا تعمل اقوم بنسخ رابط الصفحة والصقه في الرابط فيعمل
    • ZOHO Books Canadian payroll Integration

      Hello, I know ZOHO books doesn't have Canadian payroll and I dont believe its coming anytime soon. My question is there a Canadian payroll software that could be integrated with Zoho Books? Thank you HD
    • Create a draft in reply to an email via Emails API

      Hi, I’d like to use the outgoing webhook to automatically create a draft reply to incoming mail. How can I use the Emails API to create a draft reply that is linked to an existing email thread? I couldn’t find the relevant method in the documentation.
    • Zoho Desk Time Tracking and the Salary Privacy Issue

      Hello colleagues, Just wondering if anyone did hit the same wall? In the Desk, when the agent-specific hourly rates are enabled (Zoho Desk → Setup → Time Tracking → Billing Preferences), these Time Entries are being displayed in the Ticket History tab.
    • How to Delete, Disable, or Remove Streams from the Mail App?

      Is there a way to remove Streams from the mail app sidebar? I get too many notifications, it doesn't add any value to Zoho's functionality (especially since you can just make comments inside an email), and is distracting. I do not want notifications/alerts
    • Delay in MX updates

      Hi, I set MX Records 12 hours ago, and I am receiving email normally, but I still get notification MX record is not pointing correctly. Error: The MX records of your domain is not yet pointed to Zoho Mail. Why there is a delay in detecting MX records,
    • Bigin iOS and macOS app update: Link email messages to pipeline records.

      Hello everyone! In the latest version of the Bigin iOS(v1.11.9) and macOS(1.8.9) app, we have brought in support for an option to link email to pipeline records. This helps you to view emails specific to a deal, especially when a contact is associated
    • make.com integration

      Just wondering if anyone on Zoho One account connecting apps to Make.com We're on Canadian server (.com) and when connecting to Make.com, it keeps having error of Invalid Client ID. I have contacted both Zoho and Make and both sides said it's not an error
    • Article Numbers for KB articles

      Hello, I was wondering if it's possible to turn on article numbers/ part numbering for KB articles. If this is not already a feature, we'd like to request it. Frequently a solution will require multiple articles so tracking which articles are referenced
    • Refund Request ,Zoho Mail Subscription (zoho suport is not replying)

      Hi Zoho Team, I recently subscribed to the Zoho Mail yearly plan, but after evaluating it, I found that the interface does not suit my workflow. I’ve already canceled the subscription from my end. As I’m well within your 30-day refund window, I’m requesting
    • File Encryption - Zoho Desk iOS app update

      Hello, Everyone! We have now introduced the 'File Encryption' option within the Zoho Desk app as part of the HIPAA Compliance. This option allows the user to encrypt the attachments within the Desk mobile app, which acts as an additional layer of security.
    • Data encryption - Zoho Desk iOS

      Hello, Everyone! In the recent iOS version(v2.8.23) of the Zoho Desk app, we have supported data encryption. As a part of HIPAA Compliance, the Zoho Desk mobile app now allow users to encrypt the Desk mobile database as an additional layer of security.
    • Notify Admin when a user forgets to check-in or check-out at the designated time.

      Hello, I would like notify the Admin via email when a user forgets to check-in or check-out at the designated time. What is the best way to setup this email notification?
    • Assistance Needed with Prospect Conversion Issue

      Hi, I attempted to convert a prospect to an account, but received a pop-up notification indicating that the contact information matches an existing contact. I selected the option to add it to the existing contact, but it appears the prospect was not successfully
    • Mail Merge - unable to send more than 50 email

      Hi, I've subscribed to the pay email service because of the Mail Merge feature. However, I've found that this feature only allow to send up to 50 emails. I've to attach a screenshot for your reference. This limitation is not mentioned anywhere in service.
    • Zoholics Europe 2025: Your Ultimate Data Analysis (Zoho Analytics) Workshop Experience

      Why should you attend? This year, Zoholics Europe 2025 is putting data analysis centre stage. With a dedicated workshop designed to answer all your data-related questions, you’ll gain practical skills, real-time solutions, and expert insights that you
    • UK payroll entries

      Hey guys, Nett payroll payments are imported direct into the bank, using an external payroll system (will be glad for Zoho to have a UK payroll app) At present I have monthly recurring bills for HMRC which are auto entered & paid when due. This seems
    • Closing Accounting Periods - Invoice/Posting dates

      Hi, I have seen in another thread but I'm unsure on how the 'transaction locking' works with regards to new and old transactions. When producing monthly accounts if I close December 24 accounts on 8th Jan 25 will transaction locking prevent me from posting
    • Invoice status on write-off is "Paid" - how do I change this to "Written off"

      HI guys, I want to write off a couple of outstanding invoices, but when I do this, the status of the invoices shows as "Paid". Clearly this is not the case and I need to be able to see that they are written off in the customer's history. Is there a way
    • Reverse Charge Services (Non-EU) Showing Correctly in 84/85 and 67, But Missing in Box 46 - Germany

      Hi, I'm located in Germany and I’ve set up my expenses for non-EU services (e.g., OpenAI, DeepSeek) under the reverse charge mechanism (§ 13b UStG) in Zoho Books, and I noticed some discrepancies in the VAT Summary Report. What’s Correct: Reverse Charge
    • Zoho Live Chat/Support

      What is going on with Zoho support lately? I've tried to use the live chat feature 4 different times and it refuses to connect to any (despite waiting over 30 minutes one of the tries). I finally gave up and emailed my question nearly a week ago and still
    • Can we have a module to records Certificate No and TDS rates for Lower TDS Certificates by the vendors ?

      Can we have a module to records Certificate No and TDS rates for Lower TDS Certificates by the vendors ?
    • Tip #38- Track Organizational Changes: A Guide to Using Action Log Viewer- 'Insider Insights'

      Hello Zoho Assist Community! Ever needed to trace who did what and when within your remote support operations? Let’s say your support team is growing, and you want to monitor key activities like settings updates, user invites, module changes, or permission
    • Tip of the Week #67– Avoid confusion – Mark duplicate threads.

      When customers send the same message to multiple email addresses, such as support@ and sales@, your team may end up seeing the same message in different inboxes. This creates confusion, risks double replies, and clutters your workspace. Use the Mark as
    • Tax in Quote

      Each row item in a quote has a tax value.  At the total numbers at the bottom, there is also a Tax entry. If you select tax in both of the (line item, and the total), the tax doubles. My assumption is that the Tax total should be totalling the tax from
    • Final Reminder: Discontinuation of Older ASAP Widgets and Mobile SDK Support

      We launched the new ASAP Help Widget last year, introducing a unified and enhanced experience. Since then, older configurations have been placed in read-only mode, with all major updates and improvements built exclusively on the new version. As part of
    • Next Page