Kaizen 141 Zoho CRM's API Collection in Postman

Kaizen 141 Zoho CRM's API Collection in Postman

Hello everyone!
Welcome back to another week of Kaizen!

In today's post, we will discuss:
  1. What is Postman?
  2. Zoho CRM's API Collection in Postman
  3. Where is it available?
  4. Prerequisites for using the collection
  5. Forking the API Collection from Zoho CRM Developer Workspace
  6. Setting up the environment
  7. Registering a Client in Zoho API Console
  8. Generating tokens
  9. Making an API call
  10. A quick alternative to token generation using Guided Auth

1. What is Postman?

  • A popular tool for API development and testing.
  • User-friendly interface for making API requests, viewing responses, and managing different environments.

2. Zoho CRM's API Collection in Postman

  • Boilerplate requests that you can use to test and explore the CRM APIs in various environments for multiple organizations.
  • Makes the process of exploring APIs swift and effortless. It also significantly reduces the risk of errors.

3. Where is it available?

The Zoho CRM API Collection is available in Zoho CRM Developers workspace in Postman.

4. Prerequisites for using the Collection

  • A Zoho CRM account to access the Zoho API Console.
  • A registered client (self-client/web-based) to generate an org-specific grant token.

5. Forking the API Collection from Zoho CRM Developer Workspace

  1. Download and install Postman.
  2. In the Postman app, click the search icon at the top bar and type Zoho CRM Developers. The Zoho CRM Developers Workspace opens.
  3. Click Collections on the left bar.
  4. Click the more actions icon.
  5. Click Create a Fork.
  6. Give a name to your collection, and choose the workspace you want to save it to.
  7. You can select one or more environments to fork and pin to the collection.
  8. Click Fork Collection. Forking will happen in the background.


6. Setting up the environment

An environment is a group of variables that you can reuse in API requests and scripts.
  1. Click Environments on the left bar.
  2. Click Create Environment and give it a name.
  3. Under Variable, add the following variables:
    client-id
    client-secret
    redirect-uri
    authorization-code
    access-token
    refresh-token
    accounts-url
    api-domain
    expiry-time


7. Registering a client in Zoho API Console

For your app to be able to use users' data in Zoho CRM across multiple orgs, you must register your app as a client in Zoho CRM.
In this post, we have used Self Client as the client type. For details about when to choose between a self-client and web-based client, refer to this Kaizen post.
  1. Go to Zoho API Console.
  2. Click Add Client.
  3. Choose Self Client from the list of client types and click Create Now.
  4. You will see the client ID and client secret.


8. Generating the tokens for a self client

Zoho CRM APIs follow the OAuth2.0 protocol for authentication.
This involves three tokens viz, grant token(authorization code), access token and refresh token.
  • Grant token - Also called the authorization code, for a self client, this token is generated in the API console itself. This token informs Zoho's authorization server(Zoho Accounts) that your app wants to access Zoho CRM users' data(bound by scopes). This token is environment-specific, i.e, if you choose a production org while generating this token, you can access Zoho CRM data in the production environment only. This token is valid from 3 minutes to 10 minutes based on what you choose in the console.
  • Access token - After you have authenticated your app and generated a grant token, you must exchange it with Zoho Accounts for an access token. This access token will also have the same scopes as your grant token. This token is valid for one hour. You must send this token in the header of every API call as a bearer token.
  • Refresh token - Since the access token is valid only for an hour, you can use the refresh token to generate a new access token. Instead of creating a grant token again for the same scopes and generating another access token, you can directly use the refresh token and get a new access token with the same scope. Refresh token is valid until you revoke it.
Let's see how to generate these tokens.



Creating the grant token is a one-time process. After you generate access and refresh tokens using the grant token, you can simply use the refresh token to create new access token every hour.

9. Making an API call

Now that we have generated the tokens, let's make an API call using the access token.
  1. Navigate to V6 > REST APIs > Records > Get Records > Accounts.
  2. You can see the request with a few fields already in place.
  3. Modify the parameters as required.
  4. Under Auth, you can see the variable {{access-token}} that holds the access token we generated earlier.
  5. Hit Send to get a response.


10. A quick alternative to token generation using Guided Auth

Postman has introduced a new flow called the Guided Auth. This method allows new users to acquaint themselves with making API calls and testing them, without the hassIe of setting up a client.
In this flow, Zoho acts as the client and takes care of generating the grant and access tokens for a set of pre-defined scopes.
Follow these steps to use Guided Auth.
  1. Click Set Up New Authorization in Postman.
  2. Click Authorize. You will be redirected to Zoho's Login page.
  3. Sign in to your Zoho account.
  4. Choose the org for which you want to generate the token.
  5. Click Agree on the consent screen to grant permission to use your Zoho CRM data as per the scopes on the screen.
In the backend, Zoho generates the grant and access tokens, and you will see the access token in your Postman instance under Auth Credentials.
Note that flow does not give you a refresh token. This method is only to get a head-start with APIs without facing authorization errors. As always, the access token is valid for an hour, after which you have to follow the process of authorizing Zoho to generate another token.



As you can see, when you use our API collection, making API calls to Zoho CRM is a piece of cake as all the requests are already in place with examples.


We hope you found this post useful. We'll meet you next week with another interesting post!
Let us know your feedback in the comment section or write to us at support@zohocrm.com.
Cheers!


      Zoho Developer Community









                                Zoho Desk Resources

                                • Desk Community Learning Series


                                • Digest


                                • Functions


                                • Meetups


                                • Kbase


                                • Resources


                                • Glossary


                                • Desk Marketplace


                                • MVP Corner


                                • Word of the Day



                                    Zoho Marketing Automation


                                            Manage your brands on social media



                                                  Zoho TeamInbox Resources

                                                    Zoho DataPrep Resources



                                                      Zoho CRM Plus Resources

                                                        Zoho Books Resources


                                                          Zoho Subscriptions Resources

                                                            Zoho Projects Resources


                                                              Zoho Sprints Resources


                                                                Qntrl Resources


                                                                  Zoho Creator Resources



                                                                    Zoho WorkDrive Resources



                                                                      Zoho Campaigns Resources


                                                                        Zoho CRM Resources

                                                                        • CRM Community Learning Series

                                                                          CRM Community Learning Series


                                                                        • Tips

                                                                          Tips

                                                                        • 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