Update User

Purpose

To update the details of a user of your organization.

Request URL

https://www.zohoapis.com/crm/v2/users

Request Method

PUT

Scope

scope=ZohoCRM.users.ALL
(or)
scope=ZohoCRM.users.UPDATE

Possible operation types
ALL - Full access to data
UPDATE - Update user data
Note:

You can update only one user's details per request.

Request JSON

AttributeData TypeMandatoryDescription
IDStringYesThe record ID of the user you want to update.
Note:
  • You can also pass the record ID in the request. Example: {{api-domain}}/crm/v2/users/{{record_id}}

  • Refer to Get User API to obtain the record ID of the user.

  • You cannot update a deactivated user.

  • You cannot deactivate the primary contact of your organization. To deactivate the primary contact, you must assign another user as the new primary contact of your organization and then deactivate the old primary contact.

  • To activate or deactivate a user, use the key status in the input with the value as either active or deactive.

  • You cannot change the time zone of another user. You can only change the time zone of your own user record. Refer to Fields Metadata API to know the values of the key "time_zone".

  • You must use only Field API names in the input. You can obtain the field API names from Fields metadata API (the value for the key “api_name” for every field).

Possible Errors

HTTP StatusError CodeMessageReason
200INVALID_DATACannot update the time_zone of another UserYou cannot update the time zone of another user.
400authorization_failedEither trial has expired or user does not have sufficient privilege to perform this actionCRM trial has expired or the user does not have permission to add another user.
400internal_errorError occurred while updating CRMPlus User in CRM Accountyou cannot update a CRM Plus user from your CRM account.
400invalid_datainvalid_dataThe data you have provided is invalid.
400invalid_datainvalid_dataUnclosed Script tags found in signature
400cannot_update_deleted_userDeleted user cannot be updatedThe user you want to update was deleted.
400invalid_requestRe-invite is not allowed for a confirmed userYou cannot invite an already confirmed user to join your organization.
400email_update_not_allowedCannot update email of a confirmed CRM UserYou cannot update the email of a confirmed user.
400duplicate_dataUser with same email id is already in CRM PlusThe user you are trying to update has an account in CRM Plus.
400id_already_deactivatedUser is already deactivatedThe user you are trying to update is already deactivated.
400invalid_requestPrimary Contact cannot be deactivatedThe user you are trying to deactivate is the primary contact of your organization and cannot be deactivated.
400id_already_activeUser is already activeThe user you are trying to activate is already active.
400feature_permissionShare among Subordinates Feature is not availableThe user you are trying to activate is already active.
405authorization_failedProfile and Role cannot be Updated by the userThe current user does not have permission to update the profile and role of another user.

Sample Request

Copiedcurl "https://www.zohoapis.com/crm/v2/users"
-X PUT
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
Copiedimport java.util.List;

import com.zoho.crm.library.api.APIConstants;
import com.zoho.crm.library.api.response.APIResponse;
import com.zoho.crm.library.api.response.BulkAPIResponse;
import com.zoho.crm.library.common.ZCRMEntity;
import com.zoho.crm.library.crud.ZCRMOrgTax;
import com.zoho.crm.library.crud.ZCRMTax;
import com.zoho.crm.library.setup.metadata.ZCRMOrganization;
import com.zoho.crm.library.setup.restclient.ZCRMRestClient;
import com.zoho.crm.library.setup.users.ZCRMProfile;
import com.zoho.crm.library.setup.users.ZCRMRole;
import com.zoho.crm.library.setup.users.ZCRMUser;
import com.zoho.oauth.client.ZohoOAuthClient;
import com.zoho.oauth.contract.ZohoOAuthTokens;

public class Org{
	public Org() throws Exception{
		ZCRMRestClient.initialize();
	}
	public void updateUser() throws Exception{
		ZCRMRestClient client = ZCRMRestClient.getInstance();
		ZCRMUser user=ZCRMUser.getInstance(554023000000691003L);//554023000000691003L is user id
		user.setFirstName("firstname");
		user.setFullName("firstname lastname");
		user.setLastName("lastname");
	
		ZCRMOrganization org=client.getOrganizationInstance();
		APIResponse response=org.updateUser(user);
		System.out.println("HTTP status code "+response.getStatusCode());
		System.out.println("Status "+response.getStatus());
		System.out.println("message "+response.getMessage());
	}
	public static void main(String[] args) throws Exception {
		Org obj=new Org();
		obj.updateUser();
	}
}
 
Copied# Update user
# -----------
def update_user(self):
    try:
        user_ins = zcrmsdk.ZCRMUser.get_instance(554023000000691003, 'Boyle') # user id and user name
        user_ins.first_name = "Patricia"
        resp = zcrmsdk.ZCRMOrganization.get_instance().update_user(user_ins)
        print(resp.status_code)
        print(resp.message)
        print(resp.code)
        print(resp.status)
        print(resp.details)
        print(resp.data)
    except zcrmsdk.ZCRMException as ex:
        print(ex.status_code)
        print(ex.error_message)
        print(ex.error_code)
        print(ex.error_details)
        print(ex.error_content)
 
Copied<?php
use zcrmsdk\crm\setup\restclient\ZCRMRestClient;
use zcrmsdk\crm\setup\users\ZCRMProfile;
use zcrmsdk\crm\setup\users\ZCRMRole;
use zcrmsdk\crm\setup\users\ZCRMUser;
require 'vendor/autoload.php';
class Org{
    public function __construct()
    {
            $configuration = array("client_id"=>{client_id},"client_secret"=>{client_secret},"redirect_uri"=>{redirect_url},"currentUserEmail"=>{user_email_id});
            ZCRMRestClient::initialize($configuration);
    }
    public function updateUser(){
        $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
        $user=ZCRMUser::getInstance("{user_id}", "{user_name}");//to get the user instance
        $user->setId("{user_id}");//to set the id of the user
        $user->setFax("321432423423");//to set the fax number of the user
        $user->setMobile("4234234232");//to set the mobile number of the user
        $user->setPhone("2342342342");//to set the phone number of the user
        $user->setStreet("sddsfdsfd");//to set the street name of the user
        $user->setAlias("test");//to set the alias of the user
        $user->setWebsite("www.zoho.com");//to set the website of the user
        $user->setCity("chennai");//to set the city of the user
        $user->setCountry("India");//to set the country of the user
        $user->setState("Tamil nadu");//to set the state of the user
        $user->setZip("6000010");//to set the zip code of the user
        $responseIns=$orgIns->updateUser($user);//to update the user
        echo "HTTP Status Code:".$responseIns->getHttpStatusCode(); //To get http response code
        echo "Status:".$responseIns->getStatus(); //To get response status
        echo "Message:".$responseIns->getMessage(); //To get response message
        echo "Code:".$responseIns->getCode(); //To get status code
        echo "Details:".json_encode($responseIns->getDetails());
    }
}
    $obj =new Org();
    $obj->updateUser();
 
Copied/** To update user */
public void UpdateUser()
{
    ZCRMUser user = ZCRMUser.GetInstance(554023000000691003);//user id
    ZCRMOrganization OrgInstance = ZCRMRestClient.GetInstance().GetOrganizationInstance();
    user.Country = "US";
    user.Role = ZCRMRole.GetInstance(554023000000015969, "Manager");
    user.City = "Chennai";
    user.Street = "street";
    user.Alias = "alias";
    user.State = "state";
    user.Fax = "fax";
    user.CountryLocale = "en_US";
    user.FirstName = "TEST";
    user.Zip = "zip";
    user.Website = "https://www.zoho.com";
    user.Profile = ZCRMProfile.GetInstance(554023000000015975, "Standard");
    user.Mobile = "95851535";
    user.Phone = "0980911111";
    user.DateOfBirth = "1995-05-05";
    user.DateFormat = "MM/dd/yyyy";

    user.SetFieldValue("FieldApiName", "FieldApiValue");
    APIResponse response = OrgInstance.UpdateUser(user);
    Console.WriteLine(response.HttpStatusCode);
    Console.WriteLine(response.Status);
    Console.WriteLine(response.ResponseJSON);
    Console.WriteLine(response.Message);
    Console.WriteLine(JsonConvert.SerializeObject(response));
    Console.WriteLine("\n\n\n");
}
 

Sample Response

Copied{
  "users": [
    {
      "id": "554023000000691003",
      "phone": "123456789",
      "email": "newtocrm@zoho.com",
      "dob": "1990-12-31",
      "role":"79234000000031154",
      "profile":"79234000000031157",
      "country_locale": "en_US",
      "time_format": "HH:mm",
      "time_zone": "US/Samoa",
      "status": "active"
    }
  ]
}
Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}
Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}
Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}
Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}

Sample Response

Copied{
  "users": [
    {
      "id": "554023000000691003",
      "phone": "123456789",
      "email": "newtocrm@zoho.com",
      "dob": "1990-12-31",
      "role":"79234000000031154",
      "profile":"79234000000031157",
      "country_locale": "en_US",
      "time_format": "HH:mm",
      "time_zone": "US/Samoa",
      "status": "active"
    }
  ]
}
Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}
Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}
Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}
Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}

Sample Response

Copied{
  "users": [
    {
      "id": "554023000000691003",
      "phone": "123456789",
      "email": "newtocrm@zoho.com",
      "dob": "1990-12-31",
      "role":"79234000000031154",
      "profile":"79234000000031157",
      "country_locale": "en_US",
      "time_format": "HH:mm",
      "time_zone": "US/Samoa",
      "status": "active"
    }
  ]
}
Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}
Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}
Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}
Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User updated",
      "status": "success"
    }
  ]
}

Sample Request

Copied/** To update user */
public void UpdateUser()
{
    ZCRMUser user = ZCRMUser.GetInstance(554023000000691003);//user id
    ZCRMOrganization OrgInstance = ZCRMRestClient.GetInstance().GetOrganizationInstance();
    user.Country = "US";
    user.Role = ZCRMRole.GetInstance(554023000000015969, "Manager");
    user.City = "Chennai";
    user.Street = "street";
    user.Alias = "alias";
    user.State = "state";
    user.Fax = "fax";
    user.CountryLocale = "en_US";
    user.FirstName = "TEST";
    user.Zip = "zip";
    user.Website = "https://www.zoho.com";
    user.Profile = ZCRMProfile.GetInstance(554023000000015975, "Standard");
    user.Mobile = "95851535";
    user.Phone = "0980911111";
    user.DateOfBirth = "1995-05-05";
    user.DateFormat = "MM/dd/yyyy";

    user.SetFieldValue("FieldApiName", "FieldApiValue");
    APIResponse response = OrgInstance.UpdateUser(user);
    Console.WriteLine(response.HttpStatusCode);
    Console.WriteLine(response.Status);
    Console.WriteLine(response.ResponseJSON);
    Console.WriteLine(response.Message);
    Console.WriteLine(JsonConvert.SerializeObject(response));
    Console.WriteLine("\n\n\n");
}