Users APIs
In Zoho Vertical Solutions, the user is the one who is allowed to access and manage your organization records. These users can be defined under various profiles and categories such as Administrators, Standard, etc,.
Using the Users APIs, you can retrieve the basic information of your available Vertical Solutions users. Use the type parameter to get the required list of users. For example, you can set the param type as AdminUsers, to get the list of users with Administrative profile. The detailed explanation of the Users API and the examples are shown below:
Get Users
Purpose
To retrieve the users' data specified in the API request. You can specify the type of users that needs to be retrieved using the Users API. For example, use type=AllUsers, to get the list of all the users available.
Endpoints
Request Details
Request URL
https://{{your-domain}}.zohoplatform.com/crm/v2/users
To get a specific user:
https://{{your-domain}}.zohoplatform.com/crm/v2/users/{user_id}
Header
Authorization: Zoho-oauthtoken 100xx.d92d4xxxxxxxxxxxxx15f52
If-Modified-Since: Use this header to get the list of recently modified users. Example: 2019-07-25T15:26:49+05:30
Scope
scope=ZohoCRM.users.{operation_type}
Possible operation types
ALL - Full access to users
READ - Get user data
Parameters
- typestring, optionalSpecify the type of the users you want to retrieve. - AllUsers - To list all users in your organization (both active and inactive users).
- ActiveUsers - To get the list of all the Active Users.
- DeactiveUsers - To get the list of all the users who were deactivated.
- ConfirmedUsers - To get the list of all the confirmed users.
- NotConfirmedUsers - To get the list of all the non-confirmed users.
- DeletedUsers - To get the list of deleted users.
- ActiveConfirmedUsers - To get the list of active users who are also confirmed.
- AdminUsers - To get the list of admin users.
- ActiveConfirmedAdmins - To get the list of active users with the administrative privileges and are also confirmed.
- CurrentUser - To get the current user.
 
- pageinteger, optionalTo get the list of user records from the respective pages. Default value is 1. 
- per_pageinteger, optionalTo set the number of user records to be retrieved per page. The default and the maximum possible value is 200. 
- idsstring, optionalRepresents the unique ID of the users. You can specify up to 100 user IDs. 
- The page and per_page parameter are used to fetch user records according to their position in the Vertical Solutions. Let us assume that the user has to fetch 400 user records. The maximum number of user records that one can get for an API call is 200. So, for the user records above the 200th position, they cannot be fetched. By using the page (1 and 2) and per_page (200) parameter, the user can fetch all 400 user records using 2 API calls. 
Sample Request
Copiedcurl "https://zylkercorp.zohoplatform.com/crm/v2/users?type=AllUsers"
-X GET
-H "Authorization: Zoho-oauthtoken 100xx.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"Copied//Get instance of UsersOperations Class
let usersOperations = new ZCRM.User.Operations();
//Get instance of ParameterMap Class
let paramInstance = new ParameterMap();
/* Possible parameters for Get Users operation */
await paramInstance.add(ZCRM.User.Model.GetUsersParam.TYPE, "ActiveUsers");
await paramInstance.add(ZCRM.User.Model.GetUsersParam.PAGE, 1);
await paramInstance.add(ZCRM.User.Model.GetUsersParam.PER_PAGE, 200);
//Get instance of HeaderMap Class
let headerInstance = new HeaderMap();
/* Possible headers for Get Users operation */
await headerInstance.add(ZCRM.User.Model.GetUsersHeader.IF_MODIFIED_SINCE, new Date("2019-07-07T10:00:00+05:30"));
//Call getUsers method that takes ParameterMap instance and HeaderMap instance as parameters
let response = await usersOperations.getUsers(paramInstance, headerInstance);Copiedvar listener = 0;
class UsersAPIs {
	async getUsers()	{
		var url = "https://zylkercorp.zohoplatform.com/crm/v2/users"
        var parameters = new Map()
        var headers = new Map()
        var token = {
            clientId:"1000.NPY9M1V0XXXXXXXXXXXXXXXXXXXF7H",
            redirectUrl:"http://127.0.0.1:5500/redirect.html",
            scope:"ZohoCRM.users.ALL,ZohoCRM.bulk.read,ZohoCRM.modules.ALL,ZohoCRM.settings.ALL,Aaaserver.profile.Read,ZohoCRM.org.ALL,profile.userphoto.READ,ZohoFiles.files.ALL,ZohoCRM.bulk.ALL,ZohoCRM.settings.variable_groups.ALL"
        }
        var accesstoken = await new UsersAPIs().getToken(token)
        headers.set("Authorization", "Zoho-oauthtoken " + accesstoken)
        headers.set("If-Modified-Since", "2020-05-15T12:00:00+05:30")
        parameters.set("type", "ActiveUsers")
        parameters.set("page", "1")
        parameters.set("per_page", "2")
        var requestMethod = "GET"
        var reqBody = null
        var params = "";
        parameters.forEach(function(value, key) {
            if (parameters.has(key)) {
                if (params) {
                    params = params + key + '=' + value + '&';
                }
                else {
                    params = key + '=' + value + '&';
                }
            }
        });
        var apiHeaders = {};
        if(headers) {
            headers.forEach(function(value, key) {
                apiHeaders[key] = value;
            });
        }
        if (params.length > 0){
            url = url + '?' + params.substring(0, params.length - 1);
        }
        var requestObj = {
            uri : url,
            method : requestMethod,
            headers : apiHeaders,
            body : JSON.stringify(reqBody),
            encoding: "utf8",
            allowGetBody : true,
			throwHttpErrors : false
        };
        var result = await new UsersAPIs().makeAPICall(requestObj);
        console.log(result.status)
        console.log(result.response)
    }
	async getUser()	{
		var url = "https://zylkercorp.zohoplatform.com/crm/v2/users/35240336182001"
        var parameters = new Map()
        var headers = new Map()
        var token = {
            clientId:"1000.NPY9M1V0XXXXXXXXXXXXXXXXXXXF7H",
            redirectUrl:"http://127.0.0.1:5500/redirect.html",
            scope:"ZohoCRM.users.ALL,ZohoCRM.bulk.read,ZohoCRM.modules.ALL,ZohoCRM.settings.ALL,Aaaserver.profile.Read,ZohoCRM.org.ALL,profile.userphoto.READ,ZohoFiles.files.ALL,ZohoCRM.bulk.ALL,ZohoCRM.settings.variable_groups.ALL"
        }
        var accesstoken = await new UsersAPIs().getToken(token)
        headers.set("Authorization", "Zoho-oauthtoken " + accesstoken)
        headers.set("If-Modified-Since", "2019-05-15T12:00:00+05:30")
        var requestMethod = "GET"
        var reqBody = null
        var params = "";
        parameters.forEach(function(value, key) {
            if (parameters.has(key)) {
                if (params) {
                    params = params + key + '=' + value + '&';
                }
                else {
                    params = key + '=' + value + '&';
                }
            }
        });
        var apiHeaders = {};
        if(headers) {
            headers.forEach(function(value, key) {
                apiHeaders[key] = value;
            });
        }
        if (params.length > 0){
            url = url + '?' + params.substring(0, params.length - 1);
        }
        var requestObj = {
            uri : url,
            method : requestMethod,
            headers : apiHeaders,
            body : JSON.stringify(reqBody),
            encoding: "utf8",
            allowGetBody : true,
			throwHttpErrors : false
        };
        var result = await new UsersAPIs().makeAPICall(requestObj);
        console.log(result.status)
        console.log(result.response)
	}
    async getToken(token) {
        if(listener == 0) {
            window.addEventListener("storage", function(reponse) {
                if(reponse.key === "access_token" && (reponse.oldValue != reponse.newValue || reponse.oldValue == null)){
                    location.reload();
                }
                if(reponse.key === "access_token"){
                    sessionStorage.removeItem("__auth_process");
                }
            }, false);
            listener = 1;
            if(sessionStorage.getItem("__auth_process")) {
                sessionStorage.removeItem("__auth_process");
            }
        }
        ["granted_for_session", "access_token","expires_in","expires_in_sec","location","api_domain","state","__token_init","__auth_process"].forEach(function (k) {
            var isKeyExists = localStorage.hasOwnProperty(k);
            if(isKeyExists) {
                sessionStorage.setItem(k, localStorage[k]);
            }
            localStorage.removeItem(k);
        });
        var valueInStore = sessionStorage.getItem("access_token");
        var tokenInit = sessionStorage.getItem("__token_init");
        if(tokenInit != null && valueInStore != null && Date.now() >= parseInt(tokenInit) + 59 * 60 * 1000){ // check after 59th minute
            valueInStore = null;
            sessionStorage.removeItem("access_token");
        }
        var auth_process = sessionStorage.getItem("__auth_process");
        if ((valueInStore == null && auth_process == null) || (valueInStore == 'undefined' && (auth_process == null || auth_process == "true"))) {
            var accountsUrl = "https://accounts.zoho.com/oauth/v2/auth"
            var clientId;
            var scope;
            var redirectUrl;
            if(token != null) {
                clientId = token.clientId;
                scope = token.scope;
                redirectUrl = token.redirectUrl;
            }
            var fullGrant = sessionStorage.getItem("full_grant");
            var grantedForSession = sessionStorage.getItem("granted_for_session");
            if(sessionStorage.getItem("__token_init") != null && ((fullGrant != null && "true" == full_grant) || (grantedForSession != null && "true" == grantedForSession))) {
                accountsUrl += '/refresh';
            }
            if (clientId && scope) {
                sessionStorage.setItem("__token_init", Date.now());
                sessionStorage.removeItem("access_token");
                sessionStorage.setItem("__auth_process", "true");
                window.open(accountsUrl + "?" + "scope" + "=" + scope + "&"+ "client_id" +"=" + clientId + "&response_type=token&state=zohocrmclient&redirect_uri=" + redirectUrl);
                ["granted_for_session", "access_token","expires_in","expires_in_sec","location","api_domain","state","__token_init","__auth_process"].forEach(function (k) {
                    var isKeyExists = localStorage.hasOwnProperty(k);
                    if(isKeyExists){
                        sessionStorage.setItem(k, localStorage[k]);
                    }
                    localStorage.removeItem(k);
                });
                valueInStore = sessionStorage.getItem("access_token");
            }
        }
        if(token != null && valueInStore != 'undefined'){
            token.accessToken = valueInStore;
        }
        return token.accessToken;
    }
    async makeAPICall(requestDetails) {
        return new Promise(function (resolve, reject) {
            var body, xhr, i;
            body = requestDetails.body || null;
            xhr = new XMLHttpRequest();
            xhr.withCredentials = true;
            xhr.open(requestDetails.method, requestDetails.uri, true);
            for (i in requestDetails.headers) {
                xhr.setRequestHeader(i, requestDetails.headers[i]);
            }
            xhr.send(body);
            xhr.onreadystatechange = function() {
                if(xhr.readyState == 4) {
                    resolve(xhr);
                }
            }
        })
    }
}Copiedresponse = invokeurl
[
	url: "https://zylkercorp.zohoplatform.com/crm/v2/users"
	type: GET
	connection:"crm_oauth_connection"
];
info response;Response JSON Keys
- country, city, street, state, country_locale, zipstringRepresents the address of the user. 
- roleJSON objectRepresents the name and ID of the role of the user. 
- localestringRepresents the user's locale. For instance, 'en_IN'. 
- Modified_ByJSON objectRepresents the name and ID of the user who last modified the user's details. 
- CurrencystringRepresents the user's currency preference. 
- aliasstringRepresents the alias name of the user. 
- idstringRepresents the unique ID of the user. 
- fax, email, mobile, phonestringRepresents the contact details of the user. 
- first_namestringRepresents the first name of the user. 
- Reporting_ToJSON objectRepresents the name and ID of the user to whom the user reports to. 
- created_timestringRepresents the date and time at which the user was created. 
- websitestringRepresents the user's website details. 
- Modified_TimestringRepresents the date and time at which the user's details were last modified. 
- profileJSON objectRepresents the name and ID of the profile of the user. 
- last_namestringRepresents the last name of the user. 
- time_zonestringRepresents the current user's timezone. 
- created_byJSON objectRepresents the name and ID of the user who created the user. 
- zuidstringRepresents the ZUID of the current user. 
- confirmbooleanRepresents if the user is a confirmed user. 
 true: The user is a confirmed user.
 false: The user is not a confirmed user.
- full_namestringRepresents the full name of the user in the format specified in "name_format" key. 
- territoriesJSON arrayEach object in the array represents the details the user's territory. 
- dobstringRepresents the date of birth of the user. 
- date_formatstringRepresents the date format. For instance, 'MM/dd/yyyy'. 
- time_formatstringRepresents the time format. For instance, 'hh:mm a'. 
- statusstringRepresents the status of the user. 
 active: The user is active.
 inactive: The user is inactive.
- signaturestringRepresents the user's signature. 
- name_formatstringRepresents the format of the full_name of the user. For instance, 'Salutation,First Name,Last Name'. 
- languagestringRepresents the language in which the user accesses Vertical Solutions. For instance, 'en_US'. 
- microsoftbooleanRepresents if the user is a microsoft user. 
 true: The user is a microsoft user.
 false: The user is a microsoft user.
- personal_accountbooleanRepresents if the user is the only user in the organization. 
 true: The user is the only user in the organization.
 false: The user is not the only user in the organization.
- IsonlinebooleanRepresents if the user is online. 
 true: The user is online.
 false: The user is offline.
- themeintegerRepresents the details of the theme selected by the user. 
Possible Errors
- INVALID_URL_PATTERNHTTP 404Please check if the URL trying to access is a correct one 
 Resolution: The request URL specified is incorrect. Specify a valid request URL. Refer to request URL section above.
- OAUTH_SCOPE_MISMATCHHTTP 401Unauthorized 
 Resolution: Client does not have ZohoCRM.users.READ scope. Create a new client with valid scope. Refer to scope section above.
- NO_PERMISSIONHTTP 403Permission denied to read 
 Resolution: The user does not have permission to read user records. Contact your system administrator.
- INTERNAL_ERRORHTTP 500Internal Server Error 
 Resolution: Unexpected and unhandled exception in the server. Contact support team.
- INVALID_REQUEST_METHODHTTP 400The http request method type is not a valid one 
 Resolution: You have specified an invalid HTTP method to access the API URL. Specify a valid request method. Refer to endpoints section above.
- AUTHORIZATION_FAILEDHTTP 400User does not have sufficient privilege to read users 
 Resolution: The user does not have the permission to read users. Contact your system administrator.
- PATTERN_NOT_MATCHEDHTTP 400Please check whether the input values are correct 
 Resolution: The value specified for the 'type' parameter is incorrect. Refer to parameters section above and specify valid parameter value.
Sample Response
Copied{
  "users": [
    {
      "country": "US",
      "customize_info": {
        "notes_desc": null,
        "show_right_panel": null,
        "bc_view": null,
        "show_home": false,
        "show_detail_view": true,
        "unpin_recent_item": null
      },
      "role": {
        "name": "CEO",
        "id": "4150868000000026005"
      },
      "signature": "<div><a id=\"link\" href=\"https://crm.zoho.com/bookings/ProjectDemo?rid=4b1b5d511ac5628eb3045495192827cc7f2f04de31c657e50f194521b21a27f5gid25837b76288d7b127a3faccd84a936702ba8ac270b0949d1521e82e1a251c1e5\" target=\"_blank\">Patricia Boyle</a></div>",
      "city": null,
      "name_format": "Salutation,First Name,Last Name",
      "language": "en_US",
      "locale": "en_US",
      "microsoft": false,
      "personal_account": false,
      "default_tab_group": "0",
      "Isonline": true,
      "Modified_By": {
        "name": "Patricia Boyle",
        "id": "4150868000000225013"
      },
      "street": null,
      "Currency": "DZD",
      "alias": null,
      "theme": {
        "normal_tab": {
          "font_color": "#FFFFFF",
          "background": "#222222"
        },
        "selected_tab": {
          "font_color": "#FFFFFF",
          "background": "#222222"
        },
        "new_background": null,
        "background": "#F3F0EB",
        "screen": "fixed",
        "type": "default"
      },
      "id": "4150868000000225013",
      "state": "Tamil Nadu",
      "fax": null,
      "country_locale": "US",
      "first_name": "Patricia",
      "email": "patricia.b@zylker.com",
      "Reporting_To": null,
      "decimal_separator": "en_IN",
      "zip": null,
      "created_time": "2019-08-20T11:21:16+05:30",
      "website": "www.zylker.com",
      "Modified_Time": "2020-07-14T18:30:01+05:30",
      "time_format": "hh:mm a",
      "offset": 19800000,
      "profile": {
        "name": "Administrator",
        "id": "4150868000000026011"
      },
      "mobile": null,
      "last_name": "Boyle",
      "time_zone": "Asia/Calcutta",
      "created_by": {
        "name": "Patricia Boyle",
        "id": "4150868000000225013"
      },
      "zuid": "694579958",
      "confirm": true,
      "full_name": "Patricia Boyle",
      "territories": [
        {
          "manager": true,
          "name": "Zylker",
          "id": "4150868000000236307"
        }
      ],
      "phone": null,
      "dob": null,
      "date_format": "MM/dd/yyyy",
      "status": "active"
    },
    {
      "country": null,
      "role": {
        "name": "Sales department Head",
        "id": "4150868000000231921"
      },
      "city": null,
      "language": "en_US",
      "locale": "en_US",
      "microsoft": false,
      "Isonline": false,
      "Modified_By": {
        "name": "Patricia Boyle",
        "id": "4150868000000225013"
      },
      "street": null,
      "Currency": "DZD",
      "alias": null,
      "id": "4150868000000231929",
      "state": null,
      "fax": null,
      "country_locale": "US",
      "first_name": "Jack",
      "email": "jack.s@zylker.com",
      "Reporting_To": null,
      "zip": null,
      "created_time": "2019-08-20T12:39:23+05:30",
      "website": null,
      "Modified_Time": "2020-07-14T18:30:01+05:30",
      "time_format": "hh:mm a",
      "offset": 19800000,
      "profile": {
        "name": "Administrator",
        "id": "4150868000000026011"
      },
      "mobile": null,
      "last_name": "Smith",
      "time_zone": "Asia/Calcutta",
      "created_by": {
        "name": "Patricia Boyle",
        "id": "4150868000000225013"
      },
      "zuid": null,
      "confirm": false,
      "full_name": "Jack Smith",
      "territories": [],
      "phone": null,
      "dob": null,
      "date_format": "MM/dd/yyyy",
      "status": "disabled"
    },
    {
      "country": null,
      "role": {
        "name": "Sales rep",
        "id": "4150868000000231917"
      },
      "city": null,
      "language": "en_US",
      "locale": "en_US",
      "microsoft": false,
      "Isonline": false,
      "Modified_By": {
        "name": "Patricia Boyle",
        "id": "4150868000000225013"
      },
      "street": null,
      "Currency": "DZD",
      "alias": null,
      "id": "4150868000000252644",
      "state": null,
      "fax": null,
      "country_locale": "US",
      "first_name": "Jane",
      "email": "Jane.J@zylker.com",
      "Reporting_To": null,
      "zip": null,
      "created_time": "2019-08-22T15:02:16+05:30",
      "website": null,
      "Modified_Time": "2020-07-14T18:30:01+05:30",
      "time_format": "hh:mm a",
      "offset": 19800000,
      "profile": {
        "name": "Administrator",
        "id": "4150868000000026011"
      },
      "mobile": null,
      "last_name": "J",
      "time_zone": "Asia/Kolkata",
      "created_by": {
        "name": "Patricia Boyle",
        "id": "4150868000000225013"
      },
      "zuid": null,
      "confirm": false,
      "full_name": "Jane J",
      "territories": [
        {
          "manager": false,
          "name": "Sample Territory",
          "id": "4150868000000264087"
        }
      ],
      "phone": null,
      "dob": null,
      "date_format": "MM/dd/yyyy",
      "status": "disabled"
    }
  ],
  "info": {
    "per_page": 200,
    "count": 3,
    "page": 1,
    "more_records": false
  }
}