Discover Shared Accounts via the Middleware Shared Account API
- Deciders: Julian Bäume
- Date: 2026-09-07
Status
Accepted
Context
Teams has always derived its shared inboxes from account?action=all: every non-primary mail account of a user is a candidate, and an account counts as shared once at least SHARED_INBOX_MIN_USERS (default 2) distinct users have opened Teams with it. That heuristic was the only option because App Suite had no notion of a shared mailbox beyond "several users happen to have a secondary account with the same address".
The App Suite middleware now ships shared accounts (module sharedaccount, capability shared_accounts): provisioned groupware entities such as support@example.com that an administrator grants to users and groups explicitly, with a per-module permission set (viewer to admin) and capabilities such as sendAs and sendOnBehalf. Internally MW mounts a shared account as a secondary mail account, so it keeps showing up in account?action=all, but the module additionally exposes:
sharedaccount?action=all: the shared accounts the session user may access, each with the entity id (<entity>@<context>), display name, primary address, the mail account id MW mounted for this user, the per-userenabledflag and the user's effective capabilities.sharedaccount?action=get&accountId=…: the same record for one account.
Two things in Teams depend on knowing whether an account is a shared account:
- Visibility. A shared account with one grantee is a legitimate shared inbox, but the user-count heuristic hides it until a second user shows up.
- Reply identity. Teams sends replies with the shared address in
From. MW only accepts that when the user holdssendAs; users withsendOnBehalfneed the acting user inSender, and users with neither may not send as the account at all.
Decision
Teams consumes the shared account API as an enrichment layer on top of the existing account sync, not as a replacement for it.
- The accounts route calls
sharedaccount?action=allalongsideaccount?action=alland joins the result to the mail accounts by mail account id (fallback: primary address). Matched accounts are reported assharedwith theirsharedAccountIdand the user'scapabilities. - A shared account is visible regardless of
SHARED_INBOX_MIN_USERS, unless the user disabled it in App Suite (userSettings.enabled = false), in which case it is treated like a hidden account. Accounts MW does not report as shared keep the heuristic. - The inbox row stores
shared_account_idonce MW has reported it and never clears it: if a grant is revoked, the mail account disappears fromaccount?action=alland the existing removal path takes care of it. This keeps shared accounts visible through transient MW failures and on requests where the module is unavailable. - The membership list (
users_to_inbox) is still built incrementally from users who open Teams. The MW API answers "which accounts may I use", not "who else may use this account"; the inverse is only available through provisioning interfaces Teams does not hold credentials for. - When a reply is sent from an inbox with a stored
shared_account_id, the send route fetches the user's effective capabilities live (action=get) and picks the identity:sendAskeeps the shared address alone inFrom;sendOnBehalfadds the user asSender; neither sends from the user's own address, mirroring App Suite's compose window. If MW cannot answer, the previous send-as behaviour is kept rather than failing the send. - Every call to the module is fail-soft. An error response, HTTP error or timeout yields "unknown" and the code falls back to persisted knowledge and the heuristic. Deployments without the feature behave exactly as before.
- Shared accounts become the recommended way to set up a shared inbox, and the secondary-account approach (one secondary mail account per member with shared credentials, detected through
SHARED_INBOX_MIN_USERS) is deprecated. It keeps working so existing teams are not disrupted, but the documentation points new setups at shared accounts and describes the migration (provision a shared account for the same address, grant it, remove the secondary accounts). Removing the heuristic is a separate decision once production teams have migrated.
Consequences
Positive
- Shared accounts provisioned in App Suite appear in Teams for their first user, without the two-user workaround or
SHARED_INBOX_MIN_USERS=1. - Replies from users with
sendOnBehalfsucceed and carry the correct headers; users without sending rights no longer trigger MW send errors. - No new configuration; the feature activates itself when MW offers the module.
Negative
- One extra MW round trip per accounts sync and per send from a shared account.
- A shared account with the mail module withheld (calendar-only grant) is matched by address only; if MW reports no address either, it is not recognised and falls back to the heuristic.
- Capabilities are not persisted, so the frontend only sees them after a sync; the send path does not rely on them and re-reads them live.
Risks
- The
shared_account_idcolumn is set-only. Should MW ever convert a shared account back into a plain secondary account without changing the address, the row keeps its shared status. - The module's HTTP contract is new; the client validates the response shape and treats any deviation as "unavailable".
Alternatives Considered
Replace the account sync with the shared account API. Rejected: secondary accounts shared by convention (the pre-existing production setups) would vanish, and MW deployments without the capability would lose all shared inboxes.
Use the administrative REST API (/preliminary/sharedaccounts/v1) to resolve members. Rejected for now: it needs the MW REST basic-auth credentials, is documented as preliminary, and only answers per user as well, so it would not give the member list either.
Persist capabilities per user and inbox. Rejected: capabilities change through group membership and provisioning without any signal to Teams; a live read at send time is cheap and always current.

