Email Message
An Email Message is a record of an email sent or received through AM’s email infrastructure.
Schema
interface EmailMessage {
id: string; // "eml_..." - Unique identifier
account_id: string; // Owning account
hostname: string; // Sending domain
direction: "in" | "out"; // Inbound or outbound
from_contact: EmailContact;
reply_to_contacts: EmailContact[];
to_contacts: EmailContact[];
cc_contacts: EmailContact[];
bcc_contacts: EmailContact[];
subject: string;
body_text: string;
body_html: string;
received_at: string | null;
sent_at: string | null;
}
interface EmailContact {
email: string;
name?: string;
}
Properties
| Property | Type | Description |
|---|---|---|
id | string | KSUID with eml_ prefix |
account_id | string | Account that owns message |
hostname | string | Domain used for sending |
direction | enum | in for received, out for sent |
from_contact | object | Sender information |
reply_to_contacts | array | Reply-to contacts |
to_contacts | array | Primary recipients |
cc_contacts | array | CC recipients |
bcc_contacts | array | BCC recipients |
subject | string | Email subject line |
body_text | string | Plain text content |
body_html | string | HTML content |
received_at | string? | When inbound email was received |
sent_at | string? | When outbound email was sent |
Example
{
"id": "eml_2kHfPZcN9xW4mE8RtY7vB",
"account_id": "acc_1jGePYbM8wV3lD7QsX6uA",
"hostname": "mail.example.com",
"direction": "out",
"from_contact": {
"email": "noreply@example.com",
"name": "Acme Corp"
},
"reply_to_contacts": [],
"to_contacts": [{ "email": "user@example.com", "name": "Jane Doe" }],
"cc_contacts": [],
"bcc_contacts": [],
"subject": "Welcome to Acme",
"body_text": "Welcome...",
"body_html": "<h1>Welcome</h1>...",
"sent_at": "2025-01-15T10:30:00Z"
}
Related
- Email Message Event - Delivery tracking
- Email Template - Reusable templates
- Email - Email infrastructure