Webhook Payload

When MyMX receives an email for your domain, it sends a POST request to your webhook endpoint with the following JSON payload. The Content-Type is always application/json.

EmailReceivedEvent* = required
FieldTypeDescription
idreqstringUnique delivery event ID.
eventreq"email.received"Event type identifier. Always `"email.received"` for this event type.
versionreqWebhookVersionAPI version in date format (YYYY-MM-DD). Use this to detect version mismatches between webhook and SDK.
deliveryreqobjectMetadata about this webhook delivery.
endpoint_idreqstringID of the webhook endpoint receiving this event. Matches the endpoint ID from your MyMX dashboard.
attemptreqnumberDelivery attempt number, starting at 1. Increments with each retry if previous attempts failed.
attempted_atreqstringISO 8601 timestamp (UTC) when this delivery was attempted.
emailreqobjectThe email that triggered this event.
idreqstringUnique email ID in MyMX. Use this ID when calling MyMX APIs to reference this email.
received_atreqstringISO 8601 timestamp (UTC) when MyMX received the email.
smtpreqobjectSMTP envelope information. This is the "real" sender/recipient info from the SMTP transaction, which may differ from the headers (e.g., BCC recipients).
helostring | nullHELO/EHLO hostname from the sending server. Null if not provided during SMTP transaction.
mail_fromreqstringSMTP envelope sender (MAIL FROM command). This is the bounce address, which may differ from the From header.
rcpt_toreqstring[]SMTP envelope recipients (RCPT TO commands). All addresses that received this email in a single delivery.
headersreqobjectParsed email headers. These are extracted from the email content, not the SMTP envelope.
message_idstring | nullMessage-ID header value. Null if the email had no Message-ID header.
subjectstring | nullSubject header value. Null if the email had no Subject header.
fromreqstringFrom header value. May include display name: `"John Doe" <john@example.com>`
toreqstringTo header value. May include multiple addresses or display names.
datestring | nullDate header value as it appeared in the email. Null if the email had no Date header.
contentreqobjectRaw email content and download information.
rawreqRawContentRaw email in RFC 5322 format. May be inline (base64) or download-only depending on size.
downloadreqobjectDownload information for the raw email. Always present, even if raw content is inline.
parsedreqParsedDataParsed email content (body text, HTML, attachments). Check `status` to determine if parsing succeeded.
ParsedDataCompleteobjectParsed email content when parsing succeeded.
ParsedDataFailedobjectParsed email content when parsing failed.
analysisreqEmailAnalysisEmail analysis and classification results.
spamassassinobjectSpamAssassin analysis results.
forwardForwardAnalysisForward detection and analysis results.
authreqEmailAuthEmail authentication results (SPF, DKIM, DMARC).
spfreqSpfResultSPF verification result.
dmarcreqDmarcResultDMARC verification result.
dmarcPolicyDmarcPolicyDMARC policy from the sender's DNS record.
dmarcFromDomainstring | nullThe organizational domain used for DMARC lookups.
dmarcSpfAlignedreqbooleanWhether SPF aligned with the From: domain for DMARC purposes.
dmarcDkimAlignedreqbooleanWhether DKIM aligned with the From: domain for DMARC purposes.
dmarcSpfStrictboolean | nullWhether DMARC SPF alignment mode is strict.
dmarcDkimStrictboolean | nullWhether DMARC DKIM alignment mode is strict.
dkimSignaturesreqDkimSignature[]All DKIM signatures found in the email with their verification results.

Notes

Delivery & retries

The delivery.attempt field indicates which delivery attempt this is (1-6). If your endpoint returns a non-2xx response or is unreachable, we automatically retry up to 6 times over approximately 10 hours:

  1. Immediate (first attempt)
  2. +60 seconds (inline retry)
  3. +5 minutes
  4. +30 minutes
  5. +2 hours
  6. +8 hours

The first two attempts happen immediately. Attempts 3-6 are scheduled and may vary by up to 5 minutes.

The id field stays the same across all retry attempts for the same email, so you can use it for idempotency. If you receive a webhook you've already processed, just return 2xx to acknowledge it.

Raw email content

The raw email is included inline (base64-encoded) if it's smaller than 256KB. For larger emails, raw.included will be false and you'll need to fetch it from download.url.

Attachments

Attachment metadata is always included in the payload. To download the actual files, fetch the attachments_download_url which returns a tar.gz archive. Each file in the archive is named according to its tar_path.

Parsing failures

If email parsing fails, parsed.status will be "failed" and parsed.error will contain details. You can still access the raw email content to parse it yourself.

Spam analysis

The analysis.spamassassin.score field contains the SpamAssassin spam score. Higher scores indicate higher likelihood of spam. Typical thresholds are 5+ for spam. You decide how to handle it. We never silently drop mail.