Attachments
Attach files to an email by URL or by uploading them with multipart/form-data.
You can attach files in two ways: give OpenMail their URLs, or upload them with the request.
Attach files by URL
Add attachments, a list of objects with name (the file name in the email) and url:
curl -H "x-token: YOUR_TOKEN" -H "content-type: application/json" -d '{
"id": "demo/invoice",
"to": "jane@example.com",
"data": { "number": "2026-002", "total": 80 },
"attachments": [
{ "name": "invoice-2026-002.pdf", "url": "https://files.example.com/invoices/2026-002.pdf" }
]
}' https://mail.example.com/{"success":true}OpenMail downloads every file before it sends the email, so the URL must be reachable from the OpenMail server. Make sure the URL works: if it answers with an error page, that page is attached under the name you gave.
Upload files with multipart/form-data
Send the fields as form fields and the files as file fields. data (and attachments, if you use it) must be JSON text:
curl -H "x-token: YOUR_TOKEN" \
-F "id=demo/invoice" \
-F "to=jane@example.com" \
-F 'data={"number":"2026-002","total":80}' \
-F "file=@invoice-2026-002.pdf" \
https://mail.example.com/{"success":true}Every uploaded file becomes an attachment with its own file name. You can upload several files in one request.
Size limit
A multipart request can be at most about 1 MB (1024 kB) in total. A bigger request is refused with status 431. For bigger files, use attachments by URL.