When to use it
Use the Mailbox API for an assistant, agent or tool that works for one person. Use an organization API key (mdk_live_) when your own backend needs several mailboxes (the whole organization, or only some domains or mailboxes), domains, events or webhooks.
- Reaches one mailbox only: the one whose address signed in
- Never needs the mailbox password nor an Owner credential
- Each app password is revoked on its own, without touching Webmail or other integrations
1. Create an app password
The mailbox user signs in to Webmail and opens Settings → API access. They type a name for the integration and choose “Create app password”. The app password starts with mdp_ and is shown once: copy it into the integration’s secret storage together with the mailbox address. The list shows each app password with its name, last characters and last use; “Revoke” ends it at once. A mailbox can hold up to 20 active app passwords. Changing the mailbox password revokes all of them.
2. Open a session
POST /v1/mailbox/sessions with the mailbox address and the app password. The token (mds_…) is valid for 24 hours; send it as Authorization: Bearer on every other call. When a call returns 401 session_expired, open a new session with the same app password. Wrong credentials return 401 unauthorized, and repeated failures are slowed down.
curl -X POST "$OMNERO_API_URL/v1/mailbox/sessions" \
-H "Content-Type: application/json" \
-d '{ "email": "ana@acme.com", "appPassword": "'"$OMNERO_APP_PASSWORD"'" }'
201 Created
{
"token": "mds_…",
"tokenType": "Bearer",
"expiresAt": "2026-11-11T14:03:22.120Z",
"mailbox": { "id": "6f1c…", "address": "ana@acme.com", "displayName": "Ana", "canSend": true }
}
3. List, search and filter
GET /v1/mailbox/messages returns the newest first. folder is inbox (default), sent, drafts, archive, spam or trash. unread=true lists only unread messages. q searches the subject, sender and text (up to 200 characters). labelId lists one label. limit is 1–100 (default 25). Send nextCursor as cursor, with the same filters, for the next page; it is null on the last one. Mail still on its way out appears in sent with status queued or sending.
GET /v1/mailbox/messages?folder=inbox&unread=true&q=invoice
Authorization: Bearer $SESSION_TOKEN
200 OK
{
"items": [
{
"id": "0b7e…",
"direction": "inbound",
"status": "delivered",
"folder": "inbox",
"isRead": false,
"isStarred": false,
"fromAddress": "billing@example.com",
"toAddresses": ["ana@acme.com"],
"subject": "Invoice 1043",
"preview": "Please find attached…",
"createdAt": "2026-11-10T14:03:22.120Z"
}
],
"nextCursor": "wm1|2026-11-10T14:03:22.120Z|0b7e…"
}
4. Read and organize
GET /v1/mailbox/messages/{messageId} returns the full message with the same fields as the Read mail guide (bodies, recipients, attachments, labels). PATCH it with isRead, isStarred and/or folder (inbox, archive, spam or trash); the change shows in Webmail and the mobile app. GET /v1/mailbox returns the mailbox, the number of messages per folder and its labels.
PATCH /v1/mailbox/messages/0b7e…
Content-Type: application/json
{ "isRead": true, "folder": "archive" }
5. Reply in the same conversation and send
POST /v1/mailbox/messages sends from the mailbox. Fields: to, cc, bcc (arrays, at least one recipient), subject, text and/or html, attachmentIds, replyToMessageId and draftId. With replyToMessageId the reply carries the In-Reply-To and References headers of that message, so it joins its conversation for the recipient; write the subject yourself (usually "Re: …"). The mailbox signature is added to the text, as in Webmail. Send an Idempotency-Key header (8–255 characters) to make retries safe: the same key always returns the same message id with Idempotent-Replayed: true and never sends twice. 202 means queued; follow the message in the sent folder.
POST /v1/mailbox/messages
Authorization: Bearer $SESSION_TOKEN
Idempotency-Key: reply-0b7e-1
Content-Type: application/json
{
"to": ["billing@example.com"],
"subject": "Re: Invoice 1043",
"text": "Received, thank you. We will pay on Friday.",
"replyToMessageId": "0b7e…"
}
202 Accepted
{ "id": "5d2a…", "object": "message", "status": "queued" }
Drafts
GET /v1/mailbox/drafts lists unsent drafts. POST /v1/mailbox/drafts creates one (201) or, with id, updates it (200); it takes the same fields as a send, none required. A draft shows in Webmail, where the person can review it. Send it with POST /v1/mailbox/messages and draftId, or discard it with DELETE /v1/mailbox/drafts/{draftId}.
POST /v1/mailbox/drafts
Content-Type: application/json
{ "to": ["billing@example.com"], "subject": "Re: Invoice 1043", "text": "Draft for review", "replyToMessageId": "0b7e…" }
201 Created
{ "draft": { "id": "9c41…", "to": ["billing@example.com"], "cc": [], "bcc": [], "subject": "Re: Invoice 1043", "text": "Draft for review", "html": null, "replyToMessageId": "0b7e…", "attachments": [], "createdAt": "…", "updatedAt": "…" } }
Attachments
Same flow as the organization API, under /v1/mailbox: POST /v1/mailbox/attachments/uploads (with Idempotency-Key and mailboxId set to the session mailbox id), PUT the bytes to the returned URL, then POST /v1/mailbox/attachments/uploads/{uploadId}/complete. Pass the attachment id in attachmentIds. Download received files with GET /v1/mailbox/attachments/{attachmentId}/download-url.
With the TypeScript SDK
OmneroMailbox opens the session on the first call and opens a new one when the token expires. Keep the app password in server-side secret storage.
import { OmneroMailbox } from '@omnero/mail-sdk';
const mailbox = new OmneroMailbox({
baseUrl: process.env.OMNERO_API_URL!,
email: 'ana@acme.com',
appPassword: process.env.OMNERO_APP_PASSWORD!,
});
const { items } = await mailbox.messages.list({ unread: true, q: 'invoice' });
const { message } = await mailbox.messages.retrieve(items[0].id);
await mailbox.messages.send(
{
to: [message.fromAddress],
subject: `Re: ${message.subject ?? ''}`,
text: 'Received, thank you.',
replyToMessageId: message.id,
},
{ idempotencyKey: `reply-${message.id}` },
);
await mailbox.messages.update(message.id, { isRead: true, folder: 'archive' });
Sign out and limits
DELETE /v1/mailbox/sessions/current ends the token. Requests count toward the organization plan like organization keys do (per minute for the mailbox, per day for the organization); 429 rate_limited includes Retry-After. If the mailbox is disabled, its organization suspended, or the app password revoked, the next call returns 401. When new terms of service are published, calls return 403 legal_acceptance_required until the mailbox user accepts them in Webmail.
- POST /v1/mailbox/sessions — open a session
- DELETE /v1/mailbox/sessions/current — close it
- GET /v1/mailbox — mailbox, folder counts and labels
- GET/POST /v1/mailbox/messages — list, search, filter; send
- GET/PATCH /v1/mailbox/messages/{messageId} — read; change state
- GET/POST /v1/mailbox/drafts and DELETE /v1/mailbox/drafts/{draftId}
- POST /v1/mailbox/attachments/uploads, …/complete and GET …/download-url