Skip to content
Last updated

Airship Export Integration CLI

You can write job results from Treasure Data directly to Airship Audience Lists. In Airship, you can then use the List to target specific users.

Prerequisites

  • Basic Knowledge of Treasure Data.
  • Basic knowledge of Airship / Airship Audience Lists

Static IP Address of Treasure Data Integration

If your security policy requires IP whitelisting, you must add Treasure Data's IP addresses to your allowlist to ensure a successful connection.

Please find the complete list of static IP addresses, organized by region, at the following link:
https://api-docs.treasuredata.com/en/overview/ip-addresses-integrations-result-workers/

Creating Your Connection from the Command Line

You can use the CLI to configure your connection.

td query --database your_database --result configuration query

The following table identifies the configuration keys with descriptions.

Config KeyTypeRequiredDescription
typestringyesAirship
base_urlstringyes- Airship North America cloud site: https://go.urbanairship.com - Airship Europe cloud site: https://go.airship.eu
access_tokenstring-Airship Bearer access token Note: access_token or app_key, app_secret is required
app_keystring-See App Keys & Secrets
app_key_custom_eventsstringNoRequired if data_type is custom_events
app_secretstring-App Secret or Master secret
data_typestringNoSupported values: - static_list (default) - non_json_attributes - json_attributes - custom_events
non_json_targetstringYes if data_type=non_json_attributesSupported values: - named_users - channels
json_targetstringYes if data_type=json_attributesSupported values: - named_users - channels
non_json_actionstringYes if data_type=json_attributesSupported values: - batch_csv - set - remove
json_actionstringYes if data_type=json_attributesSupported values: - set - remove
list_namestringYes if data_type=static_listAudience List name
list_descriptionstringNoAudience List description
attribute_namestringYes if data_type=json_attributesAttribute name to be updated
skip_invalid_recordsbooleanNoIf set to true (default), this will skip invalid records and continue uploading valid ones. If set to false, this will terminate the job when an invalid record is encountered.
skip_invalid_nonjson_attbooleanNoIf set to true (default), this will skip invalid records and continue uploading valid ones. If set to false, this will terminate the job when an invalid record is encountered.
skip_invalid_json_attbooleanNoIf set to true (default), this will skip invalid records and continue uploading valid ones. If set to false, this will terminate the job when an invalid record is encountered.
skip_invalid_custom_eventsbooleanNoIf set to true (default), this will skip invalid records and continue uploading valid ones. If set to false, this will terminate the job when an invalid record is encountered.
json_composer_custom_eventsbooleanNoIf set to true, this will compose json request from properties fields. If set to false (default), this will use json value from properties field.
retry_limitintNoMaximum retry times for each API call (Default: 5)
initial_retry_wait_msecslongNoWait time for the first retry (Default: 60000 milliseconds)
max_retry_wait_msecslongNoMaximum time between retries (Default: 30000 milliseconds)
connection_timeout_secslongNoThe amount of time before the connection times out when doing API calls (Default: 300 seconds)
write_timeout_secslongNoThe amount of time waiting for writing data into the request (Default: 300 seconds)
read_timeout_secslongNoThe amount of time waiting for reading data from the response (Default: 300 seconds)

Example Query that Exports Results to an Airship Audience List

td query --database my_db \
--result '{"type": "airship","app_key": "xxx","app_secret": "yyy","list_name: amazon_channels,"list_description": "amazone collected channels for marketing"}' \
'SELECT identifier_type, identifier from my_table'

Example Query that Exports Results to an Airship Named Users Non Json Attributes

td query --database my_db --query 'SELECT named_user, first_name, last_name, fav_color FROM my_table' --type presto \
--result '{"type":"airship","base_url":"https://go.urbanairship.com",       "auth_method":"access_token","access_token":"xxx", "data_type":"non_json_attributes","non_json_target":"named_users","non_json_action":"set", "skip_invalid_nonjson_att":true}';

Example: Query and export results to an Airship Named UsersJson Attributes

td query --database my_db --query 'SELECT named_user, instance_id, first_name, last_name, fav_color FROM my_table' --type presto \
--result '{"type":"airship", "base_url":"https://go.urbanairship.com",       "auth_method":"access_token", "access_token":"xxx","data_type":"json_attributes",        "json_target":"named_users", "json_action":"set","skip_invalid_json_att":true}';

Example: Query and export results to an Airship Custom Events

td query -d database -w -q query.txt --type presto \
--result '{"type":"airship","base_url":"https://go.urbanairship.com","auth_method":"access_token", "access_token":"xxx","app_key_custom_events":"xxx", "data_type":"custom_events", "skip_invalid_custom_events":true}';

See Also