Attachments
Attach files to an email, with the size and type limits.
Attach files to an email with the attachments field. Each file has a filename and its content in base64.
Attach a file
Encode the file
Read the file and turn its bytes into a base64 string.
Add it to the send
Put each file in
attachmentswith its name. The name is what the recipient sees.curl -X POST https://app.usenotix.dev/api/v1/emails \ -H "Authorization: Bearer $NOTIX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "from": "Acme <billing@acme.com>", "to": "customer@example.com", "subject": "Your invoice INV-2026-0142", "text": "Your invoice is attached.", "attachments": [ { "filename": "INV-2026-0142.pdf", "content": "'"$(base64 < INV-2026-0142.pdf | tr -d '\n')"'" } ] }'import { readFile } from "node:fs/promises"; import { Notix } from "notix-js"; const notix = new Notix(process.env.NOTIX_API_KEY); const pdf = await readFile("INV-2026-0142.pdf"); const { data, error } = await notix.emails.send({ from: "Acme <billing@acme.com>", to: "customer@example.com", subject: "Your invoice INV-2026-0142", text: "Your invoice is attached.", attachments: [{ filename: "INV-2026-0142.pdf", content: pdf.toString("base64") }], });import base64 from notix import Notix notix = Notix() # reads NOTIX_API_KEY with open("INV-2026-0142.pdf", "rb") as f: content = base64.b64encode(f.read()).decode("ascii") data, error = notix.emails.send({ "from": "Acme <billing@acme.com>", "to": "customer@example.com", "subject": "Your invoice INV-2026-0142", "text": "Your invoice is attached.", "attachments": [{"filename": "INV-2026-0142.pdf", "content": content}], })use Notix\Notix; $notix = new Notix(getenv('NOTIX_API_KEY')); $email = $notix->emails->send([ 'from' => 'Acme <billing@acme.com>', 'to' => 'customer@example.com', 'subject' => 'Your invoice INV-2026-0142', 'text' => 'Your invoice is attached.', 'attachments' => [ ['filename' => 'INV-2026-0142.pdf', 'content' => base64_encode(file_get_contents('INV-2026-0142.pdf'))], ], ]);
Limits
| Limit | Value |
|---|---|
| Files per email | 10 |
| File name | 255 characters |
| One file | 7 MB |
| All files in one email | 10 MB |
| All files in one batch | 40 MB |
| Whole request body | 20 MB |
Sizes are measured after base64 decoding. Base64 makes a file about a third bigger, so a 7 MB file is about 9.4 MB in the request. A request over a limit is refused with 400, and the message names the limit. Nothing is sent or charged.
Notix deletes the attachments once the email is sent. They are not kept in your email log. Keep your own copy of anything you need later.
When a file is refused
A receiving mail server can still refuse a message because of what is attached. That shows up as a bounce with the sub type AttachmentRejected in the email.bounced webhook. See Event types.
For large files, a link to a download page often works better than an attachment. It keeps the email small and lands in more inboxes.
Received attachments
This page is about files you send. For files that come in with mail you receive, see Received attachments.