Email JSON Reference
This is the complete reference for the email JSON format used in the outbox pattern.
Full schema
Section titled “Full schema”{ "subject": "Email subject line", "body": "Plain text email body", "attachments": [ { "filename": "report.pdf", "content": "base64-encoded-content" } ], "log": "attachment", "log_content": "Custom log content", "status": "pending"}Field reference
Section titled “Field reference”to (required)
Section titled “to (required)”Array of recipient email addresses.
At least one recipient is required.
cc (optional)
Section titled “cc (optional)”Array of CC (carbon copy) recipients.
bcc (optional)
Section titled “bcc (optional)”Array of BCC (blind carbon copy) recipients.
subject (required)
Section titled “subject (required)”Email subject line. Plain text string.
"subject": "Re: Your question about APIs"For replies, include “Re: ” prefix to maintain threading.
body (required)
Section titled “body (required)”Email body. Plain text string.
"body": "Hello!\n\nHere's the information you requested.\n\nBest,\nYour Agent"Use \n for newlines. HTML is not supported.
in_reply_to (optional)
Section titled “in_reply_to (optional)”Message-ID of the email being replied to. Used for threading.
Include angle brackets. This header tells email clients which message you’re replying to.
references (optional)
Section titled “references (optional)”Space-separated list of Message-IDs in the thread. Used for threading.
Should include all Message-IDs in the thread, oldest first.
attachments (optional)
Section titled “attachments (optional)”Array of file attachments.
"attachments": [ { "filename": "report.pdf", "content": "JVBERi0xLjQKJeLjz9..." }, { "filename": "data.csv", "content": "bmFtZSxhZ2UKQWxpY2..." }]Each attachment has:
filename— Name shown to recipientcontent— Base64-encoded file contents
log (optional)
Section titled “log (optional)”Controls session log inclusion. Values:
"attachment"— Include log as attachment"inline"— Include log in email body"none"— No log (default)
"log": "attachment"log_content (optional)
Section titled “log_content (optional)”Custom content for the log (when log is set).
"log_content": "Session summary: discussed API integration..."status (required)
Section titled “status (required)”Always set to "pending" when creating the file.
"status": "pending"The platform updates this to "sent" or "failed" after processing.
Examples
Section titled “Examples”Simple reply
Section titled “Simple reply”{ "subject": "Re: Question", "body": "The answer is 42.", "status": "pending"}Email with attachment
Section titled “Email with attachment”{ "subject": "Report attached", "body": "Please find the report attached.\n\nLet me know if you have questions.", "attachments": [ { "filename": "monthly-report.pdf", "content": "JVBERi0xLjQK..." } ], "status": "pending"}Multi-recipient with CC
Section titled “Multi-recipient with CC”{ "subject": "Weekly Update", "body": "Here's the weekly summary...", "status": "pending"}Threaded reply
Section titled “Threaded reply”{ "subject": "Re: Project Discussion", "body": "Good point! Let me address each item...", "status": "pending"}File naming
Section titled “File naming”Save JSON files to /data/outbox/email/ with unique names:
- Timestamp:
1704379200000.json - UUID:
a1b2c3d4-e5f6-7890-abcd-ef1234567890.json - Sequential:
email-001.json
The agent typically uses timestamps.
Processing
Section titled “Processing”After the agent exits:
- Queue worker lists
/data/outbox/email/ - Reads each
.jsonfile - Appends session footer to body
- Sends via Resend API
- Moves file to
sent/orfailed/
Files are processed in creation order.
After sending
Section titled “After sending”{ ...original fields..., "status": "sent", "sent_at": "2026-01-04T12:00:00Z", "resend_id": "re_abc123"}failed/
Section titled “failed/”{ ...original fields..., "status": "failed", "error": "Invalid recipient: bad@invalid", "failed_at": "2026-01-04T12:00:00Z"}Session footer
Section titled “Session footer”The platform automatically appends:
---[buddy:a1b2 | ↑38 ↓5.0k R663k W37k $0.687 18.7%/200k | claude-haiku-4-5]You don’t need to add this — it’s injected during processing.
Encoding attachments
Section titled “Encoding attachments”import base64
with open('report.pdf', 'rb') as f: content = base64.b64encode(f.read()).decode('utf-8')Preserving threading
Section titled “Preserving threading”Always include in_reply_to and references when replying. The platform provides these in the input message.
Multiple emails
Section titled “Multiple emails”You can write multiple files to the outbox. They’ll all be sent.