Get Zoho Mail API working (including DRE Connector, Oauth Token, ZUID, ZOID & ACCOUNT_ID)

Get Zoho Mail API working (including DRE Connector, Oauth Token, ZUID, ZOID & ACCOUNT_ID)

Disclaimer: I’m not a professional coder!


Do you need to use Zoho Mail API?

Me too. It lets you do all sorts of things — like reading the complete header of an email, or forwarding an email with its attachments — which is what I wanted to do.


But setting up the API (application programming interface) took me hours.

It didn’t need to, but advice on this forum sent me in circles and, while the Knowledgebase probably has all the information, it’s not easy to determine which are the relevant bits. So…


Maybe this little guide will help you.

       To use Zoho Mail API you need:

a) A working OAuth Token (Open Authorization token)

b) Up to three Zoho IDs — User, Organization, Account

c) Depending on what you want to do, additional IDs for emails, folders, etc


OAUTH TOKEN

The token validates you when you make an API call. There are various ways to create it.

The hard way: it’s possible to create an OAuth token via Developer Space but this requires lots of options to be chosen and the OAuth token needs to be frequently refreshed.

The easy way, at least for me, was via a custom function in filters — because it’s simple to do, the OAuth token you create isn’t time-limited, and creating a custom function is what I was trying to do anyway


If you already have an OAuth token, great. If not, but have already created a custom function, jump to 4 below. Alternatively:

      1)    In Zoho Mail, go to settings/filters

      2)    Create a new filter and, under Actions, select ‘Custom Function’. Zoho help file here.

      3)    Click ‘Select Function’ and create a new function or use an existing one

      4)    Once the custom function is on screen, select ‘DRE Connectors’ (Deluge Runtime Environment) at the top right

      5)    Click ‘Create Connection’ and under ‘Default Services’ choose ‘Zoho OAuth’

      6)    ‘Connection Name’ can be anything you like. It’s the ‘Connection Link Name’ that you will use in your Deluge scripts.

      7)    Chose the ‘Scopes’ of your token. There are zillions of them and they determine what your script can and can’t do. The most basic might be ‘ZohoMail.messages.READ’. The API Guide Index lists every API command and, for each, details what scope you need e.g. the send an email page shows you’ll need the scope ZohoMail.messages.ALL or ZohoMail.messages.CREATE. (Sorry, I don’t know why you wouldn’t always choose the ‘ALL’ flavour.)

      8)    After you click ‘Create and Connect’ you should have a working OAuth token with a lowercase ‘link name’ that you can paste into your Deluge scripts.


NB: The OAuth token only applies to the Zoho area where you have your account (Zoho.eu in my case). So, for example, if I cut and paste a snippet into my script from the send an email page: https://mail.zoho.com/api/accounts/{accountId}/messages it will NOT work with my Europe OAuth token. I would need to change the snippet to: https://mail.zoho.eu/api/accounts/{accountId}/messages

GETTING THE RELEVANT IDS

You’ll see from the snippet above that this particular API needs your ‘accountId’ to work. Here’s how you get it (Why Zoho makes it so difficult, I don’t know!)


      1)    You can get all your relevant IDs with one API call: https://mail.zoho.eu/api/accounts (remember to adjust for your area). Help page here for what scope you need. The call returns a mass of information but buried in it are your Zoho User ID (ZUID), Zoho Organisation ID (ZOID) and Zoho Account ID (ZAID).


I created a custom function (see below) to make the API call and email me the result. I was then able to search for ‘zuid’, ‘zoid’ & ‘accountId’ to get the required numbers.

      2)    If you only want your Zoho User ID (ZUID). you don’t need an API call. Just log into Zoho and click the ‘My Profile’ icon (top right). Your user ID is right there under your name and email address.


      3)    Zoho advises an API call to get your Zoho Organisation ID (ZOID). But, again, there’s an easier way: open your Zoho Mail Dashboard (remember, this link is for zoho.eu, you’ll need to use your area). Then select ‘Organization’ on the left menu bar to display your Zoho Organization ID under the heading ‘Organization Info’.


FOLDER & EMAIL IDs


      1)    You may be able to use the name of a folder (e.g. “Trash”) in your Deluge script but if you need the folder ID number, this is the API.

      2)    All my scripts are triggered by an email by arriving in my inbox. The ID for that current email is held in the variable ‘mail_messageId’.

      3)    For everything else refer to the API Guide Index


Custom function to get account IDs:

url = "https://mail.zoho.eu/api/accounts";

response = invokeurl

[

            url :url

            type :GET

            connection:"your_oath_token" // the link name (in quotes) for the OAuth Token you created 

];

sendmail

[

            from :zoho.loginuserid

            to :"you@youraddress" // your email address in double quotes

            subject :"accounts" // or whatever subject you want

            message :response

]


Finally, there might be a better way to do any of the above — I did warn you I’m not a pro! — please feel free to add improvements.

    Access your files securely from anywhere











                            Zoho Developer Community





                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                  • Ask the Experts



                                                        • Topic Participants

                                                        • zoho

                                                            • Sticky Posts

                                                            • Pocket from Mozilla is closing shop. Don’t lose your favorites . Move them to Zoho Mail Bookmarks now! 📥🔖

                                                              The end of Pocket shouldn't mean the end of your important links and content. Easily import them into Zoho Mail's Bookmarks and continue right where you left off. You can bring over your entire Saves, Collections, and tags just the way they are. Bookmarks
                                                            • Zoho Mail POP & IMAP Server Details

                                                              Hello all! We have been receiving a number of requests regarding the errors while configuring or using Zoho Mail account in POP/ IMAP clients. The server details vary based on your account type and the Datacenter in which your account is setup. Ensure
                                                            • Workplace - Zoholics Europe Customer Awards

                                                              Dear Zoho Mail Community! 📣 We're excited to announce that at this year's Zoholics events across Europe, we're holding customer awards for the first time ever! Workplace - Zoholics Europe Customer Awards This is your chance to shout about the amazing
                                                            • Important update on Group Management | Zoho Mail

                                                              Dear Zoho Mail Community, This post is to inform you all of the following updates on the Group Management in Zoho Mail. Group Member Addition: If a group member is added to an organization group in a Zoho Application, the member will be automatically
                                                            • Mastering email etiquette and best practices to follow in Zoho Mail

                                                              Hello Zoho Mail Community, We’re thrilled to invite you all to our upcoming webinar: Mastering email etiquette and best practices to follow in Zoho Mail. Join our live webinar for expert etiquette tips to enhance your professionalism and elevate your


                                                            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

                                                                                                            • Don't understand INVALID_REQUEST_METHOD when I try to post up an attachment

                                                                                                              When I make the POST request (using python requests.post() for files): https://www.zohoapis.com/crm/v8/Calls/***************01/Attachments I get this response: r:{ "code": "INVALID_REQUEST_METHOD", "details": {}, "message": "The http request method type
                                                                                                            • Organization Emails in Email History

                                                                                                              How can I make received Org Emails to show up here?
                                                                                                            • Signature field is showing black

                                                                                                              Hello, When customer signed the service form, it is showing as below picture Phone model: iPhone 16 Pro We tried delete and install application, but it not solved. This has on phone of a few person. There is any advice to solve this?
                                                                                                            • Zoho CRM Android app updates: record sharing, user image upload, Zoho Survey integration, and more

                                                                                                              Hello everyone, We've made some important improvements to Zoho CRM's Android app, and we'd like to walk you through the latest updates. Here's what's new: Record sharing with org users User image upload Zoho Survey integration support Venue preference
                                                                                                            • How to Delete/hide Google adwords section from Layout?

                                                                                                              Hi people, maybe someone can tell me how to remove or hide the Google adwords section from my layout? Im not using it and it takes too much space.
                                                                                                            • WIDGET in related record list ZOHO CRM; how to get and put data to subform custom fields?

                                                                                                              he need: Read and write two custom subform line-item fields on Quotes: Segment_wyceny (picklist/text) and W_pakiecie (number). Write works; read does not return these fields via SDK. Environment Zoho CRM Widget Zoho Embedded App SDK v1.2 Module: Quotes
                                                                                                            • Zoho CRM Formula - Current Time minus Date/Time field

                                                                                                              Hello, I am trying to prevent duplicate emails going to clients when more than 1 deal is being updated. To do this, I would like to create a formula to identify if a date/time field is >= 2 hours ago. Can someone please help me write this formula? Example:
                                                                                                            • ヒートマップ詳細設定について

                                                                                                              はじめまして マーケティング担当の浅田です。 PageSenceのヒートマップ設定について質問です。 単一ページ毎の設定は上手くできるのですが 詳細設定にて、トップページのURLを含ませ全体のヒートマップを計測できないか試したところ お知らせ:データを受信していません。と表示されてしまいます。 トップページURLで始まるページの条件も試しております。 全頁を反映させたいと思い、詳細設定を上手く設定できたらと考えております。 どなたか詳しい方がいらっしゃいましたら、教えて頂けませんでしょうか 宜
                                                                                                            • Zoho CRM still doesn't let you manage timezones (yearly reminder)

                                                                                                              This is something I have asked repeatedly. I'll ask once again. Suppose that you work in France. Next month you have a trip to Guatemala. You call a contact there, close a meeting, record that meeting in CRM. On the phone, your contact said: "meet me
                                                                                                            • Introducing Assemblies and Kits in Zoho Inventory

                                                                                                              Hello customers, We’re excited to share a major revamp to Zoho Inventory that brings both clarity and flexibility to your inventory management experience! Presenting Assemblies and Kits We’re thrilled to introduce Assemblies and Kits, which replaces the
                                                                                                            • Way to update CRM records in quik view

                                                                                                              I have custom module in zoho crm and that module have 500 records. I want a quick way or UI so that user can easily update the record information in quick view without going to record detail view or edit view. I tried zoho sheet option but in zoho sheet
                                                                                                            • Writer sing up problom

                                                                                                              Zoho writer sing up prolom face
                                                                                                            • Add additional features to Zoho Tables

                                                                                                              Zoho Tables is a really great tool, why not add features like diagramming capability into the tool from applications like Draw.io which I believe is open source, you should be able to do wireframes, process flow diagrams, network design, etc. Please note
                                                                                                            • Where to integrate Price Book and Product List Price

                                                                                                              Hello, We sync zoho crm all modules with all data to zoho analytics. In zoho crm, we have "Price Books" and "Products" modules, where each product is assigned to a few price books with different list prices. From zoho crm, I am able to export a dataset
                                                                                                            • Form / CRM Integration Not entering into workflow

                                                                                                              I have a simple form setup with company name, first name, last name and lead source. Each of the fields are mapped to CRM Leads module. When the form is submitted, the lead is populated properly. I also have a workflow created that when the lead source
                                                                                                            • Automating CRM backup storage?

                                                                                                              Hi there, We've recently set up automatic backups for our Zoho CRM account. We were hoping that the backup functionality would not require any manual work on our end, but it seems that we are always required to download the backups ourselves, store them,
                                                                                                            • Zoho Slowness - Workarounds

                                                                                                              Hi all, We've been having intermittent slowness and Zoho just asks for same stuff each time but never fix it. It usually just goes away on it's own after a couple weeks. Given that speed is a very important thing for companies to be able to keep up with
                                                                                                            • First day of trying FSM in the field.

                                                                                                              What we found. 1. with out a network connection we were unable to start a service call? 2. if you go to an appointment and then want to add an asset it does not seem possible. 3. disappointed not to be able to actually take a payment from within the app
                                                                                                            • In arattai received message can't be deleted

                                                                                                              The issue has been noticed in following: arattai app (Android) arattai app (Window) arattai web While the message posted by me may be deleted, the ones received from others can't be. The item <Delete> change to <Report> when the message is a received
                                                                                                            • how to use validation rules in subform

                                                                                                              Is it possible to use validation rules for subforms? I tried the following code: entityMap = crmAPIRequest.toMap().get("record"); sum = 0; direct_billing = entityMap.get("direct_billing_details"); response = Map(); for each i in direct_billing { if(i.get("type")
                                                                                                            • Don't understand why Forms Mobile Scan and Fill not working

                                                                                                              I have configure enabled mobile scan and fill, I have enabled QR and Bar code on two fields name and position, I have mapped seq 1 to Name and seq 2 to position, I have created a 2d QR code with the person names and position, seperated by a comma. When
                                                                                                            • Recurring Supervisor Rule Reminders for Open/In-Progress Tickets

                                                                                                              Hello Zoho Support Team, I would like to suggest a potential improvement regarding reminders for tickets and activities in Zoho Desk. Currently, it is possible to set reminders only once. In the Supervisor Rules section, it is possible to configure reminders
                                                                                                            • Syntax for URLs in HTML Snippets

                                                                                                              What are some best practices for inserting a URL in an HTML snippet? I've looked at Zoho Help articles on navigation-based and functional-based URLs, but I'm still unclear on how to incorporate them in an HTML snippet. For example, 1. How do I link to
                                                                                                            • Template usage

                                                                                                              Hi, We are using some templates as a response to customer questions. Is it possible to analyze the usage of these templates? We want to know if the use of our templates has increased over time
                                                                                                            • Round robin

                                                                                                              Hi, I'm trying to set up a round robin to automatically distribute tickets between agents in my team but only those tickets that are not otherwise distributed by other workflows or direct assignments. Is that possible and if so which criteria should I
                                                                                                            • Has anyone built a ticket export that allows Help Center users to export the tickets shown in the My Area list they are looking at?

                                                                                                              Hi, We are moving to Zoho Desk soon. Our current support system displays an option in our help center allowing customers to export their Open, Closed, or all tickets based on which list they are looking at. We need to offer the same in Zoho Desk help
                                                                                                            • How to mute chat notification sound by default in Zoho SalesIQ?

                                                                                                              We’ve recently embedded the Zoho SalesIQ chatbot on our website, and we’ve noticed that notification sounds sometimes play even when the visitor hasn’t interacted with the chat widget yet. We’re trying to understand two things: Why do these sounds occur
                                                                                                            • Ticket Status Colors

                                                                                                              Can i change the colors of Ticket Status in the admin panel? Or even change the background of the entire cell of a Critical ticket? This way its easy for my agents to see a urgent ticket when it comes in. Right now everything is black text. Here Right
                                                                                                            • Sync Lookup Fields from Zoho CRM

                                                                                                              HI Team, I have synced a lookup field from my CRM data to Campaigns. When I view the synced data the field appears to display a Zoho CRM record ID rather than the text value. Is it possible to get the sync to import the text value rather than the CRM
                                                                                                            • New From Address cannot verify

                                                                                                              I have created a new From Address, which is the support@ address for my domain, that forwards to the default support mailbox. Presumably then, the verification email that is sent, should turn up as a ticket, but it does not. How can I verify my from address so that I can use my own domain?
                                                                                                            • 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
                                                                                                            • How to update/remove file in zoho creator widgets using javascript API

                                                                                                              Hi Team, I have developed a widget which allows inserting and updating records I have file upload field with multiple file upload. Now while doing insert form record, I am using uploadFile API to upload files for that record. I am using updateRecord API
                                                                                                            • Sheet View in CRM portal

                                                                                                              Hi, When will it be possible for my CRM portal users to edit/add records with Sheet View? George
                                                                                                            • issue with image thumbnails not showing in Image Selector

                                                                                                              We have been using Zoho Campaigns for over a year, maybe close to two years, and this issue just started happening in the last month. I wanted to wait to see if it would resolve on it's own, and it doesn't seem to be. The thumbnail images for all new
                                                                                                            • Deluge Script for adding tag

                                                                                                              Trying to create a custom function where a tag is added to a record - but for the life of me, I cannot figure out how. Help please! Moderation Update: Adding the help doc and sample to add Tags to records via deluge here for everyone's benefit. tag1 =
                                                                                                            • Unlock your Zoho Vault with OneAuth, Windows Hello, TouchID, YubiKey, and many more!

                                                                                                              Hello everyone, We are thrilled to introduce one of the most highly requested features – the ability to unlock your Zoho Vault using various authenticators. The primary purpose of a password manager is to remember just one master password and securely
                                                                                                            • Where does this report come from in the Zoho One ecosystems?

                                                                                                              Is this directly from MA, Analytics or ??? ???
                                                                                                            • Blueprint or Validation Rules for Invoices in Zoho Books

                                                                                                              Can I implement Blueprint or Validation Rules for Invoices in Zoho Books? Example, use case could be, Agent confirms from client that payment is done, but bank only syncs transactions tomorrow. in this case, Agent can update invoice status to done, and
                                                                                                            • Creator roadmap for the rest of 2022

                                                                                                              Hi everyone, Hope you're all good! Thanks for continuing to make this community engaging and informative. Today we'd like to share with you our plans for the near future of Creator. We always strive to strike a good balance of features and enhancements
                                                                                                            • How can I get base64 string from filecontent in widget

                                                                                                              Hi, I have a react js widget which has the signature pad. Now, I am saving the signature in signature field in zoho creator form. If I open the edit report record in widget then I want to display the Signature back in signature field. I am using readFile
                                                                                                            • Next Page