Brevo Base64 attachments and CID images

Adding a Base64 attachment to a Brevo transactional email does not by itself make that attachment an inline image. An HTML reference such as <img src="cid:logo001"> needs a matching Content-ID in the email's MIME structure.

The public transactional API schema checked on October 8, 2026, documents attachment url, content, and name fields. It does not expose a caller-controlled Content-ID field in that attachment object. Do not invent a cid or contentId field and assume it will work.

You can prepare a raw Base64 attachment with the Image to Base64 tool. For an image displayed inside the message, the example below uses an HTTPS image URL and keeps the Base64 file as an ordinary attachment.

Attachment or inline: the distinction that decides the outcome

The two words get used interchangeably, and that is where the trouble starts. An attachment is a MIME part marked Content-Disposition: attachment. A mail client lists it under the message and offers a save button. An inline image is a MIME part marked inline that also carries a Content-ID header, and the HTML points at that identifier with cid:. Both live inside the message. Neither is a data URI, which puts the bytes in the src attribute and needs no separate part at all.

Skip that distinction and you get the outcome this page is named after: the file arrives, the picture does not.

What the transactional API documents

For POST /v3/smtp/email, Brevo documents two attachment sources: an absolute file URL, or Base64 content. When you provide content, also provide the filename in name.

These fields describe an attachment. They are not a documented way to bind an HTML cid: reference. A setting from another Brevo product or a different provider is not automatically part of this transactional endpoint's contract. If CID is essential to your delivery workflow, confirm the currently supported method with Brevo or use a provider that documents the required CID fields, such as the SendGrid inline-image API.

How the no-CID failure looks on the receiving end

Three symptoms show up, all tracing back to the same missing link between the HTML and a MIME part. The recipient sees a paperclip and a file listed below the body, with no image above it. Or the <img> renders as a broken icon showing the alt text. Or the space collapses entirely because the client refuses to resolve an image it cannot find and remote content is still blocked.

None of these is a transport failure. The API answered with a message ID because the message was well formed; it simply contained no part matching the identifier the HTML referred to. Reading the API response as evidence of rendering is the mistake that makes this loop take longer than it should.

What a working inline image looks like in MIME

The mechanism is older than any of these APIs. The message becomes multipart/related, the HTML is one part, and the image is another with Content-ID: <logo001> and Content-Disposition: inline. The HTML then says <img src="cid:logo001">, and the client matches the two. Some APIs let the caller set that identifier directly; the Postmark inline image guide shows the field names for one that does. The public Brevo attachment object documents a filename, a URL, and encoded content, with no caller-controlled Content-ID, so on this endpoint the identifier is not yours to set.

A hosted image plus a Base64 attachment

Save this as brevo-attachment.mjs. It requires Node.js 18 or later and a local logo.png. Set IMAGE_URL to a public HTTPS image you control. The default command prints JSON; adding --send makes an actual request.

import { readFile } from "node:fs/promises";

const imageUrl = new URL(process.env.IMAGE_URL || "https://example.com/logo.png");
if (imageUrl.protocol !== "https:") throw new Error("IMAGE_URL must use HTTPS");
const bytes = await readFile("logo.png");
const safeImageUrl = imageUrl.href.replaceAll("&", "&amp;").replaceAll('"', "&quot;");
const payload = {
  sender: { email: process.env.EMAIL_FROM || "sender@example.com" },
  to: [{ email: process.env.EMAIL_TO || "recipient@example.com" }],
  subject: "Image and attachment example",
  htmlContent: `<p>Your image:</p><img src="${safeImageUrl}" alt="Company logo">`,
  textContent: "This message includes a hosted image and a PNG attachment.",
  attachment: [{ content: bytes.toString("base64"), name: "logo.png" }]
};

if (!process.argv.includes("--send")) {
  console.log(JSON.stringify(payload, null, 2));
} else {
  const key = process.env.BREVO_API_KEY;
  if (!key || !process.env.EMAIL_FROM || !process.env.EMAIL_TO || !process.env.IMAGE_URL) {
    throw new Error("Set BREVO_API_KEY, EMAIL_FROM, EMAIL_TO, and IMAGE_URL first.");
  }
  const response = await fetch("https://api.brevo.com/v3/smtp/email", {
    method: "POST",
    headers: { "api-key": key, "Content-Type": "application/json", "Accept": "application/json" },
    body: JSON.stringify(payload)
  });
  const result = await response.json();
  if (!response.ok) throw new Error(`Brevo request failed: ${JSON.stringify(result)}`);
  console.log(result.messageId);
}

https://example.com/logo.png is a placeholder, not a working image asset. The real image must be reachable without your private login. Recipients' mail clients may block remote images until the user allows them. Keep credentials on your server, and test the intended clients before relying on the visual result.

Raw Base64 is not a data URI

The content field holds the encoded file bytes. Do not include data:image/png;base64, in that field, and do not Base64-encode a string that is already Base64. Use the API payload guide when converting between output shapes.

A browser can render a data URI even when an email client strips it. Switching the HTML source to a data URI is therefore not a reliable substitute for a supported inline-attachment workflow. The Outlook image guide covers this compatibility distinction.

Base64 in a JSON body inflates the request

The attachment field holds a JSON string, so the request carries about four characters for every three bytes of the file. A 900 KB image becomes roughly 1.2 MB of text before any escaping, and the whole body has to fit inside the provider's request limit, a different number from the message size limit applied after delivery. The Base64 size calculator gives the encoded length for a known file size, which is worth checking before a payload fails at the edge.

Multipart uploads avoid part of that cost: an endpoint that accepts multipart sends raw bytes and encodes nothing, so the same image travels smaller. Whether a given provider offers that is a per-provider detail. The transactional JSON endpoint in this guide takes the encoded string, so size the payload around it, or use the url field when the image is already public and the encoding is not needed at all.

Checking what actually arrived

Open the raw source of the received message instead of the rendered view. In Gmail that is “Show original”; other clients put it behind a view-source or save-as menu, and the exact wording varies. On the image part, look for Content-Type: image/png, then Content-Disposition, then Content-ID. A disposition of attachment means the client treats the part as a downloadable file regardless of what the HTML asked for. A missing Content-ID means no cid: reference can resolve at all, which is the case this page describes.

Putting Base64 straight into the HTML has its own compatibility record, covered in Base64 images in HTML email. Neither route works everywhere, and the raw source shows which one your recipient's client actually honored.

Troubleshooting

The attachment arrives but cid:logo001 is blank. The attachment filename is not a Content-ID. The checked schema does not document a field that connects that CID to the attachment. Use a hosted image or confirm a supported CID method before relying on it.

The API rejects the attachment. Inspect raw Base64 versus data URI, the required filename, supported file types, and your current provider limits. Decode the value locally to confirm it contains the intended bytes.

The hosted image does not show. Check the final HTTPS URL without a login, then check the client's image-blocking policy. API acceptance is not proof of rendering.

FAQ

Does this prove that all Brevo email products lack CID support?

No. This guide describes the checked public transactional endpoint. Product capabilities and schemas can change.

Can I add a contentId property anyway?

That would depend on undocumented behavior. Use documented fields or get a supported method confirmed by Brevo.

Do I need Base64 for the hosted image?

No. The hosted image uses an HTTPS URL. Base64 is used separately for the ordinary attachment in this example.

Related guides

Compare SendGrid inline images, review Base64 API output shapes, and check Outlook rendering behavior.