Skip to contentSkip to navigationSkip to topbar
On this page

Formatting a CSV


(information)

Info

The content on this page describes the experience in the latest version of Marketing Campaigns. If you're using the legacy version of Marketing Campaigns, your experience may be different. To explore Marketing Campaigns plans and upgrade, click here(link takes you to an external page).

You can add contacts to your contact database by uploading a CSV into Marketing Campaigns. If you have your contacts in a spreadsheet, save that sheet as a CSV file using a spreadsheet application like Microsoft Excel or Google Sheets. You can also export your contacts from most database systems as a CSV file.


General Formatting Rules

general-formatting-rules page anchor

Follow the rules below when formatting a CSV to upload into Marketing Campaigns. Download this sample CSV(link takes you to an external page) similar to the one shown below:

Example of a CSV with proper formatting.

Contact Info

contact-info page anchor

Your CSV should contain the following information about each contact:

  • email
  • phone_number_id
  • external_id
  • anonymous_id
  • first_name
  • last_name

Only one of email, phone_number_id, external_id, or anonymous_id is required.

In addition to the above, there are also several other reserved fields such as city and zipcode. You can also include custom fields with additional identifying information for each contact in the CSV. For example, you could specify birthday, occupation, and age as the custom fields. The data in the custom fields are critical for both segmentation and content personalization.

The first row of your CSV must be a header row containing labels identifying each column. Headers should only use letters, numbers, and underscores. Header fields can be blank in your CSV, but must be named and have their type defined later during the upload process.

(information)

Info

You cannot use spaces, dashes, or other special characters, except for underscores in a CSV.

If you add custom field data to your CSV, you can save some time when uploading by naming the columns the same as the custom fields you have previously defined.

SendGrid identifies individual contacts by their unique identifiers: "email", "phone_number_id", "external_id", or "anonymous_id". One of the CSV headers must be one of these unique identifiers. If you do not include one of the required identifier columns, SendGrid will not add any information about your contact. Rows in your CSV without one of these required identifiers will automatically fail to be added to your contact list, although they will not cause the entire upload to fail.

If your contacts list has non-English characters, please make sure that you are UTF-8 encoding your CSV file.

Removing invalid and duplicate addresses

removing-invalid-and-duplicate-addresses page anchor

SendGrid removes duplicate and invalid identifiers, including email addresses with any special characters except for underscores from your list during upload. At least one identifier is required to be present to create a new contact and each identifier must be unique. This means that the number of contacts can potentially change between your CSV and your Marketing Campaigns list. For updating a contact, all of its existing identifiers must be present.

Format your text fields so that there are no strings of numbers that appear like phone numbers, zip codes, and so on. They should not contain punctuation characters like a dash, underscore, parenthesis, or multiple dots.

1
- US Zip Code: 80202-1713
2
- Phone numbers: "(555) 555-5555" or "555.555.5555"
3
- Monetary Values with the currency indicator such as $3.50 or €5.73

Properly format any dates in your CSV. If you create your CSV with Excel and it is not displaying correctly, change the date format to display appropriately before exporting to CSV. Use one of the following date formats: MM/DD/YYYY, MM/D/YYYY, M/D/YYYY, or M/DD/YYYY.

Below are a few errors you may encounter when uploading a CSV to Marketing Campaigns, along with tips to correct the root issue.

We were unable to detect an identifier column in the CSV file headers. The identifier column must always have a header of "email", "phone_number_id", "external_id", or "anonymous_id".

  • If there is a header labeled "email" or one of the other accepted identifiers, try moving it to column A, so it is the first header in your list.
  • Your CSV must include a header with one of the accepted identifiers.
Move email header to column A.

Some of your custom fields have not been selected.

  • Look for hidden characters in your CSV file if you have worked with the file multiple times and made some adjustments to the data.
  • A common fix for this error would be to select all and copy your data to a new CSV spreadsheet. This should remove any hidden characters.
This should remove any hidden characters.

Each custom field can only be applied to a column once. Please check your columns and try again.

  • Check your CSV for duplicate fields, especially fields that have matching information as your email, first_name and last_name fields. You cannot edit these field names as they are reserved.
  • For example, if you have a "Name" field, it may conflict with your first_name reserved field.
Check your CSV for duplicate fields, especially fields that have matching information as your email, first_name and last_name fields.

We were unable to detect any headers in your CSV file.

  • Include headers at the top of each column. All CSV uploads must contain the "email" header. Header fields can be blank in your CSV but must be defined later during the upload process.
Include headers at the top of each column.

Float type conversion error.

  • Categorize dashes or decimal places that are past the hundredth place as text_fields (-100, 123.123 are text fields, 100, 12.12 can be number fields).
  • Number fields can include monetary values without the currency symbols. For example, 19.95 would be a number field, and $19.95, including the ($), would be a text field.
  • As you are uploading your CSV, make sure you select the correct fields for your Field type.
Categorize dashes or decimal places that are past the hundredth place as text_fields.

Need some help?

Terms of service

Copyright © 2024 Twilio Inc.