User API
The User API is a JSON-over-HTTP RPC API for settings that belong to a single signed-in user. Every operation is a POST request with a JSON body. JSON field names are lowerCamelCase, as in the Admin API.
A user’s preferences come in two parts:
- Shared preferences are one typed set of fields that every client application of the user honours.
- Client settings are one free-form JSON object per client application, such as the webmail or a mobile app. Only that client reads and writes it; the server stores the object as given and never interprets it.
Endpoint URL
Section titled “Endpoint URL”The User API is served at https://api.<your mail domain>/user, on the same host as the Admin API, which is served under /admin. The adminApiUrl stack output holds the host; append /user.
Hosted zone / subdomainNamespace | User API endpoint |
|---|---|
example.com, namespace left empty | https://api.example.com/user |
example.com, namespace mailbox | https://api.mailbox.example.com/user |
Authentication
Section titled “Authentication”Requests carry a Bearer JWT in the Authorization header. The User API accepts the tokens that authorize the JMAP API, so any user who can sign in to webmail can call it. No admin permission is needed.
The caller is always the user the token identifies. No request names whose preferences are read or written, and a user can reach only their own.
Operations
Section titled “Operations”| Path | Purpose |
|---|---|
POST /user/preferences/GetPreferences | Returns the shared preferences and the settings of the named client |
POST /user/preferences/UpdateSharedPreferences | Sets the shared preferences present in the request |
POST /user/preferences/UpdateClientSettings | Replaces the settings of the named client |
Writes are last-write-wins: an update replaces the part it names without checking any earlier read. An update changes only the part it names. Updating shared preferences never changes any client’s settings, and updating client settings never changes the shared preferences or another client’s settings.
Client name
Section titled “Client name”GetPreferences and UpdateClientSettings take a clientName: the fixed name a client application uses for itself, for example webmail. It must match ^[a-z][a-z0-9-]{0,15}$. Each client reads and writes only the settings under the name it gives, and other clients’ settings are never returned.
Reading
Section titled “Reading”curl -s -X POST "https://api.mail.example.com/user/preferences/GetPreferences" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"clientName": "webmail"}'{ "shared": { "language": "nl-NL" }, "settings": { "theme": "dark" }}shared holds the stored shared preferences; a field with no stored value means the user has not chosen one, and each client applies its own default. settings holds the named client’s object. A client name that has stored no settings returns an empty object.
Shared preferences
Section titled “Shared preferences”| Field | Values |
|---|---|
language | A BCP 47 language tag such as en or nl-NL, at most 35 characters. Only the shape of the tag is checked, not whether a client supports the language. |
Every field is optional. In an update, a field that is present is set, a field that is left out keeps its stored value, and an empty language clears the stored language.
curl -s -X POST "https://api.mail.example.com/user/preferences/UpdateSharedPreferences" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"shared": {"language": "nl-NL"}}'The response returns the shared preferences as stored after the write:
{ "shared": { "language": "nl-NL" }}The shared object is required.
Client settings
Section titled “Client settings”UpdateClientSettings replaces the named client’s settings with the object you send, so a setting you leave out is removed. Send back the settings that stay. An empty object {} clears the client’s settings.
curl -s -X POST "https://api.mail.example.com/user/preferences/UpdateClientSettings" \ -H "Authorization: Bearer $TOKEN" \ -H "Content-Type: application/json" \ -d '{"clientName": "webmail", "settings": {"theme": "dark"}}'The response returns the settings as stored after the write, empty when they were cleared:
{ "settings": { "theme": "dark" }}The settings object is required; a request without it is rejected rather than treated as a clear.
Limits
Section titled “Limits”| Limit | Value |
|---|---|
| Client name | Matches ^[a-z][a-z0-9-]{0,15}$ |
| Size of one client’s settings | At most 4096 bytes serialized as JSON |
| Clients with settings per user | At most 16 |
| Language tag | At most 35 characters |
Errors
Section titled “Errors”A request that breaks a rule above is rejected with HTTP 400:
GetPreferences:clientNameis missing or malformed.UpdateSharedPreferences:sharedis absent or a field is malformed.UpdateClientSettings:clientNameis missing or malformed,settingsis absent,settingsexceeds 4096 bytes, or the write would add a client beyond the limit of 16.
Related
Section titled “Related”- Using the Admin API — the administrative API on the same host
- Use the webmail interface — which settings follow the account