Receiving mail

How a message becomes a thread, a message and an event: attachments and their text, the raw and HTML bodies, categories, verdicts and the auto-replyable flag, threading and duplicates.

On this page
  1. What happens when mail arrives
  2. Threads
  3. Messages
  4. Attachments and extracted text
  5. The raw and HTML bodies
  6. Categories, verdicts and the auto-replyable flag
  7. How messages join a thread
  8. Duplicates

What happens when mail arrives

Mail for an active inbox is accepted at the mail server and goes through one pipeline before anything is stored: the message is parsed, duplicates are dropped by their Message-ID, the thread is chosen, the message is classified, the original, the HTML body and the attachments are stored, text is extracted from the attachments, and one transaction writes the thread, the message, the attachments and the message.received event. The event is then pushed to the stream and queued for the webhooks.

Mail for an unknown address, mail larger than 25 MiB and mail that cannot be parsed are rejected at the mail server, so the sender learns at once. A passing fault is answered with a temporary failure so the sender's server retries later. Receiving is never counted against a plan.

Where a deployment runs the malware engine or the link sandbox and enforces security policies, a message with an attachment or a suspect link is stored first and announced a little later: its event fires once, when the check is in, usually within seconds. See Attachments and links.

Threads

A thread is a conversation. GET /v1/inboxes/{inboxId}/threads lists an inbox's threads, newest activity first, with limit (50 by default, at most 100), offset and total. isRead=false keeps the threads waiting on the agent; q keeps the threads whose subject or a participant address contains the text.

A Thread carries the subject of its first message, the addresses that took part in it, the message count, isRead, the instants of its first and last messages and the id of the last one. PATCH /v1/threads/{threadId} with { "isRead": true } marks it read; sending a reply marks it read as well, as a mail client would.

DELETE /v1/threads/{threadId} trashes a thread: it and its messages leave every list and read, a reply to it answers 404 thread_not_found, and a later message in the same conversation starts a new thread. Nothing is erased until the retention sweep exists.

Messages

GET /v1/threads/{threadId}/messages answers the thread and its messages, oldest first, at most 500. GET /v1/inboxes/{inboxId}/messages lists an inbox's messages across threads, newest first, with direction=inbound or outbound to keep one side. GET /v1/messages/{messageId} reads one.

A Message is one email with everything an agent needs and nothing it has to parse:

Who and what
from, to, cc and bcc as address and display name pairs; replyTo when the sender set one; subject; deliveryRole, how the inbox received the message (as a to, cc or bcc recipient).
The text
text is the plain-text body, or text derived from the HTML when there was none. hasHtml says whether an HTML body is stored.
Threading headers
rfcMessageId, inReplyTo and references, as the message carried them.
Classification
category, verdict, autoReplyable and authentication (the SPF, DKIM and DMARC results), explained below.
Where the rest is
rawUrl for the original message, and attachments with their download URLs and extracted text.
When
occurredAt is the instant the message arrived (or was sent). Arrival time orders a thread; the sender's Date header is not trusted to.

A message

{
  "id": "msg_01jc5a6g7h8j9k0m1n2p3q4r5s",
  "inboxId": "inb_01jc4q7w9k2m5n8p3r6t1v4x7z",
  "threadId": "thr_01jc5a1b2c3d4e5f6g7h8j9k0m",
  "direction": "inbound",
  "rfcMessageId": "<a1b2c3@example.com>",
  "inReplyTo": null,
  "references": [],
  "from": {
    "address": "sam@example.com",
    "name": "Sam Rivera"
  },
  "to": [
    {
      "address": "concierge@doorman.example",
      "name": null
    }
  ],
  "cc": [],
  "bcc": [],
  "replyTo": null,
  "deliveryRole": "to",
  "subject": "Invoice 2847",
  "text": "Hi, invoice 2847 is attached.",
  "hasHtml": true,
  "rawUrl": "https://api.doorman.example/v1/messages/msg_01jc5a6g7h8j9k0m1n2p3q4r5s/raw",
  "sizeBytes": 48120,
  "category": "personal",
  "autoReplyable": true,
  "verdict": "clean",
  "spamScore": 0.02,
  "authentication": {
    "spf": "pass",
    "dkim": "pass",
    "dmarc": "pass"
  },
  "risk": {
    "score": 6,
    "level": "low",
    "labels": [],
    "reasons": [],
    "sender": {
      "standing": "known",
      "authenticated": true
    },
    "action": "delivered",
    "analysis": "full",
    "review": null
  },
  "occurredAt": "2026-11-05T10:05:00.000Z",
  "attachments": [
    {
      "filename": "invoice.pdf",
      "contentType": "application/pdf",
      "sizeBytes": 45000,
      "url": "https://api.doorman.example/v1/attachments/msg_01jc5a6g7h8j9k0m1n2p3q4r5s/invoice.pdf",
      "parsedText": "Invoice 2847. Line 3: Setup fee, billed twice. Total 1,480.",
      "extractionMethod": "pdf"
    }
  ]
}

Attachments and extracted text

Each attachment is stored as it arrived and listed on the message as an Attachment: filename (unique within the message), contentType, sizeBytes, url to download the bytes with the same credential as the API, parsedText when extraction produced any, and extractionMethod, which says how the text was obtained or why it was not.

An attachment of any type is accepted and stored. Assessed mail also carries scan on each attachment, an AttachmentScan: what the bytes are whatever the file is called (detectedType), their sha256, a status of clean, suspicious, malicious or unscanned, and the findings behind it. Nothing is extracted from a malicious attachment, and a key or an app token cannot download one (403 risk_blocked). Attachments and links explains each status.

The same text is in the webhook payload, so an agent reads an attached invoice in the very first event. GET /v1/attachments/{messageId}/{filename}/text answers the text on its own, and GET /v1/attachments/{messageId}/{filename} the bytes.

MethodMeaning
textPlain text, Markdown, JSON, XML, YAML, logs and calendars: decoded as text.
csvCSV and tab-separated files.
pdfPDF documents, read into text by the platform's document converter.
ocrPNG, JPEG, WebP, GIF and SVG images, read by the converter.
officeWord, Excel, PowerPoint, OpenDocument and Numbers files, read by the converter.
unsupportedA type nothing reads, such as a binary or an archive.
skippedBeyond the first 10 attachments of a message, which are stored but not read.
skipped_too_largeLarger than 10 MiB.
unavailableThe converter is not configured on this deployment, so only text, CSV and HTML are read.
timeout, pdf_error, ocr_error, office_error, html_errorExtraction was attempted and did not finish; the bytes are still there.

Extracted text is capped at 50,000 characters. The complete list of methods is text, csv, pdf, ocr, office, unsupported, skipped, skipped_too_large, unavailable, timeout, pdf_error, ocr_error, office_error, html_error.

The raw and HTML bodies

GET /v1/messages/{messageId}/raw downloads the original message as message/rfc822, every header and part included, for anything the parsed form leaves out. Outbound messages have no raw copy and answer 404.

GET /v1/messages/{messageId}/html serves the stored HTML body as text/html under cache-control: private, no-store, x-content-type-options: nosniff and a content security policy that allows images and inline styles only, with sandbox. Show it in a sandboxed frame rather than inside your own page. 404 when the message has no HTML body.

Categories, verdicts and the auto-replyable flag

Every inbound message is classified at the door from its headers, so an agent knows what not to answer. category is one of personal, automated, marketing, bounce, spam, malicious:

bounce
An empty envelope sender, a sender such as mailer-daemon or postmaster, a multipart/report body, or an X-Failed-Recipients header.
spam
The platform's X-Spam-Flag or X-Spam-Status says yes.
marketing
A List-Unsubscribe header, or Precedence: bulk with a List-Id or Feedback-ID.
automated
Auto-Submitted (other than no), Precedence bulk, list, junk or auto_reply, a List-Id, an auto-response suppression header, or an automated-looking sender such as no-reply, notifications, alerts, mailer, system, robot or bot.
personal
Everything else: mail a person wrote. Outbound messages are always personal.
malicious
Assigned in enforce mode when Doorman's inbound risk assessment rates a non-spam threat critical or detects disguised malware. See Security and sender trust.

verdict comes from the first Authentication-Results header, which is trusted only when the mail platform wrote it: clean, unverified, suspicious. DMARC pass is clean, DMARC fail is suspicious, and without a DMARC result a DKIM or SPF pass is clean and anything else unverified. A message with no trusted results is unverified; an outbound message has a null verdict.

autoReplyable (auto_replyable in the webhook payload) is true only for a personal message whose verdict is not suspicious and, where security policies are enforced, that was neither warned about, held nor rated high risk. An agent that answers on its own should check it first: it keeps the agent out of bounce loops, off mailing lists and away from spoofed or flagged mail.

How messages join a thread

  • A message whose In-Reply-To or References names a message the inbox already holds joins that message's thread. Both the original Message-ID and the identifier the sending provider assigned to an outbound message are matched, so replies to mail the agent sent thread correctly.
  • A message without a matching header joins the newest thread with the same normalized subject (reply and forward prefixes removed) when the sender already took part in it and the thread had activity within the last 14 days.
  • Otherwise the message starts a new thread. A trashed thread is never reopened: a later message in the same conversation starts a new one, as a mail client would.

A thread's participants lists the addresses that took part in it, kept sorted; q on the thread list searches them. An inbound message marks its thread unread again.

Duplicates

Mail servers retry. A message whose Message-ID the inbox already holds is accepted and dropped silently, so the same email never becomes two messages or two events. A message without a Message-ID cannot be deduplicated this way; it is stored each time it arrives.

Webhook delivery is at least once as well, for the same reason, and the event id in webhook-id is stable across retries: deduplicate on it.

Up Down to move, Enter to open, Esc to close