LOOMAL
SDK / API ReferenceMessages

Attachments

Send and download email attachments

Loomal supports file attachments on both inbound and outbound emails. Attachment metadata is returned on every message and thread response. Binary content is fetched via a dedicated download endpoint.

Limits

LimitValue
Per attachment10 MB
Per email (total)25 MB
Per email (count)10 attachments

Sending attachments

POST /v0/messages/send and POST /v0/messages/:id/reply accept an attachments array. Each attachment carries the file content as base64.

{
  "to": ["user@example.com"],
  "subject": "Quarterly report",
  "text": "See attached.",
  "attachments": [
    {
      "filename": "Q1-report.pdf",
      "contentType": "application/pdf",
      "data": "JVBERi0xLjQKJeLjz9MK..."
    }
  ]
}
FieldTypeDescription
filenamestringDisplay name (max 255 chars)
contentTypestringMIME type (e.g. application/pdf, image/png)
datastringBase64-encoded file content

Attachment metadata in responses

GET /v0/messages, GET /v0/messages/:id, GET /v0/threads/:id, and the send/reply responses all include an attachments array per message:

{
  "messageId": "<abc@mailgent.dev>",
  "subject": "Quarterly report",
  "...": "...",
  "attachments": [
    {
      "attachmentId": "cm9k2x4f80001abc",
      "filename": "Q1-report.pdf",
      "contentType": "application/pdf",
      "size": 2148532,
      "inline": false,
      "contentId": null,
      "createdAt": "2026-04-07T12:00:00.000Z"
    }
  ]
}

Downloading attachment bytes

Scope: mail:read

Streams the raw file bytes with the original Content-Type and a Content-Disposition: attachment header.

Request

mail.get_attachment(message_id, attachment_id)

The MCP tool returns the file as base64 inside the JSON-RPC response so the agent can process it immediately without a separate HTTP call. Available through @loomal/mcp — see MCP setup.

curl -O \
  -H "Authorization: Bearer loid-your-api-key" \
  https://api.loomal.ai/v0/messages/%3Cabc%40mailgent.dev%3E/attachments/cm9k2x4f80001abc

The messageId must be URL-encoded (it contains <>@).

The Node and Python SDKs do not expose attachment downloads — call REST directly or use the MCP tool.

Endpoint

GET /v0/messages/{messageId}/attachments/{attachmentId}

Errors

StatusCodeDescription
404not_foundAttachment doesn't exist or doesn't belong to the message/inbox

On this page