Delete User

Purpose

To delete a user from your organization.

Request Details

Request URL

https://www.zohoapis.com/bigin/v1/users/{user_id}

Scope

scope=ZohoBigin.users.{operation_type}

Possible operation types

ALL - Full access to users
DELETE - Delete user data

Note
  • You can delete only one user per request.

  • You can also pass the record ID in the request. Example: {{api-domain}}/bigin/v1/users/{{record_id}}

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

  • The deleted user record will also show up in the response when you fetch user records through the Get Users API where the status is set as deleted.

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

Sample Request

Copiedcurl "https://www.zohoapis.com/bigin/v1/users/554023000000691003"
-X DELETE
-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 deleteUser() throws Exception{
		ZCRMRestClient client = ZCRMRestClient.getInstance();
		ZCRMOrganization org=client.getOrganizationInstance();
		APIResponse response=org.deleteUser(554023000000691003L);//554023000000691003L is user id
		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.deleteUser();
	}
}
Copied# Delete user
# -----------
def delete_user(self):
    try:
        resp = zcrmsdk.ZCRMOrganization.get_instance().delete_user(554023000000691003) # user id
        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;
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 deleteUser(){
        $orgIns = ZCRMRestClient::getOrganizationInstance(); // to get the organization instance
       
        $responseIns=$orgIns->deleteUser("554023000000691003");//to delete 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->deleteUser();
Copied/** To delete a user */
public static void DeleteUser()
{
    ZCRMOrganization OrgInstance = ZCRMRestClient.GetInstance().GetOrganizationInstance();
    APIResponse response = OrgInstance.DeleteUser(554023000000691003); //user ID
    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");
}
Copiedresponse = invokeurl
[
	url: "https://www.zohoapis.com/crm/v2/users/554023000000691003"
	type: DELETE
	connection:"crm_oauth_connection"
];
info response;

Possible Errors

  • INVALID_DATAHTTP 200

    the_id_given_seems_to_be_invalid
    Resolution: The record ID of the user you want to delete is invalid. Refer to Get Users API to get valid record IDs.

  • INVALID_REQUESTHTTP 400

    Primary contact cannot be deleted
    Resolution: You cannot delete the primary contact of your organization.

  • ID_ALREADY_DELETEDHTTP 400

    User is already deleted
    Resolution: The user you want to delete is already deleted.

  • AUTHORIZATION_FAILEDHTTP 400

    User does not have sufficient privilege to delete users
    Resolution: The user does not have the permission to delete users. Contact your system administrator.

Sample Response

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