Portal APIs in Zoho CRM - Part II

Portal APIs in Zoho CRM - Part II

Hi everyone! Welcome back to another week of Kaizen!

In continuation to our previous post on Portal APIs in Zoho CRM, we will discuss more on user groups and users this week.
Let us consider the case of the automobile industry. In such a case, you may need to give portal access to more than one user type, such as customers, employees, and partners.
With user types, each user will have access to the information that is most relevant to their role. For example, when you give your customers portal access, they can book services, view and update their service schedules. Your partners or employees with portal access can view customer behaviours, sales date, etc. 

Create a User Type via API

Using this API, you can create a user type for a portal you have already created.

Request URL: {api-domain}/crm/v4/settings/portals/<portal_name>/user_type
Request Method: POST
Scope: ZohoCRM.settings.clientportal.ALL/CREATE

Input Keys

 Key
 Description
name : string, mandatory
Name of the user type.
personality_module : string, mandatory
The module api name for which the user type is to be configured.
active : Boolean, optional
Represents whether the user type is active or inactive. The default value is false.
modules : JSONArray, mandatory
The JSON array containing keys that describe the user type's settings for different modules that are linked to the personality module through look up or multi-lookup fields.
modules.layouts.id : Number, mandatory
The layout the user type should be able to access.
modules.permission : key value pairs, mandatory
Boolean key-value pairs that represent the permissions you want the users to have in the module. The possible keys are view, edit, create.
modules.views : JSONObject, mandatory
The custom view or canvas view to display the records for the user type.
modules.id: Number, mandatory
The related module id.
modules.shared_type : String, mandatory
Represents whether the module is a private or public module.
modules.filters : JSONObject,mandatory
Field id, by which the module record can be filtered for the user type.
modules.fields : JSONArray, mandatory
Field permissions for the user type with read_only (Boolean), api_name(field API name) and id of the each field to be configured for the module. Note that if any of the fields in the layout is marked mandatory, they cannot be read-only in the portal.

For example, the following request creates the user type Customer for the ZylkerAutos portal, with view permission to the service module.

Sample Request:

Sample Input:

{
   "user_type":[
      {
         "name":"Customer",
         "personality_module":{
            "api_name":"Customer"
         },
         "active":true,
         "modules":[
            {
               "layouts":[
                  {
                     "id":"1306462000000095055"
                  }
               ],
               "permissions":{
                  "view" : true
               },
               "views":{
                  "id":"1306462000000091501",
                  "type":"custom_view"
               },
               "filters": null,
                fields": [
                 {
                      "id": "18936550000000063924",
                      "read_only": false
                  }
                ],
               "id":"1306462000000000125",
               "shared_type":"private"
            },
            {
               "layouts": null,
                "views": null,
               "filters": null,
               "permissions":{
                  "view":true
               },
               "id":"1306462000000000147",
               "shared_type":"private"
            }
         ]
      }
   ]
}

Sample Response

{
    "user_type": [
        {
            "code": "SUCCESS",
            "details": {
                "id": "1306462000001856005"
            },
            "message": "user type created successfully.",
            "status": "success"
        }
    ]
}

Update User Type via API

Suppose your automobile dealership firm decides to expand your online booking system to allow customers to schedule test drives, in addition to service appointments. In this case, the dealership may need to update the Customer user type to include the ability to book test drives. You can use the Update User Type API to make such updates. 

Request URL : {api-domain}/crm/v4/settings/portals/<portal_name>/user_type/<user_type_id>
Request Method : PUT
Scope : ZohoCRM.settings.clientportal.ALL/UPDATE

Input Keys:

Key Description
name : string, optionalName of the user type.
personality_module : string, optionalThe module api name for which the user type is to be configured.
active : Boolean, optionalRepresents whether the user type is active or inactive. The default value is false.
modules : JSONArray, optional
The JSON array containing keys that describe the user type's settings for different modules that are linked to the personality module through look up or multi-lookup fields.
modules.layouts.id : Number, optionalThe layout the user type should be able to access.
modules.permission : key value pairs, optional
Boolean key-value pairs that represent the permissions you want the users to have in the module. The possible keys are view, edit, create.
modules.views : JSONObject, optional
The custom view or canvas view to display the records for the user type.
modules.id: Number, optional
The related module id.
modules.shared_type : String, optional
Represents whether the module is a private or public module.
modules.filters : JSONObject, optional
Field id, by which the module record can be filtered for the user type.
modules.fields : JSONArray, optional
Field permissions for the user type with read_only (Boolean), api_name(field API name) and id of the each field to be configured for the module. Note that if any of the fields in the layout is marked mandatory, they cannot be read-only in the portal.

For example, the following request updates the Customer user type's access to the Service module.

Sample Request

https://www.zohoapis.com/crm/v4/settings/portals/ZylkerAutos/user_type/1306462000001856005

Sample Input

{
   "user_type":[
      {
         "modules":[
            {
               "permissions":{
                  "edit":true,
                  "create":true
               },
               "id":"1306462000000000125",
               "shared_type":"private"
            }
         ]
      }
   ]
}

Sample Response

{
    "user_type": [
        {
            "code": "SUCCESS",
            "details": {
                "id": "1306462000001856005"
            },
            "message": "Portal user type updated successfully.",
            "status": "success"
        }
    ]
}

Delete User Type via API

Let us consider the case where your company had a user type for suppliers in its portal but has decided to handle supplier management through a separate system. In this case, you would need to delete the supplier user type from the portal to simplify user management and ensure that only the necessary users have access to the portal. 

Request URL: {api-domain}/crm/v4/settings/portals/<portal_name>/user_type/<user_type_id>
Request Method: DELETE
Scope: ZohoCRM.settings.clientportal.ALL/DELETE

For example, the following request deletes the supplier user type from the ZylkerAutos portal.

Sample Request

Sample Response

{
    "user_type": [
        {
            "code": "SUCCESS",
            "details": {
                "id": 1306462000001857564
            },
            "message": "Portal user type deleted successfully.",
            "status": "success"
        }
    ]
}

Please note that you cannot delete a user type with users. You should transfer the users to another portal before deleting the user type.

Transfer User to another User Type

There may be scenarios where you have to transfer a user from one user type to another. For instance, if a customer is upgraded to premium level which offers additional services, you might need to transfer the customer to a new user type that includes these features. Also, if you ever have to delete a user type, you need to transfer the users in that user type to another one. 

Request URL: {api-domain}/crm/v4/settings/portals/<portal_name>/user_type/<user_type_id>/users/action/transfer
Request Method: POST
Scope: ZohoCRM.settings.clientportal.ALL/UPDATE

Parameters

Parameter
Description
transfer_to : string, mandatory
The id of the user type to which you want to transfer the users.
personality_ids : string, mandatory
comma separated list of ids of the users you want to transfer.

Sample Request

Sample Response

{
    "users": [
        {
            "code": "SUCCESS",
            "details": {
                "personality_id": "1306462000000659009"
            },
            "message": "User has been transferred successfully",
            "status": "success"
        }
    ]
}

You can transfer up to 200 users in one API call. If there are more than 200 users to be transferred, a job will be scheduled.

Change Status of a User 

If you want to change the activate or deactivate a user, you can do so using this API.

Request URL: {api-domain}/crm/v4/settings/portals/<portal_name>/user_type/<user_type_id>/users/<user_id>/actions/change_status
Request Method: PUT
Scope: ZohoCRM.settings.clientportal.ALL/UPDATE

Parameters

Parameter
Description
active : Boolean, mandatory
To mention whether to activate or deactivate the user.

The following request changes the status of the user to inactive.

Sample Request

Sample Response

{
    "change_status": [
        {
            "code": "SUCCESS",
            "details": {
                "personality_id": "1306462000000665004"
            },
            "message": "Status of the user changed successfully.",
            "status": "success"
        }
    ]
}

Delete User from Portal

There may be times when you want to delete a user from a portal to prevent unauthorized access. You may use the Delete User from Portal API to do this.

Request URL: {api-domain}/crm/v4/settings/portals/<portal_name>/user_type/<user_type_id>/users
Request Method: DELETE
Scope: ZohoCRM.settings.clientportal.ALL/DELETE

Parameters

ParameterDescription
personality_ids : string, mandatoryComma separated ids of the users you want to delete from the portal.

Sample Request

Sample Response

{
    "users": [
        {
            "code": "SUCCESS",
            "details": {
                "personality_id": "1306462000000659009"
            },
            "message": "Portal user deleted successfully.",
            "status": "success"
        }
    ]
}

Please note you can delete up to 499 users from a portal synchronously. If you want to delete 500 or more users, a delete job will be scheduled.

We hope you found this post useful, and that it has given you a better understanding of the Portal APIs. See you next week with another useful topic.

If you have any questions or feedback, please let us know in comments below, or write to us at support@zohocrm.com. We would love to hear from you!


    Access your files securely from anywhere

        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 Campaigns 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