Sluice Docs

Sending with attachments

Sluice supports file attachments via the REST API using base64-encoded content in JSON — the same model used by Resend and other modern email APIs.

Attachment format

Each attachment is an object with filename and content (base64-encoded):

{
  "attachments": [
    {
      "filename": "invoice.pdf",
      "content": "<base64-encoded content>"
    }
  ]
}

curl example

curl -X POST https://app.sluice.email/api/v1/emails \
  -H "Authorization: Bearer sl_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "from": "agent@yourdomain.com",
    "to": "customer@example.com",
    "subject": "Your invoice",
    "text": "Please find your invoice attached.",
    "attachments": [
      {
        "filename": "invoice.pdf",
        "content": "<base64-encoded content>"
      }
    ]
  }'

Node.js example

Read a file from disk, base64-encode it, and send:

import fs from 'fs'
 
const content = fs.readFileSync('./invoice.pdf').toString('base64')
 
await fetch('https://app.sluice.email/api/v1/emails', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer sl_live_...',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    from: 'agent@yourdomain.com',
    to: 'customer@example.com',
    subject: 'Your invoice',
    text: 'Please find your invoice attached.',
    attachments: [{ filename: 'invoice.pdf', content }],
  }),
})

Python example

import base64
import requests
import os
 
with open("./invoice.pdf", "rb") as f:
    content = base64.b64encode(f.read()).decode("utf-8")
 
requests.post(
    "https://app.sluice.email/api/v1/emails",
    headers={
        "Authorization": f"Bearer {os.environ['SLUICE_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "from": "agent@yourdomain.com",
        "to": "customer@example.com",
        "subject": "Your invoice",
        "text": "Please find your invoice attached.",
        "attachments": [{"filename": "invoice.pdf", "content": content}],
    },
)

Multiple attachments

Include multiple objects in the attachments array:

{
  "attachments": [
    { "filename": "invoice.pdf", "content": "<base64>" },
    { "filename": "receipt.pdf", "content": "<base64>" }
  ]
}

Limits and constraints

10 MB total payload limit. The entire request body — including all base64-encoded attachments — must be under 10 MB. Base64 encoding increases file size by approximately 33%, so the effective file size limit is roughly 7.5 MB of original file data.

Attachment content is not inspected by guardrails. Guardrails analyze email text and HTML content only. File attachments pass through without content inspection. If your organization requires attachment review, enable the Attachment Scanning guardrail to flag emails with attachments for human review.

On this page