Add User

Purpose

To add a user to your organization.

Endpoints

Request Details

Request URL

https://www.zohoapis.com/bigin/v1/users

Scope

scope=ZohoBigin.users.{operation_type}

Possible operation types

ALL - Full access to users
CREATE - To create users

Note
  • You can add only one user per POST request.

  • 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).

Sample Request

Copiedcurl "https://www.zohoapis.com/bigin/v1/users"
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-d "@newuser.json"
-X POST
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 addUser() throws Exception{
		ZCRMRestClient client = ZCRMRestClient.getInstance();
		ZCRMUser user=ZCRMUser.getInstance(null);//null is passed to the entity id
		user.setFirstName(“Patricia”);
		user.setFullName(“Patricia Boyle”);
		user.setLastName(“Boyle”);
		user.setEmailId(“Patricia@abc.com”);
		ZCRMRole role=ZCRMRole.getInstance(554023000000015969L, “Manager”);//554023000000015969L-entity id,"CEO" is the role name
		user.setRole(role);
		ZCRMProfile profile=ZCRMProfile.getInstance(554023000000015975L,”Standard”);//554023000000015975L-entity id,"Standard" -profile name
		user.setProfile(profile);
		ZCRMOrganization org=client.getOrganizationInstance();
		APIResponse response=org.addUser(user);
		System.out.println("HTTP status code"+response.getStatusCode());
		System.out.println("Status"+response.getStatus());
		System.out.println("message"+response.getMessage());
		System.out.println("details"+response.getResponseJSON());
	}
	public static void main(String[] args) throws Exception {
		Org obj=new Org();
		obj.addUser();
	}
}
Copied# Create user
# -----------
def create_user(self):
    try:
        user_ins = zcrmsdk.ZCRMUser.get_instance()
        user_ins.last_name = "Boyle"
        user_ins.email = 'Patricia@abc.com'
        user_ins.role = zcrmsdk.ZCRMRole.get_instance(554023000000015969, 'Manager')# role id and role name
        user_ins.profile = zcrmsdk.ZCRMProfile.get_instance(554023000000015975, 'Standard')# profile id and profile name
        resp = zcrmsdk.ZCRMOrganization.get_instance().create_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 createUser(){
        $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
       
        $user=ZCRMUser::getInstance(NULL, NULL);//to get the user instance
        $user->setLastName("Boyle");//to set the last name of the user
        $user->setFirstName("Patricia");//to set the first name of the user
        $user->setEmail("Patricia@abc.com");//to set the email id of the user
        $role=ZCRMRole::getInstance("554023000000015969","Manager");//to get the role
        $user->setRole($role);//to get the role of the user
        $profile=ZCRMProfile::getInstance("554023000000015975","Standard");//to get the profile
        $user->setProfile($profile);//to set the profile of the user
        $responseIns=$orgIns->createUser($user);//to create 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->createUser();
Copied/** To create new user */
public void CreateUser()
{
    ZCRMUser user = ZCRMUser.GetInstance("Boyle", "Patricia@abc.com"); //last_name and email of the user
    ZCRMOrganization OrgInstance = ZCRMRestClient.GetInstance().GetOrganizationInstance();
    user.Country = "US";
    user.Role = ZCRMRole.GetInstance(554023000000015969, "Manager");
    user.CountryLocale = "en_US";
    user.FirstName = "Patricia";
    user.Profile = ZCRMProfile.GetInstance(554023000000015975, "Standard");
    user.DateOfBirth = "1990-12-31";
    user.DateFormat = "MM/dd/yyyy";

    user.SetFieldValue("FieldApiName","FieldValue");
    APIResponse response = OrgInstance.CreateUser(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");
}
Copieduser1 = Map();
user1.put("last_name", "Shawn");
user1.put("email", "shawn@zylker.com");
user1.put("role", "692969000000015969");
user1.put("profile", "692969000000015972");

users = List();
users.add(user1);

params = Map();
params.put("users", users);

response = invokeurl
[
	url: "https://www.zohoapis.com/crm/v2/users"
	type: POST
	parameters: params.toString()
	connection:"crm_connection"
];
info response ;

In the request, "@newuser.json" contains the sample input data.

Request JSON
  • last_namestring, mandatory

    Specify the last name of the user.

  • emailstring, mandatory

    Specify the email ID of the user.

  • rolestring, mandatory

    Specify the unique ID of the role you want to assign the user with. You can obtain the role ID from the Roles API.

  • profilestring, mandatory

    Specify the unique ID of the profile you want to assign the user with, to decide the user's level of access to CRM data. You can obtain the profile ID from the Profiles API.

 

Sample Input

Copied{
  "users": [
    {
      "role": "554023000000015969",
      "first_name": "Patricia",
      "email": "Patricia@abcl.com",
      "profile": "554023000000015975",
      "last_name": "Boyle"
    }
  ]
}

Possible Errors

  • LICENSE_LIMIT_EXCEEDEDHTTP 400

    Request exceeds your license limit. Need to upgrade in order to add.
    Resolution: The maximum number of users you can add per your Bigin plan has exceeded. Please buy additional user licenses to add more users.

  • DUPLICATE_DATAHTTP 400

    Failed to add user since same email id is already present
    Resolution: The user you are trying to add already exists in your organization.

  • MANDATORY_NOT_FOUNDHTTP 400

    Company Name is required
    Resolution: Company name is not specified in the request body.

  • INVALID_DATAHTTP 400

    Invalid data.
    Resolution: Email Id should not contain @skydesk.jp. Please choose a different email id (OR) Invalid Email Id. Please choose a different email id The email ID is either invalid or contains @skydesk.jp.

Sample Response

Copied{
  "users": [
    {
      "code": "SUCCESS",
      "details": {
        "id": "554023000000691003"
      },
      "message": "User added",
      "status": "success"
    }
  ]
}