# Using Treasure Workflow With Import and Export connectors

Most batch import and export integrations can be added to workflows as part of a more advanced data pipeline. The basic steps are:

- Prepare a workflow definition, which is a YAML file, using the **td_load>** operator for an import integration and the **td>** operator for an export integration.
- Run the workflow on the Treasure Console, or from a command-line interface


## Use a pre-defined Source of an import integration

If you have already created a Source for an import integration, you can run it in a workflow using its unique ID

1. Identify the target Source on the **Integration Hub**
2. Select the `...` menu, and select **Copy Unique ID**
![](/assets/using-td-workflow-with-td-integrations-2024-08-09.f0acc37b697f4693c6d5e5f2fccc80706461e31eff5d1baabef37ed64a2c2773.18b4736f.png)
3. Define a workflow task using the **td_load>** operator.

```yaml
+my_first_worklfow_step:
   td_load>: unique_id_of_your_source
```


## Use a configuration file for an import integration

Alternatively, you can provide all the parameters of the import connector in a YAML file, and refer to it in the workflow definition

1. Prepare a configuration file for your import integration, ex: **load_config.yml**. Examples and the full parameter explanation can be found in the document of each integration
2. Define a workflow refers to it

```yaml
+my_first_workflow_step:
   td_load>: config/load_config.yml
   database: my_database_name
   table: my_table_name
```


## Define a workflow involving an export integration

There are a few ways to define a workflow task to query and upload the results to an export integration

1. Use the **td>** operator and the **name** of a pre-defined Authentication
![](/assets/using-td-workflow-with-td-integrations-2024-08-09-1.a52133de619be06eed4ff85425ba571cd590adc97e5e7d600dd617864ea051f6.18b4736f.png)

```yaml
+query_and_export:
   td>: queries/sample.sql
   database: my_database
   result_connection: ads_with_oauth
   result_settings:
      parameter1: value1
      parameter2: value2
```
The parameter explanation can be found on each integration document, as the one below from the SFCC Export Integration
![](/assets/using-td-workflow-with-td-integrations-2024-08-14.c8d92f28ae6ba0e800fa2fda32d81638c3713763f4f9e5dd43fdb074178ff49e.18b4736f.png)
2. Use the **td>** operator and the **ID** of a pre-defined Authentication
![](/assets/google-ads-import-integration-v2-2024-08-06-9.fdc162a377e20998a8f41e69c38afef49bbd1ab0b84f6b913fd06fe82b2010f3.7c52a81f.png)

```yaml
+query_data_and_write_result_with_existing_authentication_by_url:
   td>:
   query: 'select * from wf_test'
   database: my_database
   result_url: '{"type": "google_adwords_v2", "td_authentication_id": 330392, "bucket": "qa-auto-test-3", "path": "viet/assume_role_from_eu01.csv"}'
```
3. Use the **td_run>** operator and a saved query

```yaml
+query_a_saved_sql:
   td_run>: presto_select_all_s3v2
   database: my_database
   result_url: '{"type":"s3_v2", "td_authentication_id":260370, "bucket": "qqus-east-1", "path":"foo/wf_jan16_1444.csv"}'
```


### Run a workflow

There are two options to define and run a workflow

1. Use the graphical interface on **Treasure Console** > **Data Workbench** > **Workflows**
2. Use the command-line interface of TD Toolbelt


While using the Treasure Console is more straightforward than the command-line interface, the Treasure CLI tool offers options for more complex configurations.

Refer [here](/products/customer-data-platform/data-workbench/workflows/about-workflow-syntax) for more details about the syntax and usages of the Treasure Workflow