# Zendesk Export Integration CLI

You can export data results from TD to Zendesk Sunshine using CLI (TD Toolbelt).

## Prerequisites

- [TD Toolbelt](/tools/cli-and-sdks/td-toolbelt) is installed.
- Basic knowledge of Zendesk Sunshine and Zendesk account.


## Limitations

The query must match require columns(name & data type) with target event.

## Using the Command Line to Create Your Connection

You can use the CLI to configure your connection.

Configuration keys and descriptions as follows:

| **Config Key** | **Type** | **Required** | **Description** |
|  --- | --- | --- | --- |
| type | string | yes | zendesk |
| login_url | string | yes | Login URL for Zendesk |
| auth_method | string | yes | basic or token or oauth |
| username | string | yes if auth_method is basic or token | Your Zendesk username |
| password | string | yes if auth_method is basic | Zendesk password |
| token | string | yes if auth_method is token | Zendesk token |
| access_token | string | yes if auth_method is oauth | Zendesk OAuth access token |
| target | string | yes | which export Zendesk target: event_profile, event_profile_id or event_user_id |
| skip_invalid_records | string | no | continue when have invalid record |


### Connection and Query Examples

Create a event for profiles


```bash
td query --database my_db \
         --result '{
            "type": "zendesk",
            "login_url": "https://{example}.zendesk.com",
            "auth_method": "basic",
            "password": "xxxxx",
            "username": "xxxxx",
            "target": "event_profile",
            "skip_invalid_records": false
         }'
         'SELECT profile_source, profile_type, profile_identifier_1, 
          event_source, event_type, event_properties
          FROM your_table;'
```

Create a event for profile id


```bash
td query --database my_db \
         --result '{
            "type": "zendesk",
            "login_url": "https://{example}.zendesk.com",
            "auth_method": "basic",
            "password": "xxxxx",
            "username": "xxxxx",
            "target": "event_profile_id",
            "skip_invalid_records": false
         }'
         'SELECT profile_id, event_source, event_type, event_properties
          FROM your_table;'
```

Create a event for user id


```bash
td query --database my_db \
         --result '{
            "type": "zendesk",
            "login_url": "https://{example}.zendesk.com",
            "auth_method": "basic",
            "password": "xxxxx",
            "username": "xxxxx",
            "target": "event_user_id",
            "skip_invalid_records": false
         }'
         'SELECT user_id, profile_source, profile_type, profile_identifier_1, 
          event_source, event_type, event_properties
          FROM your_table;'
```