messageNew
The messageNew webhook event is triggered when EmailEngine detects a new email in a monitored mailbox folder. This is one of the most commonly used webhook events, enabling real-time processing of incoming emails.
When This Event is Triggered
The messageNew event fires when:
- A new email arrives in a synced mailbox (INBOX, Sent, or any other monitored folder)
- An existing email is moved into a monitored folder from another folder
- An email is copied into a monitored folder
- Initial sync discovers emails not previously seen by EmailEngine
The event is triggered after EmailEngine has fetched and parsed the message metadata from the IMAP server.
Common Use Cases
- Support ticket creation - Automatically create tickets from incoming support emails
- Lead capture - Process inquiry emails and add contacts to your CRM
- Order processing - Parse order confirmation emails
- AI analysis - Feed incoming emails to language models for classification or summarization
- Email archival - Store emails in external databases or document management systems
- Notification forwarding - Send alerts via Slack, SMS, or other channels
- Spam filtering - Apply custom spam detection rules
Payload Schema
Top-Level Fields
| Field | Type | Required | Description |
|---|---|---|---|
serviceUrl | string | No | The configured EmailEngine service URL |
account | string | Yes | Account ID that received the message |
date | string | Yes | ISO 8601 timestamp when the webhook was generated |
path | string | Yes | Mailbox folder path (e.g., "INBOX", "Sent Mail") |
specialUse | string | No | Special use flag of the folder (e.g., "\Inbox", "\Sent", "\Trash") |
event | string | Yes | Event type, always "messageNew" for this event |
data | object | Yes | Message data object (see below) |
Note: The unique event identifier is sent as the HTTP header X-EE-Wh-Event-Id, not in the JSON payload.
Message Data Fields (data object)
| Field | Type | Required | Description |
|---|---|---|---|
id | string | Yes | EmailEngine's unique message ID (base64url encoded) |
uid | number | Yes | IMAP UID of the message within the folder |
path | string | No | Mailbox folder path |
emailId | string | No | IMAP EMAILID (if supported by server) |
threadId | string | No | Thread identifier for conversation threading |
date | string | Yes | Message date from headers (ISO 8601) |
flags | array | No | Array of IMAP flags (e.g., ["\Seen", "\Flagged"]) |
labels | array | No | Gmail labels (Gmail accounts only) |
unseen | boolean | No | True if message has not been read |
flagged | boolean | No | True if message is flagged/starred |
answered | boolean | No | True if message has been replied to |
draft | boolean | No | True if message is a draft |
size | number | No | Message size in bytes |
subject | string | No | Email subject line (decoded) |
from | object | No | Sender address object |
replyTo | array | No | Reply-To addresses |
sender | object | No | Sender header (if different from From) |
to | array | No | Recipient addresses |
cc | array | No | CC recipient addresses |
bcc | array | No | BCC recipient addresses (rarely available) |
messageId | string | No | Message-ID header value |
inReplyTo | string | No | In-Reply-To header for threading |
attachments | array | No | List of attachment objects |
headers | object | No | Selected email headers (if configured) |
text | object | No | Text content object |
bounces | array | No | Associated bounce information |
isAutoReply | boolean | No | True if detected as auto-reply |
seemsLikeNew | boolean | No | True if message appears genuinely new (not moved/copied) |
category | string | No | Message category (e.g., "primary", "social", "promotions") |
messageSpecialUse | string | No | Special use tag (e.g., "\Inbox", "\Sent", "\Junk") |
calendarEvents | array | No | Parsed calendar event data (if enabled) |
summary | object | No | AI-generated summary (if OpenAI integration enabled) |
riskAssessment | object | No | AI-generated risk assessment (if enabled) |
embeddings | object | No | AI-generated embeddings (if enabled) |