Raw MIME storage

Resend’s signed raw.download_url expires in about an hour. MailAgent downloads the full .eml at ingest and stores it in Cloudflare R2 until the inbox is deleted or TTL expires.

Why

API

GET /v1/inboxes/:inboxId/messages
→ { "messages": [{ "id": "…", "hasRaw": true, "rawUrl": "/v1/inboxes/…/messages/…/raw" }] }

GET /v1/inboxes/:inboxId/messages/:messageId/raw
→ Content-Type: message/rfc822

GET …/raw  Accept: application/json
→ { "sizeBytes": 1234, "filename": "message-….eml" }

Self-host setup

Enable R2 in the Cloudflare Dashboard first, then:

npx wrangler r2 bucket create mailagent-raw-mime
npm run deploy

Binding RAW_MIME is defined in wrangler.jsonc. Optional env RAW_MIME_MAX_BYTES (default 15MB).

Lifecycle

Raw files are removed when you delete an inbox, bulk-delete by labelPrefix, or when the hourly TTL cron purges expired inboxes.

← API docs · Full reference