Skip to content
emailkit
Esc
navigateopen⌘Jpreview
On this page

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

PropType
emailDriver?string

EmailKit driver id that produced this event, attached by the EmailKit client.

Typestring
schemaVersion?"1"

Schema version for forward-compat

Type"1"
eventId?string

Unique event identifier for dedupe

Typestring
messageIdstring

Unique message identifier from the email provider

Typestring
providerId?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.

Typestring
fromEmailAddress

Sender email address

TypeEmailAddress
toEmailAddress[]

Recipient email addresses

TypeEmailAddress[]
cc?EmailAddress[]

Carbon copy recipients (if available)

TypeEmailAddress[]
bcc?EmailAddress[]

Blind carbon copy recipients (if available)

TypeEmailAddress[]
replyReplyContext

Thread metadata, mirroring the outbound `reply` shape.

TypeReplyContext
subjectstring

Email subject

Typestring
text?string

Plain text body (if available)

Typestring
html?string

HTML body (if available)

Typestring
strippedText?string

Plain text body stripped of quoted content (if provided)

Typestring
strippedHtml?string

HTML body stripped of quoted content (if provided)

Typestring
attachments?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

TypeAttachment[]
headersRecord<string, string>

Email headers as key-value pairs

TypeRecord<string, string>
timestampDate

Timestamp when the email was received

TypeDate
raw?unknown

Provider-specific raw data (for debugging or advanced use cases)

Typeunknown

Last updated on July 24, 2026

Was this page helpful?