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. This route is intended for developers who are using external apps to link with Zoho.


The easy way, at least for me, was via a custom function in filters — because it’s simple to do, refreshing the OAuth token is handled by Zoho, 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). It's good security practice to only use the minimum scope you need.

      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 YOUR IDS


Without API

You’ll see from the snippet above that this particular API needs your ‘accountId’ to work. Zoho advises getting your IDs via an API call, but you don't need to:


1)   Zoho User ID (ZUID).  Just log into Zoho and click the ‘My Profile’ icon (top right). Your user ID is right there under your name and email address.

2)  Zoho Organisation ID (ZOID). 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 ‘Organization Info’, including your Zoho Organization ID.

3) Zoho Account ID (ZAID). Select any of your emails in Zoho Mail. Right click and pick 'Open in New Window'. Your Zoho Accound ID is the number following "accId=". (See Zoho's help page to get the message ID of emails — it also shows the accountId.)

With API
Alternatively, you can get all three 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 for this API call. 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).


So how do I make the API call?

There are various ways but I use a bit of deluge script:

apiUrl = "https://mail.zoho.eu/api/accounts";
response = invokeurl
[
    url :apiUrl
    type :GET
    connection:"your_oauth_token" // the OAuth token you created, in quotes
];
info response;

1) Create a new Zoho Mail custom function and paste in the above script.
2 ) In the function window, click 'Test Run' (top right). You'll be asked for a Message ID.
3) For this script, any message will do. Select any message in your Zoho Mail inbox. Right click and choose 'Open in New Window'. You'll see the Message ID after 'msgId=' in the URL displayed by your browser. See here for visual.
4) Paste the Message ID into the function window and press 'Proceed'. You'll be presented with the heading 'Console' and the result of your API call beneath it, where you'll find the IDs you need after 'zuid=', 'zoid=' and 'accountId='.

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, either use this API or, even easier, select an email in the folder your interested in, right click and pick 'Open in New Window'. The folder ID comes after 'folId=' in the browser URL.

      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


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

                                                                                                            • Connecting Zoho Inventory to ShipStation

                                                                                                              we are looking for someone to help connect via API shipStation with Zoho inventory. Any ideas? Thanks. Uri
                                                                                                            • Subform edits don't appear in parent record timeline?

                                                                                                              Is it possible to have subform edits (like add row/delete row) appear in the Timeline for parent records? A user can edit a record, only edit the subform, and it doesn't appear in the timeline. Is there a workaround or way that we can show when a user
                                                                                                            • New in Cadences: Option to Resume or Restart follow-ups when re-enrolling records into a Cadence, and specify custom un-enrollment criteria

                                                                                                              Managing follow-ups effectively involves understanding the appropriate timing for reaching out, as well as knowing when to take a break and resume later, or deciding if it's necessary to start the follow-up process anew. With two significant enhancements
                                                                                                            • Im Stuck in an EDIT ONLY WITH WIZARD issue

                                                                                                              So I found Wizards to be a really helpful tool in minimizing the exposure of redundant, superfluous fields to staff that would never otherwise have to edit those fields. My issue is, that when the record (in this case a lead) is created with a wizard,
                                                                                                            • Account upgrade

                                                                                                              Good evening, I upgraded my account and paid for it. From standard to professional. Unfortunately after the paiment my account was not upgraded. Please your advise. Best Regards Erik van Staverden
                                                                                                            • How to set ALL default dates of my organization to DD-MM-YYYY format?

                                                                                                              All replies to this question comes from a time where the UI was different. It's extremely frustrating not being able to find how to do this simple setting change. I want everything and everyone in my organizations to have DD-MM-YYYY date format by default.
                                                                                                            • How can I sync from Zoho Projects into an existing Zoho Sprints project?

                                                                                                              Hi I have managed to integrate Zoho Projects with Zoho Sprints and I can see that the integration works as a project was created in Zoho Sprints. But, what I would like to do is to sync into an existing Zoho Sprints project. Is there a way to make that
                                                                                                            • Can we generate APK and IOS app?

                                                                                                              Dears, I want to know the availability to develop the app on zoho and after that .. generate the APK or IOS app  and after that I added them to play store or IOS store.. Is it possible to do this .. I want not to use zoho app or let my customers use it. thanks 
                                                                                                            • Zoho Subform Workflows onAdd of Row

                                                                                                              Suppose I have a form with attached workflows onLoad. If I use the form as a subform, will it inherit the workflows or do I need to create new ones onAdd of row?
                                                                                                            • Session Expired

                                                                                                              I constantly get "Session Expired" and need to relogin or close and open the application again. This gets really frustrating during the day. Is this something that can be solved? This really makes me want to leave the app as it is no go to need to reopen
                                                                                                            • Super Admin removal

                                                                                                              I brought a sub, and I gave the Super admin rights to a person who is no longer with us, so I need to change, and I need to make myself the Super admin
                                                                                                            • Better Notes Commenting

                                                                                                              Hi, I'd like to suggest better collaboration tools for NOTES. The current notes section for Accounts, Contacts and Deals is not ideally suitable for any degree of communication or collaboration. When responding to a note, there is no ability to leave
                                                                                                            • Exporting Templates

                                                                                                              I have just spent 2 hours creating a project template for a Netsuite configuration, and want to share it with other Zoho Projects users - who have a different account. Is there any way to do this?
                                                                                                            • Power of Automation:: Streamline Associated Teams based on the Task Owner update.

                                                                                                              Hello Everyone, A Custom function is a user-written set of code to achieve a specific requirement. Set the required conditions needed as when to trigger using the Workflow rules (be it Tasks / Project) and associate the custom function to it. Requirement:
                                                                                                            • No Response from Zoho Support in 8 Days - Typical?

                                                                                                              I have a couple of issues I'm trying to work through. Initially, I was getting support from support@zohofsm.com, but I have not received a response in 8 days (11 on another question). Is this typical? Can I pay for support? For context, I am not spamming
                                                                                                            • Add QUOTE OWNER profile image to a Quote Template

                                                                                                              I can add their email address.. phone number, DOB. I need to add a users profile picture so when they assign a template to a quote they own it adds their picture to the cover page. I've tried hacking a solution together but there has to be an easier way.
                                                                                                            • Zoho Connections Desk API relative URL PATTERN_NOT_MATCHED

                                                                                                              While i am trying to do this: async function fetchTicketsFromDesk(timeFilter = 'current_month') { try { const response = await ZOHO.CRM.CONNECTION.invoke("desk_connection", { url: "/api/v1/tickets", method: "GET", }); const data = response.details ? JSON.parse(response.details)
                                                                                                            • Zoho CRM - Custom Views for Portal Users

                                                                                                              I'm looking for an option to customise custom views for portal users in CRM. It would be great if "portal user" was a permission on custom views.
                                                                                                            • 【参加無料】10/17(金) 東京 ユーザ交流会 Vol.3 参加登録 受付開始!

                                                                                                              ユーザーの皆さま、こんにちは。コミュニティチームの藤澤です。 10/17(金)に、東京・新橋で「東京 ユーザー交流会 Vol.3」を開催します! 今回のユーザー事例セッションのテーマは、「Zoho Flowを活用した他社の決済サービスとの連携事例」です。 さらに、Zoho Flowに限らず、Analytics や Campaigns などの多彩なZohoサービスの活用方法について、豊富なご経験をもとにご紹介いただきます。 また、Zoho社員セッションでは、Zoho CRMを活用して日々の営業業務を効率化する具体的な事例をお話しします。業界を問わず、幅広い方にご参考いただける内容となっています!
                                                                                                            • Zoho Meeting Plug compatibility with newer versions of Outlook

                                                                                                              Documentation states that the zoho meeting plug in for outlook is only compatible with versions up to Outlook 2019 What is available to users of more up to date versions of outlook/office 365?
                                                                                                            • Getting Attachments in Zoho Desk via API

                                                                                                              Is there a way to get attachments into Zoho Desk via an API?      We have a process by which a zoho survey gets sent to the user as a link in a notification.    The survey has several upload fields where they can upload pdf documents.    I've created
                                                                                                            • Introducing Zoho's own SMS gateway

                                                                                                              We're thrilled to announce the launch of our own SMS gateway feature within Zoho Marketing Automation! This new feature enables seamless SMS campaign management alongside your email marketing initiatives, providing a more integrated and efficient way
                                                                                                            • Embedding in Desk articles

                                                                                                              We would like to embed documents in our Desk articles. When we use an iframe for the embed, we get scrollbars and a frame border. Neither of those is acceptable. I've spoken with the Desk Support team about what we want and they tell me that it cannot
                                                                                                            • Zoho CRM button to download images from image upload field

                                                                                                              Hello, I am trying to create a button in Zoho CRM that I can place in my record details view for each record and use it to download all images in the image upload fields. I tried deluge, client scripts and even with a widget, but feel lost, could not
                                                                                                            • Mass Update Contacts In Zoho Campaigns

                                                                                                              Is there a way to mass update contacts in zoho campaigns? I want to be able to change the content of a field for a few hundred contacts, and can't go through all of them individually.
                                                                                                            • report showing assignment type

                                                                                                              Hi, We've created a number of workflows to allow us to auto assign tickets to agents based on keywords and other criteria. I'm struggling to create a report that would show me what is the percentage of tickets that are assigned automatically via workflows
                                                                                                            • Option to Disable Knowledge Base Section in Feedback Widget Popup Hello Zoho Desk Team

                                                                                                              Hello Zoho Desk Team, How are you? We are actively using Zoho Desk and would like to make more use of the Feedback Widget. One of the ways we implement it is through the popup option. At the moment, the popup always displays the Knowledge Base section,
                                                                                                            • Placeholders in Ticket Templates

                                                                                                              We should be able to use placeholders in ticket templates. When we create a new ticket, our description field is shown to the client in the email they receive.  It would be very handy to be able to personalize that description field in our ticket templates to pull in the name of the client that the ticket is for. Using them in the subject field as well, so we can auto populate Account Names, etc. 
                                                                                                            • when the record is created the tag want to Show as Opportunity how i achive this using Deluge Script

                                                                                                              In the quotation i have the work flow schedule for create opportunity record in the module , on that time the quotation tag select as opportunity created. How i achive this using Deluge Script . this like i want to Do tag1 = Map(); tag1.put("name","Nurturing
                                                                                                            • Delete a channel

                                                                                                              I need delete a channel in tickets.
                                                                                                            • Copy / Duplicate Workflow

                                                                                                              I have workflows setup that are very similar to each other. We have a monitoring system watching servers, and all notifications - no matter what client it is about - will come from a  noreply@ address which is not very helpful in having it auto assigned to the right account. I have setup a workflow that will change the contact name of the ticket (currently it would say noreply@) to the correct customer which is based on the subject line, as that mentions which server the alert it is about. I need
                                                                                                            • Subtasks don't update parent task's times

                                                                                                              Hi there: I've recently upgraded to premium and check that subtasks completion % don't update the proportional completion of the parent tasks related to it.  We've been challenging with the problem of having to update twice or sometimes 3 times the completion of the related tasks. I've seen posts similar to this, of 3 years old.  Is there any roadmap for making this happen in a future release? Thanx César Ratto Lima, Perú.
                                                                                                            • Should I Use DMARC?

                                                                                                              When I configure Zoho Mail's DMARC settings, it's mandatory to fill in the RUA and RUF (Aggregate notification email address*, Forensic notification email address*) addresses. When we enter an email address in these fields, we receive reports from the
                                                                                                            • Mail ToDo & Tasks Webhooks

                                                                                                              Our company uses Zoho ToDo inside Mail to manage our tasks. When I create a task and assign it to a team member it does not notify them unless I add a reminder via mail. I'm trying to create a webhook for when a task is created to send a cliq message
                                                                                                            • Can't upload attachments.

                                                                                                              I can't upload attachment in Zoho Mail.
                                                                                                            • Tip #44 – Get Deeper Insights with Zoho Assist’s Custom Reports – ‘Insider Insights’

                                                                                                              In today’s fast-paced IT environment, having a clear view of your remote support activities is more important than ever. Zoho Assist’s Custom Reports feature gives IT teams the ability to generate tailored reports that provide actionable insights and
                                                                                                            • Message "...does not support more than 100 distinct values..." WHY????

                                                                                                              I get this message on one of my reports: Sorry, Zoho Reports currently does not support more than 100 distinct values in columns. 'Account Name * Sum(Amount),Count(Amount Tier)' contains more than 100 distinct values.  Possibly, you can apply filter to reduce the number of distinct values in 'Account Name' or drop the 'Account Name' field in Rows. I want to list all ACCOUNT NAMES (about 500) with SALES BY ACCOUNT.  What is blocking this?
                                                                                                            • Need Easy Way to Update Item Prices in Bulk

                                                                                                              Hello Everyone, In Zoho Books, updating selling prices is taking too much time. Right now we have to either edit items one by one or do Excel export/import. It will be very useful if Zoho gives a simple option to: Select multiple items and update prices
                                                                                                            • Let's Talk Recruit: Super-charge hiring with Zoho Recruit add-ons

                                                                                                              Welcome back to our Let’s Talk Recruit series! This time, we’re diving into something that might seem like a small upgrade but has a huge impact on recruiter productivity: Zoho Recruit add-ons. Think about how much of your day is spent in your inbox or
                                                                                                            • 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.
                                                                                                            • Next Page