# SFTP upload for CSV files

You can upload audience lists, attributes, named user association lists, and Coupons data directly to Airship using SFTP.

Many CRM platforms export data as CSV files. You can take advantage of Airship's SFTP interface to upload that data to: 

* **Add users to your project in a reusable** [Audience List](https://www.airship.com/docs/reference/glossary/#audience_list) — The list is labeled "[Uploaded List](https://www.airship.com/docs/reference/glossary/#uploaded_list)" in the dashboard and can be selected as your messaging audience or included in a [Segment](https://www.airship.com/docs/reference/glossary/#segment).

* **Set or remove user** [Attributes](https://www.airship.com/docs/reference/glossary/#attributes) —  Attributes can be associated with [Channels](https://www.airship.com/docs/reference/glossary/#channel_dev), [Named Users](https://www.airship.com/docs/reference/glossary/#named_user), [MSISDNs](https://www.airship.com/docs/reference/glossary/#msisdn), or email addresses, but you cannot mix identifiers. For MSISDNs and email addresses, Airship will generate new channels for identifiers we don't recognize.

* **Associate** [Channels](https://www.airship.com/docs/reference/glossary/#channel_dev) **with** [Named Users](https://www.airship.com/docs/reference/glossary/#named_user) —  Upon upload, Airship registers channels that are new to your project and creates the named user ID if it does not already exist.

* **Add more codes for a [Coupons](https://www.airship.com/docs/reference/glossary/#coupons) campaign** — You can also overwrite existing campaign settings using the values in the CSV file.

All uploaded files are encrypted in transit and at rest.

You will need:

1. An FTP/SFTP client — Many CRM platforms support SFTP directly, or you can use a client like FileZilla.
1. SSH keys — Airship's implementation of SFTP uses public key authentication.
1. A properly formatted CSV file

> **Important:** You must add Custom and Predefined Attributes to your project before setting them on users. Otherwise, setting those Attributes will result in an error. See [Adding Attributes to your project](https://www.airship.com/docs/guides/audience/attributes/adding/).
> 
> JSON Attributes can only be set using the API.

> **Tip:** You can also upload audience lists, attributes, named user association lists, and Coupons data in the dashboard. See:
> 
> * [Uploaded Lists](https://www.airship.com/docs/guides/audience/segmentation/audience-lists/uploaded/)
> * [Setting Attributes Using a CSV File](https://www.airship.com/docs/guides/audience/attributes/setting/#csv-file)
> * [Associating Named Users Using a CSV File](https://www.airship.com/docs/guides/audience/named-users/#csv-file)
> * [Coupons: Editing campaigns and adding more codes](https://www.airship.com/docs/guides/personalization/sources/coupons/#editing-campaigns-and-adding-more-codes)


## Format your CSV

Prepare your CSV according to the formatting reference for the data you want to upload:

* [Attributes CSV format](https://www.airship.com/docs/reference/messages/csv-formatting/#attributes)
* [Named user association CSV format](https://www.airship.com/docs/reference/messages/csv-formatting/#named-user-association)
* [Uploaded audience list CSV format](https://www.airship.com/docs/guides/audience/segmentation/audience-lists/uploaded/#formatting-your-list)
* [Coupons CSV format](https://www.airship.com/docs/guides/personalization/sources/coupons/#formatting-your-csv)

## Generate keys

Airship's SFTP implementation uses SSH key pairs for authentication. You will create a pair of keys: a private key for your client and a public key for Airship.

Steps for Windows-based clients:
![Generating keys in PuTTY](https://www.airship.com/docs/images/putty_hu_54f2bfc7adc62833.webp)

*Generating keys in PuTTY*

1. [Download and run **puttygen.exe**](https://www.puttygen.com/download-putty).
1. Select **RSA** in the *Parameters* section near the bottom of the page and click **Generate**.
1. Move the mouse around in the blank area, as instructed, until the key pair is generated and the *Key* section updates.
1. Click **Save public key** and select the directory where you want to save your public key.
1. Click **Save private key** and save the private key in the same folder as your public key.
1. Copy the contents of the **Public key for pasting into OpenSSH authorized_keys file** field. This is what you'll paste when adding the key to Airship. Make sure to copy the entire key, starting with `ssh-rsa`.

Steps for MacOS- and Linux-based clients:
1. Open your terminal.
1. At the command line, enter `ssh-keygen -t rsa`. You can set other options, but the key type must be set to RSA (`-t rsa`).
1. Enter the directory and file name (without extension) for your new keys, e.g., `/Users/your_username/Documents/rsa_keys/<filename>`, and optionally enter a passphrase and confirm. This process generates two files based on the file name you provide:
   *  `<filename>` contains your private key.
   * `<filename>.pub` contains your public key.
1. Copy the contents of your `.pub` file. This is what you'll paste when adding the key to Airship.

---

If you need to remove a key from your project:

1. Next to your project name, select the dropdown menu (
), then **Settings**.
1. Under **Project settings**, select **SFTP**.
1. Select the trash can icon (
) for a key.

## Add your public key to Airship

When you add your public key to Airship, you select the *Purpose* for the key (audience/static lists or attributes), then  we generate a username for your SFTP connection. You can use the same key pair to upload both audience/static lists and attributes, but you must add the public key to Airship twice — once for each purpose.

In Airship:

1. Next to your project name, select the dropdown menu (
), then **Settings**.
1. Under **Project settings**, select **SFTP**.
1. Select **Add key** and configure:
   * **Purpose:** Select **Static Lists** (Uploaded audience lists), **Attributes**, **Attributes Snapshot**, **Named Users**, or **Coupons**.
   * **Name:** Enter a name to help you identify the key in Airship.
   * **Public key:**
      * For **Window users**, paste the contents of the **Public key for pasting into OpenSSH authorized_keys file** field you copied in the previous step.
      * For **MacOS and Linux users**, paste the contents of the `<filename>.pub` you saved in the previous step.
1. Select **Save key**.

## Set up your client and transfer CSVs

You can set up any client to use Airship's SFTP interface, using SSH or an SFTP client. Many CRM platforms natively support SFTP. First retrieve configuration information for the [key you added to Airship](#add-your-public-key-to-airship), then enter it in your SFTP client configuration.

1. Next to your project name, select the dropdown menu (
), then **Settings**.
1. Under **Project settings**, select **SFTP**.
1. Select the eye icon () for a key to see values for:
   * SSH command line
   * Username
   * Host: `sftp.airship.com` (`sftp.airship.eu` for EU customers)
   * Port: `5222`
1. Copy and paste the values from the previous step for use in your SFTP configuration. Authentication also requires [your private key](https://www.airship.com/docs/guides/audience/segmentation/sftp-upload/#generate-keys).
   ![SFTP client configuration](https://www.airship.com/docs/images/sftp-client-setup_hu_86bc6d506ba22424.webp)
   
   *SFTP client configuration*

After your connection is set up, you can transfer CSV lists to Airship.

---

After file transfer, see the following locations to access each upload type:

* **Audience Lists** — Go to **Audience**, then **Lists**, then **Uploaded**. See [Uploaded lists](https://www.airship.com/docs/guides/audience/segmentation/audience-lists/uploaded/).

* **Attributes** — Go to **Audience**, then **Attributes**, then **Attribute List**. See [Targeting your audience using attributes](https://www.airship.com/docs/guides/audience/attributes/targeting/) and [Managing attributes](https://www.airship.com/docs/guides/audience/attributes/managing/).

* **Coupons** — Next to your project name, select the dropdown menu (
), then **Settings**. Under **Project settings**, select **Coupons**. See [Coupons](https://www.airship.com/docs/guides/personalization/sources/coupons/).

* **Named Users** — To view user data, go to **Audience**, then **Contact Management**. See [Contact Management](https://www.airship.com/docs/guides/audience/contact-management/).

* **Attributes** and **Named Users** — For your upload history, go to **Audience**, then **Attributes**, then **Upload History**. The latest upload is listed first, with columns for:

   <ul>
   <li>File name</li>
   <li>User name — The user who performed the upload in the dashboard</li>
   <li>Source — Dashboard or SFTP</li>
   <li>Upload date</li>
   <li>Status — Processed, Processed with errors, Processing, or Failed</li>
   </ul>
   <p>For status &ldquo;Processed with errors&rdquo;, select the download icon (
   ) to download a CSV file of the identifiers that failed processing and their error reasons.</p>
