Messages & Flags
The message object
List endpoints return summaries (no bodies). Opening a message adds:
| Field | Description |
|---|---|
bodyText |
Plain-text body; derived from HTML when the mail has no text part |
bodyHtml |
HTML body, when present |
bodyError |
Transient message set when a body fetch failed |
attachments |
Stored attachment metadata (id, filename, contentType, size); present when the message has attachments and they are cached locally |
Passwords aside, bodyText/bodyHtml are omitted when empty. Attachment
payloads are never inlined into the message object — download them through
GET /api/attachments/{id}.
List messages in a mailbox
GET /api/mailboxes/{id}/messages
| Query | Default | Description |
|---|---|---|
limit |
50 |
Page size, maximum 200 |
offset |
0 |
Skip this many messages |
q |
— | Case-insensitive substring match on subject, snippet or body text |
unseen |
— | 1 or true returns only unread messages |
since |
— | Unix seconds; only messages dated at or after this value |
Messages are ordered newest first (date DESC, id DESC). The list reads only
the local cache — it does not contact IMAP and does not mark anything as read.
Read one message
GET /api/messages/{id}
If the body was not cached during sync, Pigeon selects the mailbox read-only,
fetches the single message with BODY.PEEK (so it stays unread) and stores the
body before responding. If that fetch fails, the response still contains the
message with bodyError set and bodyLoaded: false.
Attachments travel with the raw MIME message and are stored locally in the same
fetch. Each file is capped at 25 MB — larger attachments are skipped (they
do not appear in the attachments array and cannot be downloaded), while the
rest of the mail, including its other attachments, is stored normally. Mail
cached before attachment storage existed is backfilled on first open: Pigeon
refetches the raw message once, extracts the attachments and serves them on
every later request without touching the network. A failed backfill is logged
and does not block the message itself.
Error codes: 404 when the message does not exist, 400 for an invalid ID.
Download an attachment
GET /api/attachments/{id}
Responds with the raw file bytes and Content-Disposition: attachment carrying
the attachment’s original filename, so clients save it under that name —
curl -OJ and browsers both honor it. Non-ASCII names use RFC 5987
(filename*=). Attachments that arrived without a filename are served as
attachment. Downloads are served from the local SQLite cache — no IMAP
round-trip — and support Range requests.
| Status | Meaning |
|---|---|
400 |
Invalid attachment ID |
404 |
Attachment not found (or not cached yet — open its message first) |
Change flags
POST /api/messages/{id}/flags
| Field | Description |
|---|---|
seen |
Read/unread (\Seen) |
flagged |
Starred (\Flagged) |
Pass at least one field; both are optional pointers, so omitted fields are left untouched. Pigeon applies the change on the IMAP server first (selecting the mailbox read-write), then updates the local cache and mailbox counts, and returns the updated message.
| Status | Meaning |
|---|---|
400 |
Neither seen nor flagged provided |
404 |
Message not found |
502 |
IMAP update failed; nothing changed locally |
Reading mail through the API never marks it as read automatically — clients should call this endpoint explicitly (the built-in web UI does so when a message is opened). MCP read tools follow the same rule.