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.
AttachmentsTo 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).AttachmentsTo 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.
MessageIf you know the Message an Attachment belongs to, you can retrieve it directly.
ThreadSimilarly, you can retrieve an Attachment if you know the Thread it’s in, which can be more convenient for multi-message conversations.
Copy one of the blocks below into Cursor or Claude for complete Attachments usage in one shot.