Attachments

When a message has attached files, the attachments array will contain the information needed to retrieve those files.

If the attachment is inline (ie: an image in the body of an email), the property metadata.cid will help you retrieve the HTML tag corresponding to the attachmens in the body of the message.

Download Attachment

In the attachment object, the property url can be used to download the attached file.

Just like any other API endpoint, the download request should be authenticated.
The response however will not be a JSON object but the content of the file with the correct headers so that you can save it.

📘

Downloading attachments will count against your API rate limiting.

File Upload

Even though all the API is designed to work with JSON, some endpoints support file upload:

Send Multipart Request

📘

When you want to send files through the API, your request needs to be sent using the Content-Type HTTP header set to multipart/form-data.

The JSON data you would normally send in the request body needs to be split in multiple form fields (one for each property) named after the property key. If the property is an array, the name should include the index of the data

For example:
{"to": [[email protected], [email protected]]} would be split in two fields, named to[0], to[1].

Restriction on files (type and size) depends on the endpoint. If your request doesn't comply to those limitations, the response will contain an error describing the issue.