Skip to Content
POST
/api/v1/mailboxes/{mailboxId}/messages/compose

Constructs and saves an email message from structured JSON (headers, body text/HTML, attachments) into a mailbox without sending.

Authorization

bearerAuth
headerAuthorizationBearer <token>

Two credential kinds share this scheme; GET /api/v1/auth/whoami answers which one you hold and what it reaches.

oek_… API key (minted by POST /api/v1/api-keys; shown once at mint). role: account reaches the full account surface: the directory (domains, routes, patterns, api-keys, accounts, address lists) plus every mailbox the account owns. role: system additionally reaches the operator surface, which is documented separately.

oemp_… mailbox app password (minted by POST /api/v1/identities/{identityId}/credentials). Reaches ONE mailbox: its messages, labels, threads, search, sync, send, filters and PIM collections. Directory routes refuse it with 403 insufficient_scope.

Refusal vocabulary: a missing, malformed, expired, or revoked credential answers 401 unauthorized with a WWW-Authenticate: Bearer challenge; a VALID credential outside its scope answers 403 (insufficient_scope for an app password on a directory route, system_credentials_required where only the operator may call). The public routes (health, branding, token-in-path capabilities) declare security: [].

Path Parameters

mailboxId*string

Mailbox ULID identifier

Query Parameters

label?string

Target label (default INBOX)

flags?string

Comma-separated initial flags, e.g. seen,draft

filter?string

Whether to run the mailbox's active Sieve filter (default false)

Value in"true""false"
internaldate?|

Epoch seconds recorded as receivedAt (default now)

Range-62135596800 <= value <= 253402300799

Header Parameters

x-delivery-id?string

Optional client idempotency key to prevent duplicate imports. Stored NAMESPACED as append:<your id> (an append is the mailbox's own side writing its own row, announced as message.imported, not message.new), so the traffic log and the filtered response show that form — retry with your original value.

Request Body

application/json
  1. body
attachments?array<>
Itemsitems <= 50
bcc?array<>
Itemsitems <= 100
cc?array<>
Itemsitems <= 100
from*
headers?

Extra headers; structural ones (Content-Type, Date, …) are refused

html?|

HTML body; paired with text as multipart/alternative

inReplyTo?|

Parent Message-ID, angle-bracketed

Lengthlength <= 512
messageId?|

Overrides the generated Message-ID

Lengthlength <= 998
references?array<>
Itemsitems <= 50
replyTo?array<>
Itemsitems <= 10
subject?|
Lengthlength <= 2000
text?|

Plain-text body

to?array<>
Itemsitems <= 100

Response Body

Stored (uid + uidValidity answer IMAP APPENDUID), or status:filtered when an opted-in Sieve filter discarded it

application/json
  1. response
blobHash?string

On a fresh store: the blob SHA-256 (what body caches key on)

duplicate*boolean

True if message was already delivered previously

flags?array<string>

On a fresh store: the flags the row was stored with

keywords?array<string>

On a fresh store: the keywords the row was stored with

messageId*string

Assigned message ULID

modseq?integer

On a fresh store: the membership row's MODSEQ in the target label

Formatint64
receivedAt?integer

On a fresh store: the INTERNALDATE in epoch seconds

Formatint64
size?integer

On a fresh store: the stored size in bytes

Formatint64
status*"delivered"

Message was successfully delivered and stored

Value in"delivered"
threadId*|

Assigned conversation thread ULID, or null on duplicate

uid*|

Assigned message UID, or null on duplicate

Formatint64
uidValidity*|

Label UID validity epoch, or null on duplicate

Formatint64
Example Request
curl -X POST 'https://api.open.email/api/v1/mailboxes/string/messages/compose' \
  -H 'Content-Type: application/json' \
  -d '{
  "from": {
    "email": "grace@acme.example",
    "name": "Grace Hopper"
  },
  "inReplyTo": "<7f2a1c9e4b8d@mail.example.com>",
  "references": [
    "<7f2a1c9e4b8d@mail.example.com>"
  ],
  "subject": "Re: Q3 report draft",
  "text": "Thanks Ada, final version attached.\n\nGrace",
  "to": [
    {
      "email": "ada@example.com",
      "name": "Ada Lovelace"
    }
  ]
}'
Example Response
{
  "blobHash": "string",
  "duplicate": true,
  "flags": [
    "string"
  ],
  "keywords": [
    "string"
  ],
  "messageId": "string",
  "modseq": 0,
  "receivedAt": 0,
  "size": 0,
  "status": "delivered",
  "threadId": "string",
  "uid": 0,
  "uidValidity": 0
}