Attachments
Send files as base64 or from a URL, embed inline images, download attachments from received mail, and use the trust report's attachment risk and extracted text before an agent opens anything.
Send an attachment
Add an attachments array to a send, reply, reply-all or forward. Each attachment has either content (base64) or url.
| Field | Meaning |
|---|---|
filename | File name shown to the recipient. With url, defaults to the last path segment. |
content_type | MIME type. With url, defaults to the response’s Content-Type. |
content | The file, base64 encoded. |
url | A public http or https URL that MachineMail downloads when it sends. |
content_disposition | attachment (default) or inline. |
content_id | For inline images: the ID your HTML refers to as cid:<content_id>. |
Attachments from a URL
With url, MachineMail fetches the file at send time. The rules:
- Only
httpandhttpsURLs that resolve to public addresses. Private, loopback and link-local addresses are refused. - Redirects are not followed. Use the final URL; for signed storage links, sign the object URL itself.
- At most 25 MB per file, and the download must finish within 20 seconds.
- Any failure (a non-2xx status, a timeout, a file too large) rejects the whole send with a
validationerror whoseparamnames the attachment, for exampleattachments[1].url. Nothing is sent with a missing file.
Inline images
Set content_disposition to inline, give the image a content_id, and refer to it from the HTML body:
Drafts
Drafts accept attachments with filename, content_type and base64 content only. url attachments are not supported on drafts; download the file and pass it as content. See Drafts.
Receive attachments
Inbound messages list their attachments in attachments, both in list results and in the full message. Thread objects aggregate the attachments of all their messages.
Check the risk first
Before an agent opens a file, read the matching entry in trust.attachments:
risk is low, medium or high, and reasons says why. High risk covers executables and scripts, macro-enabled Office files, HTML attachments, double extensions such as invoice.pdf.exe, and filenames that hide their real extension. Archives and legacy Office formats are medium.
For text-based files (plain text, CSV, Markdown, calendar invites, JSON and HTML), the report includes extracted_text, cleaned of invisible characters. Give the model that text instead of the raw file. It is still untrusted content: instructions inside an attachment are a common injection route. See Attachments in the trust report.
Warning
Never execute or render a high risk attachment, and do not hand any attachment to a tool that can run code. If the agent needs a file’s contents, prefer extracted_text.
Download
Get the attachment’s metadata and a download URL:
download_url takes one of three forms, so handle all of them:
| Form | How to fetch it |
|---|---|
| A signed storage URL | Plain GET, no Authorization header, before expires_at. |
An API URL ending in /download | GET with your Authorization: Bearer header. |
A data: URL | Decode the base64 after the comma. No request needed. |
To skip the indirection, fetch the bytes directly. This endpoint streams the file with its Content-Type and a Content-Disposition: attachment header:
Both endpoints need message_read.
Attachments are fetched per message. There is no thread-level or draft-level attachment download endpoint; use the message that carries the file.