Email Attachments

Customer.io doesn’t support attachments of any type in Campaigns or Broadcasts. But, there are other, better ways to send files to recipients!

 Try our transactional API

Rather than trying to send links, or add attachments to events, you can send attachments as a part of our transactional message service.

Why you shouldn’t send attachments

Sending attachments can create problems for your deliverability. Here’s a non-exhaustive list of potential problems stemming from attachments:

  • Email attachments are often used to hide viruses and malware, so they are more likely to end up in spam folders or flagged as potentially malicious.
  • Some email servers have strict policies around message size limits and/or attachments which can cause messages to bounce.
  • Attachments impose a larger download for recipients, which can impact their data consumption and/or lead them to ignore your email.

All of these can damage your deliverability.

 Include PDF attachments from the asset library

While you can encode attachment and send them directly to people, you can also host PDFs in our asset library and link to them in your messages. This can save you the trouble of encoding and sending files directly.

If you want to send a file to your recipients, the best approach is to send them a link to a landing page where they can download the file.

  1. You should host the file online—either on your own server or a cloud storage service like AWS S3, Google Drive, Dropbox, Box, etc.
  2. Create a page that links to the file. Your hosting service might already create one for you. Otherwise, you’ll need to add a page to your website.
  3. Copy that page’s URL and use it in your email.

 Avoid sending a link to a file directly

You can send a link to the file itself, but be aware that some spam filters and algorithms have been known to follow links to evaluate them, and if the link leads to a file, it could be considered suspicious. Microsoft Office files are particularly risky.

While more convoluted than using a direct link, this approach helps ensure that your emails are not flagged as spam.

File attachments with the transactional API

In cases where an attachment is unavoidable, our Transactional API does support attachments through an attachments parameter.

You can specify for this parameter a dictionary of attachments where the filename is the key and the value is the base64-encoded contents. The total size of all attachments must be less than 2 MB. Do note that some filetype extensions are restricted.

Moving from the events API to the transactional API

Before we released our Transactional API, you could send an attachment as a part of an event. This workaround for attachments is less performant and more restrictive than the attachment support available with the Transactional API. We will officially remove attachment support from the Events API on March 20, 2023. If you want to continue sending attachments in your messages, you’ll need to update your integration to use the Transactional API.

In events, you’d pass custom data and attachments as a part of the data object. In a transactional message, you’ll send custom data as a part of the message_data object, and attachments in their own attachments object.

The examples below show how to send a purchase receipt using the new transactional APi, and how you would have done it with the deprecated event attachments parameter.

Transactional message with attachmentsPurchase event with deprecated attachments key
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
POST https://api.customer.io/v1/send/email

{
  "transactional_message_id": "purchase_confirmation",
  "to": "customer@example.com",
  "identifiers": {
    "id": {identifier}
  },
  "message_data": {
    "price": 23.45,
    "product": "socks"
  },
  "attachments": {
    "receipt.pdf": "base64-encoded pdf"
  }
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
POST https://track.customer.io/api/v1/customers/{identifier}/events 

{
  "name": "purchase",
  "data": {
    "price": 23.45,
    "product": "socks"
    // deprecated attachments object
    "attachments": {
      "receipt.pdf": "base64-encoded pdf"
    }
  }
}

See the transactional API for a complete list of available properties.

Copied to clipboard!
Is this page helpful?