# Clevertap Export Integration This feature is in BETA version. For more information, contact your Customer Success Representative. ## Overview CleverTap is a premier customer engagement and retention platform that combines app analytics with marketing tools to help businesses drive user engagement and improve retention. It offers three key functionalities: - **User Behavior Tracking and Analysis**: Monitor user actions and analyze product usage patterns. - **Segmentation and Targeted Campaigns**: Segment users based on behavior and run personalized campaigns across various channels. - **Campaign Analysis**: Evaluate campaign effectiveness to optimize user engagement and business metrics. The CleverTap integration connects Treasure Data with CleverTap, enabling seamless synchronization of user profiles, events, and audiences. This integration empowers businesses to leverage Treasure Data’s unified data and CleverTap’s engagement tools to enhance their CX, CRM, and retention marketing efforts. ## Prerequisites - Basic Knowledge of Treasure Data - Basic knowledge of the CleverTap Engagement Platform ## Limitations - The maximum file size for uploading a user audience custom list is 5GB. ## Create a New Connection Before running your query, you must create and configure the data connection on the TD Console. As part of the data connection, you provide authentication to access the integration. Complete the following steps. ![](/assets/screenshot-at-aug-20-14-20-44.4ecf9908bf6b0d6a3fb3d797b5f0186b642ca69788941919b316e44f3ef37254.fe495661.png) 1. Open TD Console. 2. Navigate to **Integrations Hub > Catalog.** 3. Search for and select **CleverTap.** 4. Select **Create Authentication**, and provide the credential information for the integration as described in the following table. 5. Select **Continue,**enter a name for the Authentication, and select **Done**. ### Authentication Fields | **Field** | **Description** | | --- | --- | | **CleverTap Account ID** | Input field for CleverTap Account ID. To get an Account ID, read [API Quick Start Guide](https://developer.clevertap.com/docs/api-quickstart-guide#get-clevertap-account-credentials-to-authenticate-api-requests). | | **CleverTap Passcode** | Input field for CleverTap Account Passcode or User’s Passcode. To get a Passcode, read [API Quick Start Guide](https://developer.clevertap.com/docs/api-quickstart-guide#get-clevertap-account-credentials-to-authenticate-api-requests). | | **Rest Endpoint Region** | Select **Box** to select the API regions to determine the Rest of the End-points to use. To get the Account Regions (for Rest Endpoint), read [Common API Components](https://developer.clevertap.com/docs/common-api-components#region). | ## Configure a Query Result for Export The TD Console supports multiple ways to export data. Please follow these steps to export data from the Data Workbench. 1. Navigate to **Data Workbench** > **Queries**. 2. Select **New Query**, and define your query. 3. Select **Export Results** to configure the data exporting. 4. Select an existing CleverTap authentication or create a new one described previously 5. Select **Done.** ### Connector Configuration Parameters The following table describes the configuration parameters for the CleverTap export integration. | **Field** | **Description** | | --- | --- | | **Target Data Entity** | The CleverTap export Target Data Entity. Supported Values:- **User Profiles:** Upload the data related to user profiles. - **User Events:** Upload the data related to user events. - **User Audiences - Custom List:** Upload custom list segment. | | **User Profiles Operation** | The operation related to upload user profiles. Select the list of values below:- **Upload User Profiles:** Update user profile information such as gender, phone, etc. - **Upload Device Tokens:** Add an existing device token to a CleverTap user profile. - **Demege User Profile:** Demerge a user profile. - **Update Email/Phone Subscription:** Set a phone number or email status as subscribed or unsubscribed. - **Disassociate A Phone Number:** Disconnect a phone number from a user profile. | | **Array Property Operation** | This option is required only if the **User Profiles Operation** is **Upload User Profiles** and the custom attribute value is json array. It will apply the CleverTap array operation: replace, append ($add), and remove ($remove). Supported operations: - **Replace** - **Append** - **Remove** | | **Name for Custom List Upload** | This option is required if the **Target Data Entity** is **User Audiences - Custom List**. This is the name of the segment in CleverTap. | | **Custom List Upload User Email** | This option required if the **Target Data Entity** is **User Audiences - Custom List**. The email must belong to CleverTap admin role. | | **Segment Operation Mode** | Supported values:- **Create New Segment (One-Time):** This will create a new segment on the CleverTap. If the segment already exists, the job will fail. - **Update Existing Segment (Scheduled):** This will update the existing segment on the CleverTap. The segment must exist in the CleverTap; otherwise, the job will fail. This option can be used for scheduled jobs. | | **Thread Count Number** | The number of concurrent requests to the CleverTap server. Min: 1, Max: 10, Default: 5. This parameter only apply for Target Data Entity: **User Profiles** and **User Events**. | | **Skip on Invalid Record?** | If checked, the job will skip the invalid record and continue to handle the next record. Otherwise, the job will stop. | ## Detailed Guide for Each Target Data Entity For all target data entities, you need to build a data export query that includes a combination of default and custom fields that adhere to CleverTap API guidelines. For default fields, ensure that the column names match those listed in each feature guide's "Field/Column-Level Specifications" section. The connector automatically normalizes the column names to match CleverTap's required format, so you do not need to worry about case sensitivity. For example, for the default field "objectId," the column name in your export query can be written in any case, such as "OBJECTID," "objectid," or "OBJECTid." The connector will standardize the column name to "objectId" to align with CleverTap's requirements. ## Target Data Entity: User Profiles For the User Profiles data entity, we support a few operation modes: - **Upload User Profiles:** Update user profile information such as gender, phone, etc. - **Upload Device Tokens:**Add an existing device token to a CleverTap user profile. - **Demege User Profile:**Demerge a user profile. - **Update Email/Phone Subscription:**Set a phone number or email status as subscribed or unsubscribed. - **Disassociate A Phone Number:** Disconnect a phone number from a user profile. This document includes one detailed guide section for the Upload User Profiles mode and one section for the four remaining operation modes. ### Upload User Profiles Details #### I. Building the Export Query To successfully upload/modify user profile data to CleverTap, you must construct an export query that adheres to specific data specifications. These specifications are divided into two levels. #### Export Query Specifications | **Specification** | **Description** | | --- | --- | | **Conditionally Required Columns** | At least one of the following columns must be present: `identity` or `objectid`. | | **Null Value Columns** | Columns with null values will be ignored. | | **Column Naming Rules** | - Column names must not include the following characters: `&`, `$`, `"`, `,`, `%`, `>`, `<`, `!`. - Column names must not exceed 120 characters. | | **Maximum Column Value Length** | Column values for both default and custom fields must not exceed 512 characters. | | **Duplicated Columns** | Duplicated columns are not allowed. | ##### Field/Column-Level Specifications **Default Field Columns** | **Field** | **Description** | **Required** | **Data Type** | **Additional Specifications** | | --- | --- | --- | --- | --- | | `identity` | User identity field | Yes, if `objectid` is not present | Scalar types (string, integer, boolean) | | | `objectid` | User identity field | Yes, if `identity` is not present | Scalar types (string, integer, boolean) | | | `Name` | Profile name | No | String | | | `Email` | User’s email | No | String | It must match a valid email pattern. | | Phone | User's phone number | No | String | Must be formatted as E.164 phone number format, which is +[country code][national significant number] | | `Gender` | User gender | No | String | It can only accept values from the following enum: `["M", "F"]`. | | `DOB` | User date of birth | No | Unix timestamp string | There are three options for this field’s value to match CleverTap’s requirement for a Unix timestamp format of `"$D_unix_time_value"`: 1) **Integer type**: If the column’s data is of integer type, it will be used as-is, assuming it’s already in Unix format, and the format `"$D_unix_time_value"` will be applied. 2) **Timestamp cast**: If the column’s data is cast as a timestamp, the connector will convert it to an integer Unix time format and then apply the format `"$D_unix_time_value"`. *For example:*`SELECT CAST(timestamp_column AS TIMESTAMP) AS dob`*.* 3) **ISO-8061 string format**: If the column’s data is of string type in ISO-8061 format, it will be converted to Unix time (integer), then apply the format `"$D_unix_time_value"`. Ensure the value ends with `“Z”` to be recognized as an ISO-8601 date-time string and note that it will consistently be recognized as UTC. For example:`SELECT "2020-08-01T00:00:00Z" AS dob`*.* | #### Field/Column-Level Names For Export Queries | Feild Name | Query Values | Feild Usage | | --- | --- | --- | | phone | phone | users phone | | name | name | user name | | email | email | user email | | MSG-whatsapp | MSG-whatsapp | Whatsapp user preference | | MSG-sms | MSG-sms | SMS user preference | | MSG-push | MSG-push | User Push Preferences | **Example Query:** ```sql SELECT IDENTITY, CAST( 'objectid' AS VARCHAR ) AS objectId, name, email, 'M', CAST( '+1234567890123456789' AS VARCHAR ) phone, '1995-05-15T00:00:00Z', CAST( email_pref AS BOOLEAN ) AS MSG_email, CAST( 'true' AS BOOLEAN ) AS MSG_push, CAST( 'true' AS BOOLEAN ) AS MSG_sms, CAST( 'true' AS BOOLEAN ) AS MSG_whatsapp, CAST( json_parse('["Newsletters", "Promotions"]') AS arrayvarchar ) "Custom Value 1" FROM clever_tap_upload_user_profiles LIMIT 1 ``` **Custom Field Columns** | **Column Type** | **Description** | **Mapping** | **Additional Specifications** | | --- | --- | --- | --- | | Non-default Fields | Columns not listed as default fields will be treated as custom fields. | Mapped as key/value pairs in `profileData` object | Column names and values are mapped as-is. Date-time columns must be cast as “timestamp” or formatted as ISO-8601 date-time strings. Array column property values must be strings and are limited to 100 items, with each value limited to 512 characters. Refer to the following sections for guidance on handling date-time or array of strings custom field. | **Handling Date-Time** The integration can handle values cast as timestamps or in ISO-8601 date-time string format for date-time custom field columns. When using ISO-8601 date-time strings, ensure the value includes the letter “Z” at the end to allow the connector to detect and convert the date-time value into a Unix time value and apply the format “$D_unix_time_value” as required by CleverTap’s API contract. #### Examples for Handling Date-Time Custom Field Columns **1. Casting as Timestamp** - Create a column of type string in the source data table: ```sql ALTER TABLE source_data_table ADD COLUMN date_time_field VARCHAR; ``` - Insert date-time value strings into that column: ```sql INSERT INTO source_data_table (id, date_time_field)VALUES(1, '2024-08-28'),(2, '2024-08-28 15:30:00'),(3, '2024-08-28T15:30:00'); ``` - Cast the column value as timestamp: ```sql SELECT id, CAST(date_time_field AS timestamp) AS date_time_field FROM source_data_table; ``` **2. Using ISO-8601 Date-Time String** - Create a column of type string in the source data table: ``` ALTER TABLE source_data_table ADD COLUMN date_time_field VARCHAR; ``` - Insert date-time value strings into that column, ensuring they are formatted as ISO-8601 with a “T” separator and “Z” at the end: ```sql INSERT INTO source_data_table (id, date_time_field)VALUES(1, '2024-08-28T00:00:00Z'),(2, '2024-05-28T15:30:00.123Z'),(3, '2024-02-28T15:30:00Z'); ``` - Use the column directly in the query: ```sql SELECT id, date_time_field FROM source_data_table; ``` **Handling an Array of String Custom Field Columns** For the integration to accurately interpret a column’s data and map it to an array of string user properties in CleverTap, the following options are available: **1. Direct Use of Array Column** - Create a column of an array of strings in the source data table: ```sql ALTER TABLE source_data_table ADD COLUMN array_column ARRAYVARCHAR; ``` - Insert an array of string values into this column: ```sql INSERT INTO source_data_table (id, array_column)VALUES(2, ARRAY['fig', 'grape', 'honeydew', 'kiwi', 'lemon']),(3, ARRAY['mango', 'nectarine', 'orange', 'pear', 'quince']),(4, ARRAY['raspberry', 'strawberry', 'tangerine', 'ugli fruit', 'vanilla bean']),(5, ARRAY['watermelon', 'ximenia', 'yellow apple', 'zucchini', 'apricot']); ``` - Use the array of string columns directly in the query: ```sql SELECT id, array_column FROM source_data_table; ``` **2. Using String Columns Cast to JSON or JSON Array** - Create a column of string data type in the source data table: ```sql ALTER TABLE source_data_table ADD COLUMN array_string_column VARCHAR; ``` - Insert array string values into this column: ```sql INSERT INTO source_data_table( id, array_string_column ) VALUES( 1, '["apple", "banana", "cherry", "date", "elderberry"]' ), ( 2, '["fig", "grape", "honeydew", "kiwi", "lemon"]' ), ( 3, '["mango", "nectarine", "orange", "pear", "quince"]' ), ( 4, '["raspberry", "strawberry", "tangerine", "ugli fruit", "vanilla bean"]' ), ( 5, '["watermelon", "ximenia", "yellow apple", "zucchini", "apricot"]' ) ; ``` - Use the array of string columns by casting to JSON array or JSON in the dataset export query: - Cast as array: ``` SELECT id, CAST(json_parse(array_string_column) AS ARRAYVARCHAR) AS array_column FROM source_data_table; ``` - Cast as JSON array: ``` SELECT id, CAST(json_parse(array_string_column) AS JSON) AS array_column FROM source_data_table; ``` ### II. Connector Configuration ![](/assets/config_user_profiles.847c6ab8f4b75b5265bb7d27d5d2f6326a3ae34b6210fd18b2f3a7ddccf63403.b90d17e3.png) | **Configuration Option** | **Value** | **Description** | | --- | --- | --- | | Target Data Entity | User Profiles | Set to “User Profiles” for this feature. | | User Profiles Operation | Upload User Profiles | Specify that the operation is to upload user profiles. | | Array Property Operation | replace/append/remove | Determines how array properties are handled: - **replace**: Override the existing array property with new values. - **append**: Add specified values to the existing array property. - **remove**: Remove specified values from the existing array property. | ### Details Guide for Other Operation Modes ofUser Profiles The **User Profiles** operations allow you to perform various operations to manage and update user profile data. The following sections outline the four different operation modes available under this feature: 1. **Upload Device Tokens**: Add or update device tokens associated with user profiles. 2. **Demerge User Profile**: Separate merged user profiles. 3. **Update Email/Phone Subscription**: Set email or phone subscription statuses for existing user profiles. 4. **Disassociate a Phone Number**: Disconnects the phone number from existing user profiles. Each operation mode has specific requirements and configurations that must be followed to ensure successful data uploads to CleverTap. ### I. Building the Export Query To perform the previously described operations, you must construct an export query that adheres to specific data specifications, which are divided into two levels. #### Export Query Specifications | **Operation Mode** | **Required Columns** | **Description** | | --- | --- | --- | | **Upload Device Tokens** | `objectId`, `id`, `type` | The query result must include `objectId` (CleverTap object ID), `id` (device token), and `type` (device platform type). Additional required fields: `p256dh` and `auth` for Chrome-based tokens. | | **Demerge User Profile** | `identity` | The query result must include the `identity` column containing user identities to be demerged. | | **Update Email/Phone Subscription** | `type`, `value`, `status` | The query result must include `type` (contact type), `value` (contact value), and `status` (subscription status). | | **Disassociate a Phone Number** | `value` | The query result must consist of the `value` column containing the phone number to be disassociated. | - **Null Value Columns**: Any columns with null values will be ignored. - **Ignored Columns**: Any columns not required for the selected operation mode will be ignored. #### 2. Field-Level Details **Default Field Columns for Each Operation** | **Operation Mode** | **Field** | **Description** | **Required** | **Data Type** | **Additional Specifications** | | --- | --- | --- | --- | --- | --- | | **Upload Device Tokens** | `objectId` | The CleverTap objectId | Yes | String | Must uniquely identify a user. | | | `id` | Device token | Yes | String | It must be a valid device token. | | | `type` | Device platform type | Yes | String | Supported values are `apns`, `gcm`, `fcm`, `wns`, `mpns`, `chrome`. | | | `p256dh` | Encryption key used for Chrome web push notifications | Conditional | String | Required only if `type` is `chrome`. | | | `auth` | Authentication secret for Chrome web push notifications | Conditional | String | Required only if `type` is `chrome`. | | **Demerge User Profile** | `identity` | User identities for profiles to demerge | Yes | String | | | **Update Email/Phone Subscription** | `type` | Contact type | Yes | String | Can only accept values from the enum: `["phone", "email", "WhatsApp"]`. | | | `value` | Contact value | Yes | String | Phone number format as E.164 (`+[country code][national significant number]`) or email address. | | | `status` | Contact subscription status | Yes | String | Can only accept values from the enum: `["Unsubscribe", "Resubscribe"]`. | | **Disassociate a Phone Number** | `value` | Phone number value | Yes | String | Must be formatted as E.164 phone number format, which is `+[country code][national significant number]`. | ### II. Connector Configuration ![](/assets/config_user_profiles_other-modes.378422c79d66ac7b3d26487ee6d2a7e8d1fdc66d5b4c06af586b667ae57ec74e.b90d17e3.png) For each operation mode, the connector must be configured with specific settings. | **Configuration Option** | **Value** | **Description** | | --- | --- | --- | | **Target Data Entity** | User Profiles | Set to “User Profiles” for all operations. | | **User Profiles Operation** | Upload Device Tokens | Choose “Upload Device Tokens” to add or update device tokens. | | | Demerge User Profile | Choose “Demerge User Profile” to separate merged profiles. | | | Update Email/Phone Subscription | Choose “Update Email/Phone Subscription” to set email or phone subscription statuses. | | | Disassociate a Phone Number | Choose “Disassociate a Phone Number” to disconnect a phone number from user profiles. | | **Array Property Operation** | Ignored | This setting will be ignored for all operations. | ## Target Data Entity: User Events ### I. Building the Export Query Your export query must adhere to the following detailed data specifications to upload user event data to CleverTap successfully. This section outlines the requirements for both default and custom fields, as well as specific column naming rules and data constraints. #### 1. Export Query Specifications | **Specification** | **Description** | | --- | --- | | **Required Columns** | - At least one of the following columns must be present: `identity` or `objectid`. - The `evtName` column is mandatory. | | **Null Value Columns** | Columns with null values will be ignored. | | **Column Naming Rules** | - Column names must not include the following characters: `&`, `$`, `"`, `,`, `%`, `>`, `<`, `!`. - Column names must not exceed 120 characters. | | **Maximum Column Value Length** | Column values for both default and custom fields must not exceed 512 characters. | | **Duplicated Columns** | Duplicated columns are not allowed. | #### 2. Field/Column-Level Specifications **Default Field Columns** | **Field/Column/Alias** | **Description** | **Required** | **Data Type** | **Additional Specifications** | | --- | --- | --- | --- | --- | | `identity` | User identity field | Yes, if `objectid` is not present | Scalar types (string, integer, boolean) | | | `objectid` | User identity field | Yes, if `identity` is not present | Scalar types (string, integer, boolean) | | | `ts` | Event timestamp | No | Integer/Long | There are three options for this field’s value to match CleverTap’s requirement for a Unix timestamp format: 1) **Integer type**: If the column’s data is of integer type, it will be used as-is, assuming it’s already in Unix format. 2) **Timestamp cast**: If the column’s data is cast as a timestamp, the connector will convert it to an integer Unix time format. For example: `SELECT CAST(timestamp_field AS TIMESTAMP) AS ts`. 3) **ISO-8061 string format**: If the column’s data is of string type in ISO-8061 format, it will be converted to Unix time (integer). Ensure the value ends with “Z” to be recognized as an ISO-8601 date-time string and note that it will consistently be recognized as UTC. For example: `SELECT "2020-08-01T00:00:00Z" AS ts`. | | `evtName` | Event name | Yes | String | | | `Items[index].KeyName` | List of products/items for “Charged Event” | No | Array of Objects | The `Items` field is required to be an array of objects of the `evtName` object. The connector can help formulate this array of objects if you follow the specific column name pattern: - **Column Pattern**: The column names should follow the pattern: *Items*`[x].field_name, for example:``Items[0].Category`*,*`Items[0].Book name`, where `x` is an integer representing the array index. - **Hardcoding and Formatting**: The prefix `Items` is hardcoded and should not be changed. The `field_name` part of the column name should be used as-is, without any reformatting. - **Array Indexing**: Ensure the array index `x` is an integer, and the index value doesn’t need to start from 0. It is permissible to skip numbers in the array indices. **Example:** Column/Alias: *Items[0].Book name, Items[0].Category, Items[0].Quantity* will convert as `"evtData": { "Items": [ { "Category": "books", "Book name": "The millionaire next door", "Quantity": 1 } ]}` | **Custom Field Columns** | **Column Type** | **Description** | **Mapping** | **Additional Specifications** | | --- | --- | --- | --- | | Non-default Fields | Columns not listed as default fields will be treated as custom fields. | Mapped as key/value pairs in `evtData` object | Column names and values are mapped as-is. Date-time columns must be cast as “timestamp” or formatted as ISO-8601 date-time strings. Refer to the "Handling Date-Time Custom Field Columns" section in the Upload User Profiles guide for more details. | ### II. Connector Configuration ![](/assets/config_user_events.50873c4323f3e21584c7970d3177add14104ae3ee55cc729c49c23637f365447.b90d17e3.png) | **Configuration Option** | **Value** | **Description** | | --- | --- | --- | | Target Data Entity | User Events | Set to “User Events” for this feature. | ## Target Data Entity: User Audiences - Custom List This feature allows you to create a segment of users by uploading a list of user identities to CleverTap. The following details guide you through building the export query and configuring the connector. ### I. Building the Export Query To successfully create a segment by uploading a list of user identities to CleverTap, you must construct an export query that adheres to specific data specifications. These are divided into two levels. #### 1. Export Query Specifications | **Specification** | **Description** | | --- | --- | | **Required Columns** | The query result must include the `type` and `identity` columns. | | **Null Value Columns** | Columns with null values will be ignored. | | **Ignored Columns** | Any columns that are not one of the required columns will be ignored. | #### 2. Field/Column-Level Specifications **Default Field Columns** | **Field** | **Description** | **Required** | **Data Type** | **Additional Specifications** | | --- | --- | --- | --- | --- | | `type` | User identity type | Yes | String | Values can only be `g` or `i`. | | `identity` | User identity values | Yes | String or Integer | | ### II. Connector Configuration ![](/assets/config_custom_llist.6501304b5abfdb137e71bb8663c8c888be79de616a4248502453c1fa941db18e.b90d17e3.png) | **Configuration Option** | **Value** | **Description** | | --- | --- | --- | | Target Data Entity | User Audiences - Custom List | Set to “User Audiences - Custom List” for this feature. | | Name for Custom List Upload | [Custom List Segment Name] | Specify the segment name in the CleverTap dashboard UI. | | Custom List Upload User Email | [User Email] | Enter the user email of the CleverTap user who performed the custom list segment upload. You need to input an Admin Role's email, otherwise the job will fail. | | Segment Operation Mode | Create New Segment / Update Existing Segment | Choose “Create New Segment” for a one-time job that adds a new segment to CleverTap. Choose “Update Existing Segment” to modify an existing segment, which can be scheduled to run regularly. | ## (Optional) Export Integration Using the CLI The [TD Toolbelt](https://toolbelt.treasuredata.com/) can trigger the Query Result exporting from a CLI. It would be best to specify the parameters for the exporting job using the `--result` option of the `td query` command. For more information, refer to [this article](https://docs.treasuredata.com/articles/pd/querying-and-importing-data-to-treasure-data-from-the-command-line). The format of the option is JSON, and the general structure is as follows. **User Profiles** ```json { "type": "clever_tap", "account_id": "986-XXX-XXYY", "passcode": "XXYY", "region": "UNITED_STATES", "target_data_entity": "USER_PROFILES", "user_profiles_operation": "UPLOAD_USER_PROFILES", "array_operation": "REPLACE", "skip_invalid_record": true, "thread_count": 5 } ``` **User Event** ```json { "type": "clever_tap", "account_id": "986-XXX-XXYY", "passcode": "XXYY", "region": "UNITED_STATES", "target_data_entity": "USER_EVENTS", "skip_invalid_record": true, "thread_count": 5 } ``` **Custom List** ```json { "type": "clever_tap", "account_id": "986-XXX-XXYY", "passcode": "XXYY", "region": "UNITED_STATES", "target_data_entity": "USER_AUDIENCES_CUSTOM_LIST", "name_for_custom_list_upload": "demo name", "email_for_custom_list_upload": "demo@example.com", "segment_operation_mode": "UPDATE", "skip_invalid_record": true } ``` ### CLI Parameters | Name | Description | Value | Default Value | Required | | --- | --- | --- | --- | --- | | td_authentication_id | This is the ID of the existing CleverTap authentication on the TD console. | | | | | account_id | The CleverTap's account ID | String | null | Yes, if td_authentication_id is not present | | passcode | The CleverTap's passcode | String | null | Yes, if td_authentication_id is not present | | region | The CleverTap's instance region | Supported values: - INDIA - SINGAPORE - UNITED_STATES - INDONESIA - MIDDLE_EAST - EUROPE | UNITED_STATES | Yes, if td_authentication_id is not present | | target_data_entity | Export target data | Supported values: - USER_PROFILES - USER_EVENTS - USER_AUDIENCES_CUSTOM_LIST | USER_PROFILES | YES | | user_profiles_operation | The export mode for user profiles | Supported values: - UPLOAD_USER_PROFILES - UPLOAD_DEVICE_TOKENS - DEMERGE_USER_PROFILE - UPDATE_EMAIL_PHONE_SUBSCRIPTION - DISASSOCIATE_A_PHONE_NUMBER | UPLOAD_USER_PROFILES | Yes, if the target_data_entity is USER_PROFILES | | array_operation | The array operation for the json array column when Upload User Profiles | Supported values: - REPLACE - APPEND - REMOVE | REPLACE | Yes, if the user_profiles_operation is UPLOAD_USER_PROFILES | | name_for_custom_list_upload | The name of the segment | String | | Yes, if target_data_entity is USER_AUDIENCES_CUSTOM_LIST | | email_for_custom_list_upload | The Email to receive the upload result. The email must belong to CleverTap's Admin role. | String | | Yes, if target_data_entity is USER_AUDIENCES_CUSTOM_LIST | | segment_operation_mode | Segment operation mode. Create a new segment or update the existing segment. | Supported values: - CREATE - UPDATE | UPDATE | Yes, if target_data_entity is USER_AUDIENCES_CUSTOM_LIST | | thread_count | The number of concurrent requests to the CleverTap server. | Number | 5 | Yes if the target_data_entity are USER_PROFILES or USER_EVENTS | | skip_invalid_record | The flag to control the job continues running or stops when handling the invalid record. | Boolean | false | No | ### Example usage 1. **Upload User Profiles** ```bash td query \ -d db_name \ -w "select identity, objectid, name, email, gender, phone, dob, msg_email, msg_push, msg_sms, msg_whatsapp, CAST(json_parse('["Newsletters", "Promotions"]') AS JSON) AS 'Custom Value 1' from tbl_name" \ --type presto \ --result '{ "type": "clever_tap", "td_authentication_id": 514830, "target_data_entity": "USER_PROFILES", "user_profiles_operation": "UPLOAD_USER_PROFILES", "array_operation": "REPLACE", "thread_count": 5, "skip_invalid_record": true }' ``` 1. **Upload Device Tokens** ```bash td query \ -d db_name \ -w "select objectId, Id, Type, p256dh, auth from tbl_name" \ --type presto \ --result '{ "type": "clever_tap", "td_authentication_id": 514830, "target_data_entity": "USER_PROFILES", "user_profiles_operation": "UPLOAD_DEVICE_TOKENS", "thread_count": 5, "skip_invalid_record": true }' ``` 1. **De-Merge User Profile** ```bash td query \ -d db_name \ -w "select identity from tbl_name" \ --type presto \ --result '{ "type": "clever_tap", "td_authentication_id": 514830, "target_data_entity": "USER_PROFILES", "user_profiles_operation": "DEMERGE_USER_PROFILE", "thread_count": 5, "skip_invalid_record": true }' ``` 1. **Update Email/Phone Subscription** ```bash td query \ -d db_name \ -w "select type, value, status from tbl_name" \ --type presto \ --result '{ "type": "clever_tap", "td_authentication_id": 514830, "target_data_entity": "USER_PROFILES", "user_profiles_operation": "UPDATE_EMAIL_PHONE_SUBSCRIPTION", "thread_count": 5, "skip_invalid_record": true }' ``` 1. **Disassociate A Phone Number** ```bash td query \ -d db_name \ -w "select value from tbl_name" \ --type presto \ --result '{ "type": "clever_tap", "td_authentication_id": 514830, "target_data_entity": "USER_PROFILES", "user_profiles_operation": "DISASSOCIATE_A_PHONE_NUMBER", "thread_count": 5, "skip_invalid_record": true }' ``` 1. **Upload User Events** ```bash td query \ -d db_name \ -w "select identity, objectid, ts, evtname, product_name as 'Product name', category as 'Category', price as 'Price', currency as 'Currency', amount as 'Amount', payment_mode as 'Payment mode', delivery_by as 'Delivery By', items_0__category AS 'Items[0].Category', items_0__book_name as 'Items[0].Book name', items_0__quantity as 'Items[0].Quantity', items_1__category AS 'Items[1].Category', items_1__book_name as 'Items[1].Book name', items_1__quantity as 'Items[1].Quantity' from tbl_name" \ --type presto \ --result '{ "type": "clever_tap", "td_authentication_id": 514830, "target_data_entity": "USER_EVENTS", "thread_count": 5, "skip_invalid_record": true }' ``` 1. **Upload Custom List** ```bash td query \ -d db_name \ -w "select type, identity from tbl_name" \ --type presto \ --result '{ "type": "clever_tap", "td_authentication_id": 514830, "target_data_entity": "USER_AUDIENCES_CUSTOM_LIST", "name_for_custom_list_upload": "Test", "email_for_custom_list_upload": "test@example.com", "segment_operation_mode": "UPDATE", "skip_invalid_record": true }' ``` ## Related articles #### Other Configurations - The Result Export can be [scheduled](https://docs.treasuredata.com/articles/pd/scheduling-jobs-using-td-console) to periodically upload data to a target destination. - All import and export integrations can be added to a [TD Workflow](https://docs.treasuredata.com/articles/pd/about-treasure-workflow). The **td** data operator can export a query result to a specified integration. For more information, see [Reference for Treasure Data Operators](https://docs.treasuredata.com/articles/pd/reference-for-treasure-data-operators/a/h1_76525622).