usend Docs
Sending

Attachments

Attach files to an email and download them later with signed links.

Add files to an email with the attachments array of POST /emails. Each attachment has base64-encoded content.

FieldTypeRequiredDescription
filenamestringYesThe file name shown to the recipient.
contentstringYesThe file content, base64 encoded.
content_typestringNoThe MIME type. Guessed from the file extension when omitted, otherwise application/octet-stream.
Shell
curl -X POST https://api.usend.et/emails \
  -H "Authorization: Bearer us_123456789" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "Acme <[email protected]>",
    "to": ["[email protected]"],
    "subject": "Your invoice",
    "text": "Your invoice is attached.",
    "attachments": [
      {
        "filename": "invoice-1042.pdf",
        "content": "JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoK...",
        "content_type": "application/pdf"
      }
    ]
  }'

To build the request from a file:

Node.js
import { readFile } from 'node:fs/promises';

const pdf = await readFile('invoice-1042.pdf');

await usend.emails.send({
  from: 'Acme <[email protected]>',
  to: ['[email protected]'],
  subject: 'Your invoice',
  text: 'Your invoice is attached.',
  attachments: [{ filename: 'invoice-1042.pdf', content: pdf.toString('base64') }],
});

Limits

  • The decoded attachments of one email may total at most 40 MB. The whole request body may be at most 50 MB; larger requests fail with 413 payload_too_large.
  • Batch emails cannot have attachments.
  • Remote attachments by URL are not supported: send the content.

List and download attachments

The attachments of a sent email are available through the API:

Shell
curl https://api.usend.et/emails/4ef9a417-02e9-4d39-ad75-9611e0fcc33c/attachments \
  -H "Authorization: Bearer us_123456789"
JSON
{
  "object": "list",
  "data": [
    {
      "object": "attachment",
      "id": "2a0c9ce0-3112-4728-976e-47ddcd16a318",
      "filename": "invoice-1042.pdf",
      "content_type": "application/pdf",
      "content_disposition": "attachment",
      "size": 48213,
      "download_url": "https://api.usend.et/attachments/eyJrIjoib3V0Ii...",
      "expires_at": "2026-10-11T10:00:00Z"
    }
  ]
}

download_url is a signed link. It needs no API key, so you can hand it to a browser or a background job, and it expires after one hour (expires_at). After that it returns 403 invalid_download_link: list the attachments again to get a fresh link. Downloads are always served as file downloads, never rendered inline.

Use GET /emails/{id}/attachments/{attachment_id} to get a single attachment.

Note

Attachments are kept for your plan's data retention period, then deleted. See Sandbox and limits.

For attachments of emails you receive, see Receiving attachments.