Documentation


getRecords

GetRecords API Call

You can use the getRecords method to fetch all users data specified in the API request

Check: https://www.zoho.com/crm/help/api/getrecords.html

Available functions in the method:

Name Params Description
selectColumns $columns - array You can call this function passing an array with the columns or passing columns one by one like individual params.
fromIndex $index - init From where you want to fetch the records. By default, one call just take the 20 first records.
toIndex $index - init Until where you want to fetch the records. One call only can fetch 200 records per request.
sortBy $column - string Sort the request by a column.
sortAsc - none - Sort the request in ascending order using the column setting in the sortBy function.
sortDesc - none - Sort the request in descending order using the column setting in the sortBy function.
since $timestamp - \DateTime If you specify the time, modified data will be fetched after the configured time.
withEmptyFields - none - Include the empty fields in the response.


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Leads', 'YourAuthToken');

      $records = $client->getRecords()
          ->selectColumns('First Name', 'Last Name', 'Email')
          ->sortBy('Last Name')->sortAsc()
          ->since(date_create('last week'))
          ->fromIndex(1)
          ->toIndex(200)
          ->request();

      // Getting the data
      foreach ($records as $record) {
        print_r($record->getData());
      }

      // Sample response:
      Array
      (
        [CONTACTID] => 1870824000000111075
        [Last Name] => Pontes
        [First Name] => Cristian
        [Email] => hsilencee@gmail.com
      )
      Array
      (
        [CONTACTID] => 1870824000000111076
        [Last Name] => John
        [First Name] => Doe
        [Email] => johndoe@gmail.com
      )
      ... continues ...
      


insertRecords

InsertRecords API Call

You can use the insertRecords method to insert records into the required Zoho CRM module.

Check: https://www.zoho.com/crm/help/api/insertrecords.html

Available functions in the method:

Name Params Description
addRecord $record - array Add a record as a simple associative array, like Field -> Value.
setRecords $records - array Add multiple records as a simple associative array, like Field -> Value.
onDuplicateError - none - Check the duplicate records and throw an error.
onDuplicateUpdate - none - Check the duplicate records, if exists, update the same.
requireApproval - none - By default, records are inserted directly. To keep the records in approval mode, use this function.
triggerWorkflow - none - Trigger the workflow rule while inserting record.


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Contacts', 'YourAuthToken');

      $records = $client->insertRecords()
        ->setRecords([
            array(
                'First Name' => 'Cristian',
                'Last Name' => 'Pontes',
                'email' => 'hsilencee@gmail.com',
            ),
            array(
                'First Name' => 'John',
                'Last Name' => 'Doe',
                'email' => 'johndoe@gmail.com',
            )
        ])
        ->onDuplicateError()
        ->triggerWorkflow()
        ->request();

      foreach ($records as $record) {
          // returns bool
          var_dump($record->isInserted());

          // returns bool
          var_dump($record->isDuplicate());

          // returns the Id of the new record
          var_dump($record->id);
          ...
      }
      

In some cases you will need to use more complex data in your records, I.E: In the SalesOrders module, if you want to add some products to your record, pass the 'Product Details' array will be necessary

Reference: InsertRecords#SalesOrders

Here is an XML example record, let's do the same, but with the ZohoCRMClient:


        <SalesOrders>
          <row no="1">
            <FL val="Subject">Subject Test</FL>
            <FL val="Sub Total">20.0</FL>
            <FL val="Grand Total">20.0</FL>
            <FL val="Product Details">
              <product no="1">
                <FL val="Product Id">2000000017001</FL>
                <FL val="Unit Price">10.0</FL>
                <FL val="Quantity">1.0</FL>
                <FL val="Total">10.0</FL>
              </product>
              <product no="2">
                <FL val="Product Id">2000000017002</FL>
                <FL val="Unit Price">10.0</FL>
                <FL val="Quantity">1.0</FL>
                <FL val="Total">10.0</FL>
              </product>
            </FL>
          </row>
        </SalesOrders>
      

The code would be:


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('SalesOrders', 'YourAuthToken');

      $records = $client->insertRecords()
        ->addRecord([
            'Subject' => 'Subject Test',
            'Sub Total' => '20.0',
            'Grand Total' => '20.0',
            'Product Details' => [
                [
                    '@type' => 'product',
                    'Product Id' => 2000000017001,
                    'Unit Price' => '10.0',
                    'Quantity' => '1.0',
                    'Total' => '10.0',
                ],
                [
                    '@type' => 'product',
                    'Product Id' => 2000000017002,
                    'Unit Price' => '10.0',
                    'Quantity' => '1.0',
                    'Total' => '10.0',
                ]
            ]
        ])->request();

      foreach ($records as $record) {
          var_dump($record->isInserted());
          ...
          ...
      }
      

Notice the "@type" flag that I use in each product, that is simple way to declare what should be the parent XML tag for that array, in order to avoid unnecessary array indexing...


updateRecords

UpdateRecords API Call

You can use the updateRecords method to update or modify the records in Zoho CRM.

Check: https://www.zoho.com/crm/help/api/updaterecords.html

Available functions in the method:

Name Params Description
addRecord $record - array Add a record as a simple associative array, like Field -> Value.
setRecords $records - array Add multiple records as a simple associative array, like Field -> Value.
onDuplicateError - none - Check the duplicate records and throw an error.
onDuplicateUpdate - none - Check the duplicate records, if exists, update the same.
requireApproval - none - By default, records are inserted directly. To keep the records in approval mode, use this function.
triggerWorkflow - none - Trigger the workflow rule while inserting record.


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Contacts', 'YourAuthToken');

      $records = $client->updateRecords()
          ->addRecord(array(
              // You must specify the record Id here
              'Id' => '1870824000000130001',
              'First Name' => 'Cristian',
              'Last Name' => 'Pontes',
              'email' => 'hsilencee@gmail.com',
          ))
          ->triggerWorkflow()
          ->request();

      foreach ($records as $record) {
          // returns bool
          var_dump($record->isError());

          // returns bool
          var_dump($record->isUpdated());

          // returns the Id of the new record
          var_dump($record->id);
          ...
      }
      


deleteRecords

DeleteRecords API Call

You can use this method to delete the selected record (you must specify unique ID of the record).

Check: https://www.zoho.com/crm/help/api/deleterecords.html

Available functions in the method:

Name Params Description
id $id - string Specify unique ID of the record


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Contacts', 'YourAuthToken');

      $record = $client->deleteRecords()
          ->id('1870824000000130001')
          ->request();

      // returns bool
      var_dump($record->isDeleted());
      


getDeletedRecordIds

DetDeletedRecordIds API Call

You can use the getDeletedRecordIds method to retrieve the list of IDs of deleted records from recycle bin.

Check: https://www.zoho.com/crm/help/api/getdeletedrecordids.html

Available functions in the method:

Name Params Description
fromIndex $index - init From where you want to fetch the records. By default, one call just take the 20 first records.
toIndex $index - init Until where you want to fetch the records. One call only can fetch 200 records per request.
since $timestamp - \DateTime If you specify the time, modified data will be fetched after the configured time.


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Contacts', 'YourAuthToken');

      $records = $client->getDeletedRecordIds()
          ->fromIndex(1)
          ->toIndex(200)
          ->since(date_create('last week'))
          ->request();

      foreach ($records->getData() as $id){
         print_r($id);
      }
      


getRelatedRecords

GetRelatedRecords API Call

You can use the getRelatedRecords method to fetch related records.
For example: You can fetch Leads related to a Campaign or fetch tasks related to an Account.

Check: https://www.zoho.com/crm/help/api/getrelatedrecords.html

Available functions in the method:

Name Params Description
id $id - string The id of the record for which you want to fetch related records.
fromIndex $index - init From where you want to fetch the records. By default, one call just take the 20 first records.
toIndex $index - init Until where you want to fetch the records. One call only can fetch 200 records per request.
parentModule $parentModule - string Module for which you want to fetch the related records.
Example: If you want to fetch Leads related to a Campaign, then Campaigns is your parent module.
withEmptyFields - none - Include the empty fields in the response.


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Attachments', 'YourAuthToken');

      $records = $client->getRelatedRecords()
          ->id('1870824000000111075')
          ->parentModule('Contacts')
          ->fromIndex(1)
          ->toIndex(200)
          ->request();

      foreach ($records as $record){
          print_r($record);
      }

      // Sample response:
      CristianPontes\ZohoCRMClient\Response\Record Object
      (
          [index] => 1
          [data] => Array
              (
                  [id] => 1870824000000121016
                  [File Name] => test.docx
                  [Size] => 13139
                  [Modified Time] => 2016-08-03 09:46:59
                  [SMOWNERID] => 1870824000000097008
                  [Attached By] =>  Cristian Pontes
              )

      )
      CristianPontes\ZohoCRMClient\Response\Record Object
      (
          [index] => 2
          [data] => Array
              (
                  [id] => 1870824000000118021
                  [File Name] => test.pdf
                  [Size] => 339
                  [Modified Time] => 2016-08-03 12:18:09
                  [SMOWNERID] => 1870824000000097008
                  [Attached By] =>  Cristian Pontes
              )
      )

      ... continues ...
      


getRecordById

GetRecordById API Call

You can use this method to retrieve individual records by record ID.

Check: https://www.zoho.com/crm/help/api/getrecordbyid.html

Available functions in the method:

Name Params Description
id $id - string Specify unique ID of the record.
withEmptyFields - none - Include the empty fields in the response.


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Contacts', 'YourAuthToken');

      $record = $client->getRecordById()
          ->id('1870824000000111075')
          ->request();

      print_r($record);
      


searchRecords

SearchRecords API Call

You can use the searchRecords method to get the list of records that meet your search criteria.

Check: https://www.zoho.com/crm/help/api/searchrecords.html

Available functions in the method:

Name Params Description
selectColumns $columns - array You can call this function passing an array with the columns or passing columns one by one like individual params.
fromIndex $index - init From where you want to fetch the records. By default, one call just take the 20 first records.
toIndex $index - init Until where you want to fetch the records. One call only can fetch 200 records per request.
where $field - string, $value - string Search record by an equal criteria. Could be multiple 'wheres' into a single request.
orWhere $field - string, $value - string Search record by an equal criteria adding. This function adds a secondary alternative after established 'where(s)'. Could be multiple 'orWheres' into a single request.
withEmptyFields - none - Include the empty fields in the response.


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Contacts', 'YourAuthToken');

      $records = $client->searchRecords()
          ->where('First Name', 'Cristian')
          ->where('Last Name', 'Pontes')
          ->orWhere('Email', 'hsilencee@gmail.com')
          ->request();

      foreach ($records as $record){
          print_r($record->getData());
      }
      


getSearchRecordsByPDC

GetSearchRecordsByPDC API Call

You can use this method to search the values based on predefined columns and custom lookup fields.

Check: https://www.zoho.com/crm/help/api/getsearchrecordsbypdc.html

Available functions in the method:

Name Params Description
selectColumns $columns - array You can call this function passing an array with the columns or passing columns one by one like individual params.
fromIndex $index - init From where you want to fetch the records. By default, one call just take the 20 first records.
toIndex $index - init Until where you want to fetch the records. One call only can fetch 200 records per request.
searchColumn $column - string Specify the predefined search column.
searchValue $value - string Specify the value to be searched.
withEmptyFields - none - Include the empty fields in the response.


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Products', 'YourAuthToken');

      $records = $client->getSearchRecordsByPDC()
          ->searchColumn('vendorid')
          ->searchValue('2000000017022')
          ->request();

      foreach ($records as $record){
          print_r($record->getData());
      }
      


uploadFile

Uploadfile API Call

You can use this method to attach files to records.

Check: https://www.zoho.com/crm/help/api/uploadfile.html

Available functions in the method:

Name Params Description
id $id - init Specify unique ID of the "record" or "note" to which the file has to be attached.
attachLink $link - string Attach a external link to a record.
uploadFromPath $path - string Upload the file input stream to a record, this must be the full path of the file. i.e: /home/path/to/file.extension.


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Contacts', 'YourAuthToken');

      $record = $client->uploadFile()
          ->id('1870824000000124001')
          ->uploadFromPath('home/path/to/document.pdf')
          ->request();

      // returns the id of the new attachment
      var_dump($record->id);

      // returns bool
      var_dump($record->isUploaded());

      


downloadFile

DownloadFile API Call

You can use this method to download files from CRM to your system.

Check: https://www.zoho.com/crm/help/api/downloadfile.html

Available functions in the method:

Name Params Description
id $id - init Specify unique ID of the attachment.
setFilePath $path - string This must be the full path of the file. In this location the file will be saved.


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Contacts', 'YourAuthToken');

      $client->downloadFile()
          ->id('1870824000000132007')
          ->setFilePath('home/path/to/the/newfile.extension')
          ->request();
      


deletefile

DeleteFile API Call

You can use this method to delete files attached to records.

Check: https://www.zoho.com/crm/help/api/deletefile.html

Available functions in the method:

Name Params Description
id $id - init Specify unique ID of the attachment.


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Contacts', 'YourAuthToken');

      $record = $client->deleteFile()
          ->id('1870824000000132007')
          ->request();

      // returns bool
      var_dump($record->isDeleted());
      


getFields

GetFields API Call

You can use the getFields method to fetch details of the fields available in a particular module.

Check: https://www.zoho.com/crm/help/api/getfields.html



      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Contacts', 'YourAuthToken');

      $fields = $client->getFields()
          ->request();

      print_r($fields);

      // Sample response:

      [0] => CristianPontes\ZohoCRMClient\Response\Field Object
        (
            [section] => Contact Information
            [label] => Contact Owner
            [type] => Lookup
            [required] =>
            [readOnly] =>
            [maxLength] => 120
            [options] => Array
                (
                )

            [customField] =>
            [lm] =>
        )

    [1] => CristianPontes\ZohoCRMClient\Response\Field Object
        (
            [section] => Contact Information
            [label] => Lead Source
            [type] => Pick List
            [required] =>
            [readOnly] =>
            [maxLength] => 120
            [options] => Array
                (
                    [0] => -None-
                    [1] => Advertisement
                    [2] => Cold Call
                    [3] => Employee Referral
                    [4] => External Referral
                    [5] => OnlineStore
                    [6] => Partner
                    [7] => Public Relations
                    [8] => Sales Mail Alias
                    [9] => Seminar Partner
                    [10] => Seminar-Internal
                    [11] => Trade Show
                    [12] => Web Download
                    [13] => Web Research
                    [14] => Web Cases
                    [15] => Web Mail
                    [16] => Chat
                )

            [customField] =>
            [lm] =>
        )
        ... continues ...
      


convertLead

ConvertLead API Call

You can use this method to convert Lead to potential, account and contact. You can also associate the existing contact or account to the converting Lead using this method.

Check: https://www.zoho.com/crm/help/api/convertlead.html

Available functions in the method:

Name Params Description
setLeadId $leadId - string Specify unique Lead ID to convert.
setCreatePotential $createPotential - bool Set it true if Potential should be created.
setAssignTo $assignTo - string Specify a user the converted Lead should be assign to. It could be SMOWNERID value or user email.
setNotifyLeadOwner $notifyLeadOwner - bool Specify if a Lead owner should be notified.
setNotifyNewEntityOwner $notifyNewEntityOwner - bool Specify if a new entity owner should be notified.
addRecord $record - array Specify values for potential. It is mandatory ONLY if setCreatePotential(true) is set.
setAccountId $accountId - string You can associate the existing account to the converting Lead.
setContactId $contactId - string You can associate the existing contact to the converting Lead.
setOverwriteAccountName $overwrite - bool If true, then the account name will be replaced by the company name from Lead while associating with the existing account. If false, then association will only happen. However, if you set it true without giving account using setAccountId(), the working of this method remains unchanged.
withEmptyFields - none - Include the empty fields in the response.


      use CristianPontes\ZohoCRMClient\ZohoCRMClient;

      $client = new ZohoCRMClient('Leads', 'YourAuthToken');

      $result = $client->convertLead()
          ->setLeadId($leadId)
          ->setCreatePotential(true)
          ->setNotifyLeadOwner(false)
          ->setNotifyNewEntityOwner(false)
          ->addRecord(array(
              'Potential Name' => 'Samplepotential',
              'Potential Stage' => 'Qualification',
          ))
          ->request();

      print_r($result);

      // Sample response:

      Array
      (
          [Account] => 161789000005836001
          [Potential] => 161789000005848039
          [Contact] => 161789000005836003
      )
      


updateRelatedRecords

UpdateRelatedRecords API Call

You can use the updateRelatedRecords method to update records related to another record.

Check: https://www.zoho.com/crm/help/api/updaterelatedrecords.html

Available functions in the method:

Name Params Description
relatedModule $module - string The module to which a record is related.
For example: If a lead related to a campaign needs to be updated, the value for this parameter will be Leads.
id $id - string The ID of the record to be updated.
addRecord $record - array Add a record as a simple associative array, like Field -> Value.
setRecords $records - array Add multiple records as a simple associative array, like Field -> Value.


        use CristianPontes\ZohoCRMClient\ZohoCRMClient;

        $client = new ZohoCRMClient('Products', 'authtoken');

        $response = $client->updateRelatedRecords()
            ->id('productID123')
            ->relatedModule('Leads')
            ->addRecord([
                'LEADID' => '999999999'
                ... fields ...
            ])
            ->request();

        // Sample response:

        CristianPontes\ZohoCRMClient\Response\Record Object
        (
            [index] => 1
            [data] => [
                [added-ids] => []

                [updated-ids] => [
                    [0] => 999999999
                ]
            ]
        )