# Export Lists from Salesforce Marketing Cloud

Export lists of users or Attributes from Salesforce Marketing Cloud to Airship.

You can turn a Salesforce Marketing Cloud (SFMC) audience into an Airship [Uploaded (Static) List](https://www.airship.com/docs/reference/glossary/#uploaded_list). You can also send SFMC Text, Number, and Date [Attributes](https://www.airship.com/docs/reference/glossary/#attributes) to Airship for personalization and targeting. Even better, you can automate the exports to save time.

This document walks you through creating an SFMC Data Extension, creating keys and configuring SFTP for the file transfer, creating SFMC activities that perform the data extraction and file transfer, and automating the tasks.

## Creating the Data Extension

Your SFMC data will be converted to CSV format before transfer to Airship. The structure of your Data Extension table defines the CSV.

### Formatting for Static Lists

For Static Lists, your Data Extension must contain a [Named User](https://www.airship.com/docs/reference/glossary/#named_user) value for each audience member. Configure your Data Extension with these two fields:

| Field name | Value |
| --- | --- |
| **Identifier type** | `named_user` |
| **Named User** | The ID string that represents the user in Airship |

Each row of the CSV will contain an `Identifier type, Named User` pair. However, the field names you enter in your Data Extension do not matter since they are omitted when the CSV is created. Example conversion to CSV:
```text
named_user,customer-009842
named_user,customer-277099
```


### Formatting for Attributes

For Attributes, configure your Data Extension with a field named `named_user` and an additional field for each Attribute to associate with the Named User:

| Field name | Value |
| --- | --- |
| **named_user** | The ID string that represents the user in Airship |
| **&lt;attribute_id&gt;** | The Named User's data in [Text, Number, or Date format](https://www.airship.com/docs/guides/audience/attributes/about/#attribute-types), depending on the Attribute type |

The Data Extension field names are used as the header row in the CSV, so you must enter the them exactly. Subsequent rows list a Named User ID and the value of each Attribute for that user. Example conversion to CSV:

```text
named_user,first_name,last_name
customer-009842,Freddy,Shoop
customer-059874,Denise,Green
customer-277099,Francis,Gremp
```


> **Important:** You must [define custom Attributes or add predefined Attributes in Airship](https://www.airship.com/docs/guides/audience/attributes/adding/) before associating them with Named Users. Using a custom or predefined Attribute that you haven't yet set up in the Airship will result in an error.



## Setting up file transfer requirements

Airship's SFTP implementation uses SSH key pairs for authentication. You must create a pair of keys: a private key for your client and a public key for Airship. Then you can add the keys to Airship and SFMC and create a storage location to transfer your file from.

In Airship:

1. Follow the steps in [Generate keys](https://www.airship.com/docs/guides/audience/segmentation/sftp-upload/#generate-keys) in *SFTP upload for CSV files*.

1. Follow the steps in [Add your public key to Airship](https://www.airship.com/docs/guides/audience/segmentation/sftp-upload/#add-your-public-key-to-airship) in *SFTP upload for CSV files*.
   * Making sure to set the Purpose to `Static Lists` or `Attributes`, depending on your list type.
   * Note the host, port, and username for use in the following SFMC steps.

In SFMC:

1. Create an SSH encryption key. Follow the steps in Salesforce's [Create an Encryption Key for Marketing Cloud](https://help.salesforce.com/s/articleView?id=sf.mc_overview_create_a_key.htm&type=5). Since it is for file transfer activities, make sure to use the private key of the key pair generated using the Airship steps above.

1. Create an External SFTP Site [File Location](https://help.salesforce.com/s/articleView?language=en_US&id=sf.mc_overview_file_locations.htm&type=5). Follow the steps in Salesforce's [Set Up an External FTP, SFTP, or FTPS Site File Location](https://help.salesforce.com/s/articleView?id=sf.mc_overview_set_up_external_ftp_location.htm&type=5) using the stored key from the previous step as well as the host, port, and username provided by Airship. See also [Set up your client and transfer CSVs](https://www.airship.com/docs/guides/audience/segmentation/sftp-upload/#set-up-your-client-and-transfer-csvs) in *SFTP upload for CSV files*.

## Setting up data extraction and transfer

Set up SFMC tasks that extract the data from the Data Extension, format it, and transfer it to your SFTP File Location.

Follow the steps in the following two Salesforce documents:

1. [Data Extension Extract in Automation Studio](https://help.salesforce.com/s/articleView?id=sf.mc_as_data_extension_extract.htm&type=5)

   For Static Lists:
      * The file name entered will be the name of the Uploaded/Static list in Airship.
      * Be careful about using wildcard dates. They could result in exceeding the 100 list per project limit. 
      * Use a comma as the column delimiter.
      * Leave **Has Column Headers** unselected.
      * Select **Uses Line Feed**.

   For Attributes:
      * The file name is not used anywhere in Airship, only in the File Transfer activity.
      * Use a comma as the column delimiter.
      * Select **Has Column Headers**.
      * Select **Uses Line Feed**.

1. [Create a File Transfer Activity in Automation Studio](https://help.salesforce.com/s/articleView?id=sf.mc_as_use_a_data_extract_activity.htm&type=5)
   * Use the same file naming pattern as the Data Extension Extract.
   * Select file action **Move a File From Safehouse**. This is where the files will be when the previous activity completes.
   * For **Destination**, select your previously created External SFTP Site File Location.
   * Do not encrypt.

## Automating the flow

The final step is using SFMC's [Automation Studio](https://help.salesforce.com/s/articleView?id=sf.mc_as_automation_studio.htm&type=5) to automate running, in order, the two tasks created in the previous step.

## Verifying transfer

After running the automation, verify it was successfully transferred.

* For Static Lists, select the **Audience** menu, then **Lists**. You should see your list in **Uploaded Lists** with more than zero entries.

* For Attributes, select the **Audience** menu, then **Attributes**, then **Upload History**. For more information, see [Viewing Attributes upload history](https://www.airship.com/docs/guides/audience/attributes/managing/#viewing-upload-history) in *Managing Attributes*.

## Targeting users

You can now use the transferred data for targeting. See:

* [Using Uploaded Lists](https://www.airship.com/docs/guides/audience/segmentation/audience-lists/uploaded/#using-uploaded-lists)
* [Targeting your audience using Attributes](https://www.airship.com/docs/guides/audience/attributes/targeting/)
* [Segments](https://www.airship.com/docs/guides/audience/segmentation/segments/)
