> ## Documentation Index
> Fetch the complete documentation index at: https://docs.sendbaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Attachments and inline images

> Attach files as base64, embed images inline with a content id, and know the limits.

Pass `attachments` as an array. Each file needs a `filename` and its `content` base64-encoded; `contentType` and `contentId` are optional.

```ts Node.js theme={"dark"}
import { readFile } from "node:fs/promises";

await sendbaze.emails.send({
  from: "orders@yourshop.co.za",
  to: "thandi@example.com",
  subject: "Invoice 1042",
  html: '<p>Your invoice is attached.</p><img src="cid:logo" alt="Yourshop">',
  attachments: [
    { filename: "invoice-1042.pdf", contentType: "application/pdf", content: (await readFile("invoice-1042.pdf")).toString("base64") },
    { filename: "logo.png", contentType: "image/png", contentId: "logo", content: (await readFile("logo.png")).toString("base64") },
  ],
});
```

```python Python theme={"dark"}
import base64

with open("invoice-1042.pdf", "rb") as f:
    invoice = base64.b64encode(f.read()).decode()

requests.post("https://api.sendbaze.com/v1/emails", headers=headers, json={
    "from": "orders@yourshop.co.za",
    "to": "thandi@example.com",
    "subject": "Invoice 1042",
    "html": "<p>Your invoice is attached.</p>",
    "attachments": [{"filename": "invoice-1042.pdf", "contentType": "application/pdf", "content": invoice}],
})
```

```bash cURL theme={"dark"}
curl https://api.sendbaze.com/v1/emails \
  -H "Authorization: Bearer $SENDBAZE_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"from\": \"orders@yourshop.co.za\",
    \"to\": \"thandi@example.com\",
    \"subject\": \"Invoice 1042\",
    \"html\": \"<p>Your invoice is attached.</p>\",
    \"attachments\": [{ \"filename\": \"invoice-1042.pdf\", \"contentType\": \"application/pdf\", \"content\": \"$(base64 -w0 invoice-1042.pdf)\" }]
  }"
```

## Fields

**filename** `string` *required*

Shown to the recipient. Up to 255 characters; path separators are refused.

**content** `string` *required*

The file, base64-encoded (standard alphabet; line breaks are tolerated).

**contentType** `string` (default: application/octet-stream)

The MIME type, for example `application/pdf` or `image/png`. Set it so mail clients open the file correctly.

**contentId** `string`

Makes the file an inline part. Reference it from the HTML as `<img src="cid:logo">`. Letters, digits, `.`, `_`, `@` and `-`.

## Limits

* **10 files** per email.
* **3 MB decoded** in total per email. Over that the request is a `413 payload_too_large` and nothing is queued. For larger files, link to a download.
* Files are stored encrypted for 30 days, the same window as message bodies, then deleted.
* The message object lists each attachment's `filename`, `contentType` and `size`, never the bytes.

> [!WARNING]
>
> Executable and script files (`.exe`, `.js`, `.bat`, `.vbs` and similar) are blocked by most mail providers regardless of what the API accepts. Send a link instead.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.