Read email threads without losing conversation context
Retrieve a conversation, interpret its messages and keep source references in an agent summary.
Separate workflow labels from system states and account for protected messages in searches and summaries.
Use custom labels to express your application’s processing state, such as needs-review, awaiting-document or resolved. Keep these labels separate from the business system of record: a label is a useful mailbox view, while a durable job or case record should track who performed work and which revision was processed. Decide whether a label belongs on one message or the entire conversation. A label applied to every message can be convenient for a short support thread, but it can also hide differences between a newly received request and an older resolved exchange.
System labels such as sent, received, bounced, spam, trash and blocked cannot be added or removed through normal label updates. Attempting to modify them returns a 400 rather than changing mail-delivery history. Do not model a delivery status update as a custom relabel operation or try to move blocked mail into a trusted processing queue by stripping its system label. Maintain a separate reviewed-by-human or investigated label if your operations need that distinction. A review decision can coexist with the fact that a message was originally quarantined or rejected.
PATCH /v0/emails/inboxes/:inbox_id/emails/threads/:thread_id accepts add_labels and remove_labels. A thread with 100 or more messages rejects relabeling with 422, so do not assume a conversation-wide update scales without a bound. Message-level PATCH and batch-update endpoints support narrower operations where appropriate. Each successful label change records a label.added or label.removed inbox event. If your worker subscribes to these events, avoid a loop in which observing your own classification repeatedly triggers the same label mutation and another classification run.
{"add_labels":["needs-review"],"remove_labels":["awaiting-document"]}Spam, trash, blocked and unauthenticated messages require corresponding label_*_read permissions. Ordinary lists can hide these messages, and search excludes gated labels even when a key can inspect them through other authorized routes. A zero-result search therefore means no matches in that search surface, not that the workspace never received such a message. Protected reads can return 404 to avoid disclosing unavailable content. When a human asks for a forensic mailbox count, state the scope and exclusions instead of filling the gap with an estimated total.
Record the intended label transition and processing revision in your local job before issuing updates. Repeating an add/remove request should preserve the intended final state, but external event consumers still need deduplication. Keep custom labels stable and documented so multiple agents do not assign conflicting meanings to urgent or done. Your next step is a local matrix covering normal mail, spam, blocked mail, a missing permission and an oversized thread. Confirm both the update result and the mailbox view seen by the real delegated key before relying on labels for operator triage.
A classifier’s custom label such as low-priority does not replace a protected spam or blocked state. Preserve the system state and let authorized operators interpret the custom classification alongside it. This keeps an agent from accidentally presenting an investigated quarantined message as an ordinary trusted request simply because its custom workflow label changed.
Reviewed against checked-in Lupin API handlers and documentation. Example requests were not executed against live providers.
Prepared with AI assistance by Lupin editorial. How we research and maintain these guides.