# Zoho

The connector calls the [Zoho Bulk Read APIs](https://www.zoho.com/crm/developer/docs/api/v2/bulk-read/overview.html).

**Before you start**

You need:

- **A Zoho CRM user** with access to the modules you want to extract. You sign in with it when you authorize the configuration, and you enter its email address afterwards.
- **Your Zoho data center (https://help.zoho.com/portal/en/kb/commerce/user-guide/getting-started-with-zoho-commerce/articles/data-centers):** EU, US, IN, AU or JP. The connector does not support the UK, CA or CN data centers yet. You set it in the configuration's account settings.

What each tab needs:

- **Prompt tab:** Kai, the **Kai Agent** button in the top bar, on supported stacks. A new Free Plan project has it from the start; elsewhere an organization admin turns it on once: Get started with Kai (/kai/getting-started/).
- **UI tab:** a browser.
- **CLI / API tab:** kbagent (/cli/getting-started/), connected to your project. The checks only read.

## Supported Endpoints
The supported endpoints are:

- `crm/bulk/v2/read`
- `crm/bulk/v2/read/{job_id}`
- `crm/bulk/v2/read/{job_id}/result`

If you need additional endpoints, please submit your request to [ideas.keboola.com](https://ideas.keboola.com/).

## Configuration
[Create a new configuration](https://help.keboola.com/components/configurations/#create-a-configuration) of the **Zoho** data source connector.

Click **Authorize Account** to [authorize the configuration](https://help.keboola.com/components/authorization/) with access to the Zoho CRM data you want to extract. Then, select 
the [data center](https://help.zoho.com/portal/en/kb/commerce/user-guide/getting-started-with-zoho-commerce/articles/data-centers) of your Zoho instance in the account settings.

Once done, you must enter the **account's user email address (`user_email`)** you used to generate the Self Client.

### Creating a New Report
To create a new report to download, click **Add Row**. 
Each report you download will be a [configuration row](https://help.keboola.com/components/#configuration-rows).

After that, set up the **Module records download configuration (`module_records_download_config`)**. This step is required.  
Then, set up the job configuration:
  - **Module name (`module_name`)** – The API name of the Zoho CRM module you want to extract records from *[required]*. 
  - **Field names (`field_names`)** – API names of the module record fields you want to extract. Leave it empty if you want to download all available fields *[optional]*. 

### Sync Options
Next, select one of the **Sync Options (`sync_options`)**. This step is required. There are three modes available: 
- Full Sync
- Incremental Sync
- Advanced Sync that allows you to set up custom filtering

The **Filtering criteria (`filtering_criteria`)** enable you to filter the downloaded records using their fields' values. There is a single filtering criterion and a filtering criteria group. 
This can be left empty as this step is optional.

- *Single filtering criterion:*
    - **Field name (`field_name`)** – The API name of the field you want to filter by *[required]*. 
    - **Operator (`operator`)** – The operator you want to use to filter the field *[required]*. 
    - **Value (`value`)** – The value you want to use to filter the field. Datetimes must always contain time zone information *[required]*. 
- *Filtering criteria group:*
    - **Group (`group`)** – List of simple filtering criteria (see above) *[required]*. 
    - **Group operator (`group_operator`)** – The operator you want to use to combine the filtering criteria; `and` / `or` *[required]*.

### Destination
Finally, fill in the **Destination settings** to determine what happens in Keboola Storage *[required]*.

- **Output table name (`output_table_name`)** – The name of the table that should be created or updated in Keboola Storage. The default is `module_name` *[optional]*.
- **Load mode (`load_mode`)** –  If full load is used, the destination table will be overwritten every run. If incremental load is used, data will be upserted into the destination table *[required]*.

Once everything is configured, click **Save** and run the configuration.

**Check:**

#### Prompt

```text title="Prompt" wrap
Did the latest job of my Zoho configuration succeed, and which tables did it load, with row counts and primary keys?
```

Kai only reads here, so it asks for no approval, and its answer links to what it found in your project.

#### UI

The job ends with status **Success** and Storage has a table named after the module, or the output table
name you set, with an `Id` column as its primary key.

#### CLI / API

```bash
kbagent job list --component-id kds-team.ex-zoho --config-id 123456789 --limit 1
kbagent storage tables --bucket-id in.c-kds-team-ex-zoho-123456789
```

Replace `123456789` with your configuration ID: `status` shows whether the job succeeded, and `id` and `rows_count` list the tables it loaded.

---

## Output
All output tables contain the `Id` column containing the record's unique ID. It is always used as the output table's primary key in Keboola Storage. 
Other fields depend on the module from which you extract the records and the field names specified in the configuration.
