Attachments
What are Attachments?
An Attachment is a file that is associated with a Message. This can be anything from a PDF invoice to a CSV report or an image(though we don’t recommend sending images in the first email sent. We go more into this in the deliverability section). Your agents can both send Attachments in outgoing Messages and process Attachments from incoming Messages.
Sending Attachments
To send a file, you include it in an Attachments array when sending a Message. Each object in the array represents one file and must have a content property.
content(required): The Base64 encoded content of your file.filename(optional): The name of the file (e.g.,invoice.pdf).content_type(optional): The MIME type of the file (e.g.,application/pdf).
Retrieving Attachments
To retrieve an Attachment, you first need its attachment_id. You can get this ID from the attachments array on a Message object. Once you have the ID, you can download the file.
The API response for getting an attachment is the raw file itself, which you can then save to disk or process in memory.
From a Specific Message
If you know the Message an Attachment belongs to, you can retrieve it directly.
From a Specific Thread
Similarly, you can retrieve an Attachment if you know the Thread it’s in, which can be more convenient for multi-message conversations.
