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

> ## Agent Instructions
> AhaSend stores all message data in the EU. See /facts.
> The API base URL is https://api.ahasend.com. Send the API key in the Authorization: Bearer header. See /api-reference/authentication.
> Use send.ahasend.com for SMTP. Ports 25, 587 and 2525 use STARTTLS. Port 465 is not supported. See /smtp.
> For send-only integrations, create an API Key v2 under Credentials → Add and scope it to messages:send:{your-domain}. See /send-api/credentials and /api-reference/scopes.

# Attachments

> Send files with your emails through the API or SMTP: PDFs, calendar invites and other documents, with the fields, encoding rules and size limits explained.

You can add files to any email you send through AhaSend: an invoice as a PDF, a calendar invite as an `.ics` file, a CSV export. Over the API you put each file in the `attachments` array of the request; over SMTP you attach files the way your mail library already does.

Available on Free, Pro and Max. See [plans and features](https://ahasend.com/docs/facts.md#plans-and-features).

## How do I attach a file with the API?

Add an `attachments` array to your [Create Message](https://ahasend.com/docs/api-reference/messages/create-message.md) request. Each attachment has a file name, a content type and the file's content in `data`.

```bash theme={null}
curl --request POST \
  --url https://api.ahasend.com/v2/accounts/{account_id}/messages \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
    "sandbox": true,
    "from": { "email": "billing@yourdomain.com", "name": "Your Company" },
    "recipients": [{ "email": "customer@example.com" }],
    "subject": "Your invoice",
    "html_content": "<p>Your invoice is attached.</p>",
    "attachments": [
      {
        "file_name": "invoice.pdf",
        "content_type": "application/pdf",
        "base64": true,
        "data": "JVBERi0xLjcKJcOkw7zDtsOfCjIgMCBvYmoK..."
      }
    ]
  }'
```

The `data` value in this example is shortened; send the complete base64 string of your file.

| Field | Required | Description |
| - | - | - |
| `file_name` | Yes | The name the recipient sees, for example `invoice.pdf`. |
| `content_type` | Yes | The MIME type, for example `application/pdf`, `text/calendar` or `text/csv`. |
| `data` | Yes | The file's content: base64-encoded when `base64` is `true`, otherwise read as UTF-8 text. |
| `base64` | No | Set to `true` for binary files such as PDFs, images and archives. Defaults to `false`. |
| `content_disposition` | No | The disposition of the attachment. |
| `content_id` | No | Shows the file inside the message instead of as a download; see [Inline images](https://ahasend.com/docs/send-api/inline-images.md). |

Attachments work the same way with [Create Template Message](https://ahasend.com/docs/api-reference/messages/create-template-message.md) and [Create Conversation Message](https://ahasend.com/docs/api-reference/messages/create-conversation.md).

## How do I send a calendar invite?

An `.ics` file is plain text, so it can go in `data` without encoding:

```json theme={null}
{
  "file_name": "appointment.ics",
  "content_type": "text/calendar",
  "data": "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//Your Company//Booking//EN\r\nBEGIN:VEVENT\r\nUID:booking-1234@yourdomain.com\r\nDTSTART:20261120T090000Z\r\nDTEND:20261120T093000Z\r\nSUMMARY:Your appointment\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"
}
```

## How do I send attachments over SMTP?

Attach files with your mail library as usual when you send through the [SMTP relay](https://ahasend.com/docs/smtp.md). AhaSend sends the message as you built it and doesn't change its MIME structure.

## How large can attachments be?

| Limit | Value |
| - | - |
| Complete message | 20 MiB, including headers, body and all attachments after base64 encoding |
| API request body | 30 MB |
| Per attachment | No separate limit |

Base64 makes a file about a third larger, so a 15 MB PDF is already close to the limit once encoded. For large files, send a download link instead: the message stays small and lands more reliably in the inbox.

## Can I receive attachments on incoming mail?

Yes. [Message routes](https://ahasend.com/docs/integrations/routing.md) can include the attachments of incoming messages in the payload they send to your endpoint, base64-encoded with their file name, content type and Content-ID.

## Related guides

* [Send email](https://ahasend.com/docs/send-api/send-email.md), [Inline images](https://ahasend.com/docs/send-api/inline-images.md), [Create Message reference](https://ahasend.com/docs/api-reference/messages/create-message.md).
* [SMTP settings](https://ahasend.com/docs/smtp.md), [Message routing](https://ahasend.com/docs/integrations/routing.md), [Sending limits](https://ahasend.com/docs/send-api/send-email.md#limits).


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