Email Attachments

Create and send email attachments with our new attachments API.

Now you can include a file to attach in an email in both our Push and Create-and-Send APIs. Create your attatchment using the Create attachments endpoint and send your attachments in an email using the Email override object.

Create attachments

The first step is to create an email attachment with the Create attachments endpoint. This will generate IDs for attachments that you can use later in your email sends.

Create attachment
POST /attachments HTTP/1.1
Authorization: Bearer <authorization token>
Content-Type: application/json
Accept: application/vnd.urbanairship+json; version=3

{
   "filename": "that_thing.txt",
   "content_type": "text/plain; charset=\"UTF-8\"",
   "data": "iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAAGXRFWHRTb2Z0d2FyZQBBZG9i6cmVTek5UY3prYzlkIj8..."
}

Retrieve Attachment IDs

A successful response will return an array of attachment IDs:

Retrieve attachment IDs
HTTP/1.1 201 Accepted
Data-Attribute: attachment_ids
Content-Type: application/vnd.urbanairship+json; version=3

{
   "ok": true,
   "attachment_ids": [
         "b0c46a8d-b701-441b-9d6e-147c183b28ca"
   ]
}

Include Attachments in Notification Payload

When you are ready to send the attachment(s), inlude the attachment ID(s) in the attachments array in the Email override object.

Send attachments
POST /push HTTP/1.1
Authorization: Bearer <authorization token>
Content-Type: application/json
Accept: application/vnd.urbanairship+json; version=3

{
   "audience": {
      "named_user": "peter_potamus"
   },
   "device_types": [
      "email"
   ],
   "notification": {
      "email": {
         "subject": "Did you get that thing I sent you?",
         "html_body": "<<p>Here's that thing!</p><p><a data-ua-unsubscribe=\"1\" title=\"unsubscribe\" href=\"http://unsubscribe.urbanairship.com/email/success.html\">Unsubscribe</a></p>",
         "plaintext_body": "Here's that thing! [[ua-unsubscribe href=\"http://unsubscribe.urbanairship.com/email/success.html\"]]",
         "message_type": "transactional",
         "sender_name": "Airship",
         "sender_address": "team@anairship.com",
         "reply_to": "no-reply@airship.com",
         "click_tracking": false,
         "open_tracking": false,
         "attachments": [
            {
               "id": "0e10a6b9-725c-4f6b-9af2-9ef5b31328c0",
            },
            {
               "id": "5503b5fe-ed69-4609-bef6-6fef0e6e428f"
            }
         ]
      }
   }
}

Size and Attachment Limits

This feature is available today for all customers using email.

  • Attachments can be used for transactional sends only, not commercial.
  • Attachments cannot be used in Automations.
  • Attachment size is limited to 2.5MB per attachment, with a 20MB content size limit on each message, including content body and all attachments.
  • Attachment count is limited to 10 per email.
  • Sending attachments with malicious content is strictly prohibited. This is enforced in part by blocking file types with .bat and .exe extensions.
  • Attachments have a TTL (Time To Live) of 60 days.