Skip to main content
You can send transactional emails with one or more file attachments using the thePurplebox API.
This is useful for delivering invoices, reports, receipts, or any other documents generated by your application.

Prerequisites

  • A thePurplebox account
  • A secret API key generated from your dashboard
  • A verified sending domain (recommended for best deliverability)

Parameters

When sending an email with attachments, include the following in your request:
  • to — A single email address or array of recipient emails
  • subject — The email subject line
  • body — Plain text or HTML content for the email body
  • attachments — An array of attachment objects (up to 5 files):
    • filename — The name of the file as it will appear to the recipient
    • content — Base64-encoded file data
    • contentType — MIME type (e.g., application/pdf, image/png)

Important Notes

  • You can attach up to 5 files per email
  • The content field must be base64 encoded
  • Maximum attachment size per file is 5MB
  • Total email size (including all attachments) must not exceed 25MB

Example Requests

  • JavaScript
  • Go
  • Python
  • PHP
  • Java
  • Ruby
  • C#
  • ASP.NET
  • cURL
await fetch('https://api.thepurplebox.io/v1/send', {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    "Authorization": "Bearer <API_KEY>"
  },
  body: JSON.stringify({
    to: "[email protected]",
    subject: "Your requested document",
    body: "Please find the attached file.",
    attachments: [
      {
        filename: "document.pdf",
        content: "<BASE64_ENCODED_CONTENT>",
        contentType: "application/pdf"
      }
    ]
  })
})