Skip to content

Using the JMAP API

ServerlessInbox implements JMAP (RFC 8620) and JMAP for Mail (RFC 8621). All JMAP traffic goes through a single HTTP endpoint.

The JMAP API is served at jmap.<your mail domain>. The ACM certificate and Route 53 record are created for you during deployment. The exact URL for your deployment is published as the jmapApiUrl output — open your stack’s Outputs tab in the CloudFormation console to read it.

Your mail domain is derived from the Route 53 hosted zone you selected when you launched the stack. If you set the optional subdomainNamespace parameter, that label is inserted between the service name and the base domain:

Hosted zone / subdomainNamespaceJMAP endpoint
example.com, namespace left emptyhttps://jmap.example.com
example.com, namespace mailboxhttps://jmap.mailbox.example.com

The JMAP API requires a Bearer JWT issued by the deployment’s identity provider — a Cognito user pool unless a different IdP addon is configured. The token must carry the jmapApi audience.

A request without valid credentials is answered 401 Unauthorized with a WWW-Authenticate: Bearer header. When the deployment is configured for OAuth, the challenge also carries a resource_metadata parameter pointing at the OAuth protected-resource document, so a client can discover the authorization server from the 401 alone.

These are the scope strings a client requests and an operator selects in the identity-provider console. They are produced by the identity-provider construct from a resource server whose identifier is si, so every mail scope is the identifier, a slash, and a dotted scope name. Transcribe them exactly as written:

Scope stringGrants
si/mail.readRead operations
si/mail.writeMutations
si/mail.sendSending

These three are the mail scopes; the same resource server also publishes si/account.read, si/alias.read, si/alias.write, si/user.read, si/contacts.read, si/contacts.write, si/admin and si/tokens.manage.

si/tokens.manage carries one permission, tokens/manage, which lets a client create, rotate and revoke the signed-in user’s personal access tokens. No other scope carries it, and si/user.read does not. A client is given it by being provisioned with Permission.TOKENS_MANAGE; the webmail client requests it. Tokens a client creates are limited to anything up to the user’s own rights, and a personal access token can never hold tokens/manage, so a token cannot create or renew tokens.

CDK consumers do not write these strings by hand — they pass Permission.MAIL_READ, Permission.MAIL_WRITE and Permission.MAIL_SEND to the construct, which maps each one to the scope string above. Permission.MAIL_READ is a construct API name, not a scope string; never put it in a token request.

Scope enforcement: A method call is admitted only when the token’s scopes allow at least one of the rights the method works with (see Rights and token limits). Otherwise the call fails with a method-level forbidden error, and no data is read or written. A token that passes this check is then limited further, object by object, by what the signed-in user may do.

A token never grants anything; it only limits. What a request may do is what the signed-in user may do, intersected with what the token allows. A token that allows writing grants nothing on a mailbox the user can only read, and the owner of an account who presents a read-only token cannot write to it.

A token limit is a set of rights. Rights are namespaced names; the scopes in Mail scopes expand to them.

RightAllows
mail/readItemsRead mailboxes, emails, threads and submissions
mail/addItemsAdd an email to a mailbox: create, import, copy, move in; upload and Blob/copy into the account
mail/removeItemsRemove an email from a mailbox, or destroy it
mail/setSeenChange the $seen keyword
mail/setKeywordsChange keywords other than $seen
mail/createChildCreate a mailbox under a mailbox; create a top-level mailbox
mail/renameRename, reorder or move a mailbox
mail/deleteDestroy a mailbox
mail/submitSend mail and manage identities
contacts/readRead address books, contact cards and principals
contacts/writeCreate and change address books and contact cards, and share address books
contacts/deleteDestroy address books
preferences/read, preferences/write, import/read, import/write, adminFurther rights a token limit can name
tokens/manageCreate, rotate and revoke personal access tokens

The limit is visible to a client, so it can disable what would be refused:

  • isReadOnly on an account in the session is true when the user and token together allow no write of any kind on it.
  • accountCapabilities leaves out a capability when the user and token together allow nothing of that kind on the account. An account with nothing at all allowed is omitted from the session.
  • myRights on a Mailbox and on an AddressBook reflects the limit: a right the token does not allow is false, even for the account owner.
OperationNeeds
Email/set create, Email/import, Email/copymail/addItems on each target mailbox
Email/set update, any changemail/readItems on a mailbox the email is in, then the right named in the rows for that change
Email/set update, mailbox addedmail/addItems on that mailbox
Email/set update, mailbox removedmail/removeItems on that mailbox
Email/set update of $seenmail/setSeen on every mailbox the email is in
Email/set update of any other keywordmail/setKeywords on every mailbox the email is in
Email/set destroymail/readItems on a mailbox the email is in, and mail/removeItems on every mailbox the email is in
EmailSubmission/set createmail/readItems on a mailbox the email is in, and mail/submit on every mailbox the email is in
EmailSubmission/set update, destroymail/submit
EmailSubmission/set onSuccessUpdateEmail, onSuccessDestroyEmailThe same rights as the equivalent Email/set change; when refused, the email stays unchanged
Blob/copymail/addItems on the destination account
Identity/setmail/submit
Mailbox/set create a top-level mailboxAccount owner, and mail/createChild
Mailbox/set create a child mailboxmail/createChild on the parent
Mailbox/set rename, change sortOrdermail/rename
Mailbox/set move under another mailboxmail/rename, and mail/createChild on the new parent
Mailbox/set move to the top levelmail/rename, and account owner
Mailbox/set destroymail/delete; with onDestroyRemoveEmails, also mail/readItems and mail/removeItems on that mailbox. An email also in another mailbox only leaves this one
Mailbox/set change shareWithmail/rename and mail/delete; a share may not give more than the sharer’s token allows
AddressBook/set createAccount owner (a user), and contacts/write
AddressBook/set update name, description, isDefault, sortOrdercontacts/write
AddressBook/set change shareWithcontacts/write with share permission on the book
AddressBook/set destroycontacts/delete
ContactCard/set create, update, destroycontacts/write on the address book, and on the target book when a card is moved

A token that sends mail also needs mail/readItems, because sending reads the message. The token editor in webmail turns on reading for rights that act on a message.

A mailbox, email or address book the user or token cannot read is reported as notFound rather than forbidden.

Subscribing to a mailbox (isSubscribed) needs no right and gives none.

SituationError
The user has no right of any kind on the accountaccountNotFound
The method works with a kind of data (mail or contacts) that the user and token allow nothing of on the accountaccountNotSupportedByMethod
A read method, and the user and token allow no read of this kindforbidden for the method
A write method, and the account is read-only (isReadOnly is true)accountReadOnly
A write method on an account that is not read-only, but no write of this kind is allowedforbidden for the method
/copy source account: no right of any kindfromAccountNotFound
/copy source account: nothing of this kind allowedfromAccountNotSupportedByMethod
/copy source account: no read of this kind allowedforbidden for the method
The token’s scopes do not allow the methodforbidden for the method
A write on one object needs a right that is not heldforbidden on that item in notCreated, notUpdated, notDestroyed or notCopied; the rest of the call proceeds
EmailSubmission/set create with an email that cannot be readinvalidProperties on that item
A mailbox, email or address book the user or token cannot readnotFound

Machine-to-machine access requires a deployment built with the ServerlessInbox CDK constructs. A headless app client is not part of a template install — it exists only where the CDK app asks for one explicitly, by calling provisionHeadlessClient({ name, audiences, permissions }) on the MailServerUserPool construct. That call creates a dedicated client_credentials app client and registers it as an accepted audience on the APIs listed in audiences; it returns the client’s ID, its generated client secret as a SecretValue, and the scope strings the client may request.

Where those values go is the deployment’s own choice — the constructs do not store them anywhere. The recommended handling is for the CDK app to put the secret straight into AWS Secrets Manager and never surface it any other way:

const client = userPool.provisionHeadlessClient({
name: 'sync-worker',
audiences: ['jmapApi'],
// Construct API names, not scope strings: these map to `si/mail.read` and `si/mail.write`.
permissions: [Permission.MAIL_READ, Permission.MAIL_WRITE],
});
// clientSecret is set for headless (client_credentials) clients.
new secretsmanager.Secret(this, 'SyncWorkerClientSecret', {
secretName: 'serverlessinbox/headless/sync-worker',
secretStringValue: client.clientSecret!,
});

Do not publish the secret as a CfnOutput and do not pass it into a construct property that lands verbatim in the synthesized template: a stack output and a plaintext template value are both readable by anyone with read access to the stack.

The client ID is not a secret and may be published as a stack output or hard-coded in the consumer’s configuration.

The flow itself is standard OAuth 2.0 client_credentials. The client must carry the jmapApi audience and the mail scopes the integration needs: si/mail.read for reads, plus si/mail.write and si/mail.send for mutations and sends — see Mail scopes above.

Read the secret at run time from Secrets Manager rather than pasting it into the command, and authenticate to the token endpoint with HTTP Basic auth (client_secret_basic) so the secret is never in the POST body:

Terminal window
# 1 — Fetch the client secret at run time; never paste it into the command.
CLIENT_ID=<headless-client-id>
CLIENT_SECRET=$(aws secretsmanager get-secret-value \
--secret-id serverlessinbox/headless/sync-worker \
--query SecretString --output text)
# 2 — Obtain a token. --user sends Basic auth, keeping the secret out of the body.
# The token endpoint comes from the openid-configuration document; the Cognito form is shown here.
TOKEN=$(curl -s -X POST \
--user "$CLIENT_ID:$CLIENT_SECRET" \
"https://<cognito-domain>.auth.<region>.amazoncognito.com/oauth2/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "scope=si/mail.read si/mail.write si/mail.send" \
| jq -r '.access_token')
unset CLIENT_SECRET

Never echo, log, or set -x over the secret or the token. Note that a process’s arguments are visible to other users on the host, so --user still exposes the secret on a shared machine — pass it on stdin with curl --config - there, or use an SDK that keeps it in memory.

The access token is short-lived (the identity provider returns its lifetime in expires_in). Cache it in memory and reuse it until it is close to expiry rather than requesting a new token per call.

Before making method calls, fetch the JMAP session object. It describes the capabilities the server supports, the accounts the authenticated user has access to, and the API URL to use for calls.

Terminal window
curl -s "https://jmap.mail.example.com/.well-known/jmap" \
-H "Authorization: Bearer $TOKEN" | jq .

The response includes an apiUrl (the endpoint for method calls) and the primaryAccounts map — you need the account ID for almost every method call.

Use the URLs the session gives you — do not assume a layout. This is the most common reason a JMAP client fails against a server it has not been tested with:

  • Method calls go to apiUrl, not to the session endpoint you just fetched.
  • uploadUrl and downloadUrl are RFC 6570 URI templates. Expand the variables — {accountId}, {blobId}, {type}, {name} — rather than treating the string as a literal URL. Blob upload and download will not work otherwise.
  • The host may differ per URL: downloads are served from a CDN host in this deployment, which is exactly the case a hard-coded path gets wrong.

The session lists urn:ietf:params:jmap:principals among its top-level capabilities as an empty object, as RFC 9670 defines. Each account’s accountCapabilities carries the same capability with a currentUserPrincipalId member: the id of the signed-in user’s own Principal. Fetch it with Principal/get to read that principal.

A single upload to uploadUrl is capped at 6 MB — the request passes through API Gateway, and that’s its payload ceiling. JMAP defines a single upload endpoint rather than per-object pre-signed URLs, so this limit applies to the whole request body, attachments included; a message (or attachment) that exceeds it is rejected at the gateway before it reaches the server. A JMAP extension for presigned S3 uploads, which would lift this ceiling, is planned. ServerlessInbox imposes no size limit of its own on receiving mail.

{
"capabilities": {
"urn:ietf:params:jmap:core": { "maxCallsInRequest": 32, "..." : "..." },
"urn:ietf:params:jmap:mail": { "mayCreateTopLevelMailbox": true, "...": "..." },
"https://specs.serverlessinbox.com/websocket": {
"url": "wss://ws.mail.example.com",
"maxSubscriptions": 10
}
},
"accounts": {
"acc-abc123": {
"name": "alice@example.com",
"isPersonal": true,
"isReadOnly": false,
"accountCapabilities": {
"urn:ietf:params:jmap:core": {},
"urn:ietf:params:jmap:mail": {},
"urn:ietf:params:jmap:submission": {}
}
}
},
"primaryAccounts": {
"urn:ietf:params:jmap:core": "acc-abc123",
"urn:ietf:params:jmap:mail": "acc-abc123",
"urn:ietf:params:jmap:submission": "acc-abc123"
},
"apiUrl": "https://jmap.mail.example.com/jmap",
"uploadUrl": "https://jmap.mail.example.com/upload/{accountId}",
"downloadUrl": "https://cdn.mail.example.com?accountId={accountId}&blobId={blobId}&type={type}&name={name}"
}

The table below is the complete, current picture of what the endpoint accepts. Every method the server implements is declared in the schemas served at the endpoint, and vice versa — there are no undeclared, implemented-but-hidden methods.

ObjectMethodsNotes
Mailboxget, set, query, queryChanges, changes
Emailget, set, query, queryChanges, changes, copy, import, parse
BlobcopyRFC 8620 §6.3 (core). Copies email blobs between accounts — see Blob/copy below.
Threadget, query, queryChanges, changes
SearchSnippetgetRFC 8621 §5.1. Highlights the words of an Email/query text filter — see Search below.
EmailSubmissionget, set, query, queryChanges, changesquery/queryChanges are optional under RFC 8621 §7.4; implemented here.
Identityget, set, changesset has a deliberately narrow contract — see Identity/set below.
AddressBookget, set, query, queryChanges, changesRFC 9610 (Contacts).
ContactCardget, set, query, queryChanges, changes, copyRFC 9610 (Contacts).
Principalget, set, query, queryChanges, changesRFC 9670 (Principals/sharing).
ShareNotificationget, set, query, queryChanges, changesRFC 9670 (Principals/sharing).
Core/echoNot availableDeliberately not enabled: an unauthenticated echo endpoint is attack surface with no value to a real client. Use any cheap */get call (e.g. Mailbox/get with ids: []) to verify a token/connection instead.
PushSubscriptionget, setAccount-less webhook push, RFC 8620 §7.2 — see the PushSubscription reference. Requires the push/manage right.

These methods back the urn:ietf:params:jmap:core, urn:ietf:params:jmap:mail, urn:ietf:params:jmap:submission, urn:ietf:params:jmap:contacts, and urn:ietf:params:jmap:principals capabilities the session advertises.

Calling a method the server does not implement returns a JMAP unknownMethod error, not silent success.

Identities are provisioned by the server from an account’s aliases — which addresses an account may send from is a property of that account’s aliases (the Admin API’s can_send_from flag) — so Identity/set is a preferences editor, not a provisioning API:

  • create is always rejected with forbidden (“Identities are server-managed”).
  • destroy is rejected for the account’s primary identity, which the server marks mayDelete: false.
  • On update, a non-admin caller may set replyTo, bcc, textSignature, and htmlSignature; name is rejected with invalidProperties as server-managed.

A client that uses Identity/set for signatures and per-identity reply/BCC preferences works exactly as expected. One that tries to add a sending address through it gets a clean forbidden back and should send the user to the administrator instead.

Blob/copy copies email blobs between accounts — the caller must be able to read the source blob in the source account and hold write rights on the destination account. It is part of the RFC 8620 core capability (urn:ietf:params:jmap:core), not the mail capability: unlike Email/copy, it is available regardless of which account capabilities are in play, and does not require urn:ietf:params:jmap:mail.

Its contract is email blobs. A request that names a contact or principal blob is refused for that item with invalidArguments, reported per item in the response’s notCopied map — the rest of the call proceeds normally, so one out-of-contract item never fails the whole request.

Email/query and SearchSnippet/get take the same filter. This section describes how the text members of that filter behave and which members the server refuses.

The text of text, subject, from, to, cc, bcc and body is read as words:

  • A search of several words finds the mail that contains all of them.
  • A phrase in single or double quotes finds the words together and in order. Inside a phrase, a backslash stands for the character after it, so \" and \' put a quote in the phrase.
  • Everything typed is text. There are no operators: OR, -, field: and * have no special meaning. To combine conditions, use the filter operators AND, OR and NOT.
  • A word matches whole words only, ignoring case. Stemming is not used, so invoice does not find invoices.
  • A value that holds only white space constrains nothing and matches every email.
  • text covers From, To, Cc, Bcc, Subject and the body.
  • body covers the body alone.
  • The body is the first 64 KiB of the readable text of the mail: the text part, or the HTML part reduced to its text when there is no text part, followed by text attachments and attached messages.
  • For mail stored before its text was kept for search, the body is the 200-character preview.

This differs from RFC 8621 section 4.4.1 in that text and body read at most the first 64 KiB of the text of a mail.

text does not match keywords. To find mail by keyword, use hasKeyword or notKeyword.

MemberMatches
beforeMail received before the date (exclusive).
afterMail received at or after the date.
minSizeMail of at least this many octets.
maxSizeMail of fewer than this many octets.
hasAttachmenttrue finds mail with an attachment, false mail without.
bccMail whose Bcc header contains the words.
bodyMail whose body contains the words, as described above.

before and after are UTC dates ending in Z, such as 2025-03-01T00:00:00Z; minSize and maxSize are unsigned integers.

A filter that carries one of these members gets an unsupportedFilter error (RFC 8620 section 5.5), as does any member that RFC 8621 does not define:

  • header
  • allInThreadHaveKeyword
  • someInThreadHaveKeyword
  • noneInThreadHaveKeyword

A search the server cannot understand also gets unsupportedFilter. While the search index of an account is being built or upgraded, a search gets serverUnavailable; try again later.

SearchSnippet/get returns, for each requested email, the subject and a preview with the words of the filter’s text marked. Its arguments and response are listed in the SearchSnippet reference; the behaviour is:

  • filter is the filter of the Email/query call. Only its positive text counts: words under a NOT are not marked.
  • emailIds holds at most 500 ids, the maxObjectsInGet of the session. More answers requestTooLarge. An id given twice is answered once.
  • An id that is malformed, unknown, destroyed or in a mailbox the caller cannot read is listed in notFound. notFound is null when every id was found.
  • Each found email is an item of list with emailId, subject and preview. The response has no state.
  • subject is the whole subject, never cut. preview is cut to at most 255 octets.
  • In both, the marked words are wrapped in <mark> and </mark>, and &, < and > are escaped as &amp;, &lt; and &gt;.
  • subject is null when no word of a text or subject condition occurs in the subject. preview is null when no word of a text or body condition occurs in the preview text. A subject condition never marks the preview, and a body condition never marks the subject.
  • A call with no filter, or with no text condition, finds the emails and answers null for both.

All JMAP method calls are sent as a single POST to the apiUrl:

POST /jmap
Authorization: Bearer <token>
Content-Type: application/json
{
"using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
"methodCalls": [
["<MethodName>", { ...arguments... }, "<clientId>"]
]
}

Each element of methodCalls is a 3-tuple:

  1. Method name — e.g. Email/query, Mailbox/get
  2. Arguments — the method’s argument object
  3. Client ID — an arbitrary string you choose (e.g. "r1") to identify this call when referencing its result

The response is:

{
"methodResponses": [
["<MethodName>", { ...response... }, "<clientId>"]
]
}

A method that fails answers with an error response in place of its normal response, at the same position in methodResponses and with the same client ID. The other method calls in the request are processed as normal, and a method-level error never changes the HTTP status (RFC 8620 section 3.6.2).

["error", { "type": "invalidArguments", "description": "..." }, "<callId>"]

type is always present. description is optional and meant for debugging, not for display to a user; do not match on its wording.

typeMeaning
unknownMethodThe server does not implement the method name.
invalidArgumentsAn argument is of the wrong type, is otherwise invalid, or is missing; or a result reference in the call does not resolve.
forbiddenThe method and arguments are valid, but the request’s capabilities or token scopes do not allow the method, or the signed-in user may not run it. See Rights and token limits.
accountNotFoundThe accountId is not an account the user has any right on.
accountNotSupportedByMethodThe account exists, but the user and token allow nothing of the kind the method works with (mail or contacts).
accountReadOnlyThe method writes, and the account is read-only.
fromAccountNotFoundA /copy method’s fromAccountId is not an account the user has any right on.
fromAccountNotSupportedByMethodA /copy method’s source account allows nothing of the kind the method works with.
cannotCalculateChangesA */changes or */queryChanges call cannot be answered from the sinceState or sinceQueryState given. Fetch the data again and continue from the new state.
tooManyChangesA */changes call has more changes than the maxChanges the client asked for. Repeat the call with a larger maxChanges.
requestTooLargeA */set call names more objects to create, update or destroy than the server accepts in one call. Split the call.
stateMismatchA */set call carried an ifInState that is not the current state. Nothing was changed.
serverFailAn unexpected error occurred while running the method. Its description is generic text; retrying the same call is expected to fail again.

A */set or */copy call that fails on one object still succeeds as a call. The failure is reported for that object in notCreated, notUpdated or notDestroyed (and notCopied for a copy), keyed by the creation id or the object id, and the other objects in the call are processed (RFC 8620 section 5.3).

{
"notUpdated": {
"mb-123": {
"type": "invalidProperties",
"description": "...",
"properties": ["name"]
}
}
}
PropertyMeaning
typeAlways present: the kind of failure, for example forbidden, notFound, invalidProperties or alreadyExists.
descriptionOptional text for debugging.
propertiesWith invalidProperties: the names of the properties that were invalid.
existingIdWith alreadyExists: the id of the object that already carries the conflicting value.

A key JMAP feature is the ability to use the output of one method call as the input to a later call in the same request. This avoids a round-trip. To reference a result, prefix the argument key with # and provide a ResultReference object:

{
"resultOf": "<clientId of the earlier call>",
"name": "<method name of the earlier call>",
"path": "/path/to/value"
}

Example: list and fetch emails in one request

Section titled “Example: list and fetch emails in one request”

This example:

  1. Queries the 10 most recent emails in the Inbox
  2. Fetches the subject, from, and preview of those emails — in the same HTTP request, without needing the IDs from step 1 first
Terminal window
# Substitute your accountId from the session object
ACCOUNT_ID="acc-abc123"
INBOX_ID="mailbox-inbox-id" # obtain via Mailbox/get
curl -s -X POST "https://jmap.mail.example.com/jmap" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
"methodCalls": [
["Email/query", {
"accountId": "'"$ACCOUNT_ID"'",
"filter": { "inMailbox": "'"$INBOX_ID"'" },
"sort": [{ "property": "receivedAt", "isAscending": false }],
"limit": 10
}, "q1"],
["Email/get", {
"accountId": "'"$ACCOUNT_ID"'",
"#ids": {
"resultOf": "q1",
"name": "Email/query",
"path": "/ids"
},
"properties": ["subject", "from", "preview", "receivedAt"]
}, "g1"]
]
}' | jq '.methodResponses[1][1].list'
Terminal window
curl -s -X POST "https://jmap.mail.example.com/jmap" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
"methodCalls": [
["Mailbox/get", {
"accountId": "'"$ACCOUNT_ID"'",
"ids": null
}, "m1"]
]
}' | jq '.methodResponses[0][1].list[] | {id, name, role}'

Example: incremental sync with Email/changes

Section titled “Example: incremental sync with Email/changes”

After your initial sync (via Email/get with ids: null), use the state value from the response to poll for changes incrementally:

Terminal window
curl -s -X POST "https://jmap.mail.example.com/jmap" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"using": ["urn:ietf:params:jmap:core", "urn:ietf:params:jmap:mail"],
"methodCalls": [
["Email/changes", {
"accountId": "'"$ACCOUNT_ID"'",
"sinceState": "<state-from-previous-response>"
}, "c1"],
["Email/get", {
"accountId": "'"$ACCOUNT_ID"'",
"#ids": {
"resultOf": "c1",
"name": "Email/changes",
"path": "/created"
},
"properties": ["subject", "from", "mailboxIds", "receivedAt"]
}, "g1"]
]
}' | jq .

If hasMoreChanges is true in the changes response, call again with the returned newState until it is false.

ServerlessInbox offers two push channels. Both deliver a hint that something changed, never the data itself.

  • PushSubscription (RFC 8620 §7.2) registers an HTTPS endpoint that the server calls on each change, optionally with an encrypted body. See the PushSubscription reference. It requires the push/manage right.
  • The WebSocket channel keeps a connection open and sends a stateChange frame, described below. It is ServerlessInbox’s own protocol, specified at https://specs.serverlessinbox.com/websocket, not the JMAP WebSocket transport of RFC 8887.

JMAP push over WebSocket (RFC 8887) is not implemented: that RFC multiplexes full JMAP API requests and responses over the WebSocket connection, replacing HTTP, which this server deliberately avoids (see Push Notifications). The EventSource transport of RFC 8620 §7.3 is not served either, because holding a stream open per client would bill compute for the whole time the stream is open. A client that wants push uses PushSubscription or the WebSocket channel, and otherwise polls */changes.

Both channels carry only the data types a client can track with */changes: Mailbox, Email, Thread, EmailDelivery, Identity, EmailSubmission, AddressBook, ContactCard, Principal, ShareNotification and SieveScript. Each is cut to the types the client subscribed to.

To use the WebSocket channel, a client has to:

  1. Read the session object’s capabilities map for the vendor key https://specs.serverlessinbox.com/websocket — this is how a client discovers push is available at all, and where; its url field (e.g. wss://ws.mail.example.com) is the WebSocket endpoint (the ws subdomain, following the same subdomainNamespace logic as the other endpoints).
  2. Connect and send a subscribe frame naming the accountId and data types to watch.
  3. On each stateChange frame, call the relevant JMAP */changes method over the normal HTTP apiUrl to fetch the delta — the WebSocket carries only the “something changed” signal, never JMAP request/response data itself.

Per RFC 8620 §7.2 (hint-only push), treat this the same way: a missed or dropped stateChange notification is not a correctness bug — a client must still be able to recover by polling */changes with its last known state. See the WebSocket Events reference for the full message protocol.

Concretely, the WebSocket channel only carries a small custom JSON protocol (subscribe → subscribed/error, and server-pushed stateChange notifications naming which JMAP data types changed) — it is not a transport for JMAP method calls. On receiving a stateChange, a client still issues an ordinary HTTP /changes or /query call to fetch the actual data. This is a hint channel only, consistent with RFC 8620 §7.2’s requirement that clients handle missed push notifications by polling: if a WebSocket message is dropped or the connection drops, the client must recover by polling anyway, so treat the WebSocket channel as an optimization, never as the sole sync mechanism.

What this means for a third-party JMAP client

Section titled “What this means for a third-party JMAP client”

A generic, off-the-shelf JMAP client that assumes the full RFC 8620/8621 method set will not work unmodified against ServerlessInbox — see Method coverage above for the complete list of what’s available. In short: a client that hard-requires Core/echo, EventSource or RFC 8887 WebSocket push will not be fully functional out of the box. A client that sticks to mail-object CRUD/query/changes and treats push as an optional hint — using PushSubscription or the WebSocket channel, and polling when push is unavailable — should interoperate normally.