email.onInbound
A message arrived at an address you receive on — the full email, normalized.
Fires when a message arrives at an address your setup receives on. The event is the full email — addresses, subject, text and HTML bodies, reply context for threading, headers, and attachments — in the same shape from every provider.
hooks: {
email: {
onInbound: async (email) => {
await prisma.inboundEmail.upsert({
where: { messageId: email.messageId },
create: {
messageId: email.messageId,
from: email.from.email,
subject: email.subject,
text: email.text,
},
update: {},
});
},
},
},
Providers may deliver the same message twice — save by messageId and ignore repeats. For routing setup and fetching attachment content, see Receiving & events.
Payload
emailDriver?string
EmailKit driver id that produced this event, attached by the EmailKit client.
stringschemaVersion?"1"
Schema version for forward-compat
"1"eventId?string
Unique event identifier for dedupe
stringmessageIdstring
Unique message identifier from the email provider
stringproviderId?string
Provider-specific message identifier (in addition to messageId). This is the provider's internal ID for this message, separate from the RFC Message-ID. Useful for provider-specific operations or tracking.
stringfromEmailAddress
Sender email address
EmailAddresstoEmailAddress[]
Recipient email addresses
EmailAddress[]cc?EmailAddress[]
Carbon copy recipients (if available)
EmailAddress[]bcc?EmailAddress[]
Blind carbon copy recipients (if available)
EmailAddress[]replyReplyContext
Thread metadata, mirroring the outbound `reply` shape.
ReplyContextsubjectstring
Email subject
stringtext?string
Plain text body (if available)
stringhtml?string
HTML body (if available)
stringstrippedText?string
Plain text body stripped of quoted content (if provided)
stringstrippedHtml?string
HTML body stripped of quoted content (if provided)
stringattachments?Attachment[]
Unified attachments array. Each attachment can have: - `content`: Attachment content available directly (sent in webhook body) - `url`: URL to fetch attachment (stored separately by provider) - Both: Content available but also stored at URL Inline attachments (referenced in HTML with CID) will have: - `isInline: true` - `contentId` set to the CID value (e.g., "ii_mheuh73y1") Regular attachments will have: - `isInline: false` or undefined - `contentId` may be undefined
Attachment[]headersRecord<string, string>
Email headers as key-value pairs
Record<string, string>timestampDate
Timestamp when the email was received
Dateraw?unknown
Provider-specific raw data (for debugging or advanced use cases)
unknown