This topic primarily focuses on downloading attachments from the API. For information about sending attachments in API requests, refer to the Attachments topic in our Core API guides.
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.
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.
API rate limit
Downloading attachments will count against your API rate limiting.
Even though all the API is designed to work with JSON, some endpoints support file upload:
- Create outbound conversation
- Reply to Conversation
- Receive custom messages
- Import message
- Create contact
- Update a contact
- Create draft conversation
- Create draft reply
Set the header appropriately
When you want to send files through the API, your request needs to be sent using the
Content-Type HTTPheader set to
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 suffix
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.
You can read more about attachments on the Attachments page in our Core API guides.