This confirms x:Account/get (a privileged admin API, not impersonation) exposes usedDiskQuota per account, no impersonation needed. Now check if there’s a per-account email/message count field or if that indeed requires impersonating via JMAP Mailbox/Email counts. Let’s check the Domain object too, and search “totalEmails” or similar.
I have enough information now to answer accurately.
Based on the docs, the Account object exposes usedDiskQuota directly to admins (via x:Account/get, gated by the sysAccountGet permission) — no impersonation needed for disk usage. That covers mailbox size per account. However, there is no equivalent server-set field on the Account object for the actual message count; that would require querying the Email/Mailbox objects within the account’s own JMAP namespace, which does require signing in as that account (impersonation).
So your understanding is correct for message counts, but not for size:
- Domains, domain aliases, mailboxes (as principals), and disk usage can all be retrieved with an admin-privileged account using
Domain/get, Account/get (which exposes usedDiskQuota), etc. No impersonation required for these.
- Number of e-mails per mailbox is not exposed as a field on the Account object; getting exact message counts means querying
Email/query or Mailbox/get inside that account’s own JMAP session, which does require the impersonate permission.
If you’re only after per-account disk usage (not exact email counts), you can build the report without impersonation at all, using the Account object’s usedDiskQuota field together with Domain and Account queries.
Your understanding is largely correct. Domains, domain aliases, and mailbox disk usage can be pulled without impersonation, but per-mailbox message counts require going through the mailbox’s own JMAP data, which does require signing in as (or impersonating) that account.
What is available without impersonation:
- Domains and their aliases: via the
Domain object (x:Domain/get / x:Domain/query, needs the relevant sysDomain* permissions).
- Mailbox/account disk usage: the
Account object has a server-set usedDiskQuota field (bytes currently consumed), retrievable with x:Account/get under the sysAccountGet permission, no impersonation needed.
What is not exposed at the account-registry level:
- The number of emails per mailbox is JMAP
Mailbox/Email data that lives inside the individual account’s own namespace, so reading it requires acting as that account, which today means using the impersonate permission and the composite target%impersonator login (docs: Administrators / Impersonation).
If you want to limit exposure, you can scope a dedicated role that only holds impersonate plus the minimal JMAP read permissions needed (e.g. jmapMailboxGet), rather than granting it through a full admin role, and use a service account whose password is only used by the reporting script. But there is currently no separate “read-only usage stats” endpoint that avoids impersonation for message counts.
This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.