# 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 unless auth_method is client_credentials | Login URL for Zendesk |
| auth_method | string | yes | basic or token or oauth or client_credentials |
| 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 |
| subdomain | string | yes if auth_method is client_credentials | The subdomain of your Zendesk URL, for example `example` for `https://example.zendesk.com`. Used instead of login_url |
| client_id | string | yes if auth_method is client_credentials | Client ID (unique identifier) of your Zendesk OAuth client |
| client_secret | string | yes if auth_method is client_credentials | Client secret of your Zendesk OAuth client |
| 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 |


API tokens are being deprecated
Zendesk blocks the creation of new API tokens after 2026-10-27 and deactivates all remaining API tokens on 2027-04-30. Use `client_credentials` for new scheduled exports. Create the OAuth client in Zendesk **Admin Center** > **Apps and integrations** > **APIs** > **OAuth clients**, allow the `users:write` scope, and copy the secret when it is shown — Zendesk displays it only once. Actions are attributed to the Zendesk user who created the OAuth client, so prefer a durable service account. See the Zendesk announcement, [Announcing the removal of API tokens as an authentication method for API requests](https://support.zendesk.com/hc/en-us/articles/10851263566234-Announcing-the-removal-of-API-tokens-as-an-authentication-method-for-API-requests).

### Connection and Query Examples

Create an 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 an event for profiles using OAuth Client Credentials

```bash
td query --database my_db \
         --result '{
            "type": "zendesk",
            "auth_method": "client_credentials",
            "subdomain": "{example}",
            "client_id": "xxxxx",
            "client_secret": "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 an 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 an 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;'
```