Attachments

Attach files to transactional emails from a URL or local file, and embed inline images with Content-ID.

You can attach files to any transactional email sent through the API. There are two ways to include a file: point to a URL where the file is hosted, or pass the file contents directly as a base64-encoded string.

Attaching a file from a URL

If your file is already hosted somewhere, pass its URL in the path field. Sendfully fetches the file when the email is sent. This works well for shared resources like product brochures, webinar slides, or release notes.

curl -X POST https://api.sendfully.com/v1/emails/send \  -H "Authorization: Bearer <token>" \  -H "Content-Type: application/json" \  -d '{    "from": "events@mail.yourdomain.com",    "to": "attendee@example.com",    "subject": "Thanks for joining our webinar",    "html": "<p>Thanks for attending! The slides are attached for your reference.</p>",    "attachments": [      {        "filename": "webinar-slides.pdf",        "path": "https://files.yourdomain.com/webinars/webinar-slides.pdf"      }    ]  }'

The URL must use HTTPS. HTTP URLs are not accepted.

Attaching a local file

To attach a file from your application's filesystem, read it and base64-encode the contents into the content field.

import fs from "node:fs";
const pdf = fs.readFileSync("./invoices/invoice.pdf");
const res = await fetch("https://api.sendfully.com/v1/emails/send", {  method: "POST",  headers: {    Authorization: "Bearer <token>",    "Content-Type": "application/json",  },  body: JSON.stringify({    from: "billing@mail.yourdomain.com",    to: "customer@example.com",    subject: "Your invoice for March",    html: "<p>Please find your invoice for March attached.</p>",    attachments: [      {        filename: "invoice.pdf",        content: pdf.toString("base64"),      },    ],  }),});

Each attachment needs exactly one of content or path.

Inline images with Content-ID

You can embed an image directly in the email body instead of adding it as a downloadable attachment. Set a contentId on the attachment and reference it in your HTML with a cid: URL.

curl -X POST https://api.sendfully.com/v1/emails/send \  -H "Authorization: Bearer <token>" \  -H "Content-Type: application/json" \  -d '{    "from": "notifications@mail.yourdomain.com",    "to": "customer@example.com",    "subject": "Your order has shipped",    "html": "<img src=\"cid:company-logo\" alt=\"Acme Co\" /><p>Your order is on its way.</p>",    "attachments": [      {        "filename": "logo.png",        "path": "https://yourdomain.com/logo.png",        "contentId": "company-logo"      }    ]  }'

The contentId can be any string. Match it exactly between the attachment and the cid: reference in your HTML.

Limitations

Size limit. A single email, including all attachments, cannot exceed 40 MB after base64 encoding.

Blocked file types. Executable file types like .exe, .bat, .js, .vbs, and .msi are not accepted.

Template sends. Attachments are only available when sending with html or text. They can't be used with template-based sends.

What's next?