List only users with stalwart-cli

Your question

Hi,

I’m trying to create a dynamically mailing list with all the users from the servers. In order to do this I’m thinking to create a script which is listing the users with stalwart-cli and updating the mailing list.
I couldn’t found out how to filter only users in Account query. Is it possible?

Thanks,
Andrei

Let me look up the CLI account commands and how filtering works.

Based on the docs, the x:Account/query filter does not expose a type or role condition directly - the supported filter conditions are only text, name, domainId, memberTenantId, and memberGroupIds. There is no --where type=User equivalent in the CLI query for accounts.

However, there are two practical workarounds:

Option 1: Use stalwart-cli describe Account to confirm available filters

Run this first to see exactly what filter keys your version exposes:

stalwart-cli describe Account

Look at the Filters: section output. If a type/variant filter isn’t listed, you’ll need the approach below.

Option 2: Post-filter with jq on the roles field

Since accounts are created with "roles": {"@type": "User"} (vs "@type": "Admin" or "@type": "Group"), you can fetch all accounts with --json and filter in jq:

stalwart-cli query Account --fields id,name,roles --json \
  | jq -r 'select(.roles["@type"] == "User") | .name'

This streams all accounts and keeps only those whose roles variant is User, which you can then pipe into your mailing list update script.

Option 3: Use memberGroupIds filter (if users share a group)

If all regular users are members of a specific group, you can filter by that:

stalwart-cli query Account --where memberGroupIds=<group-id> --json

The query docs are at: Searching and listing | Stalwart and the Account object reference (including all supported filter conditions) is at: Account | Stalwart

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong. If you found it useful, mention @helpbot in any reply to ask follow-up questions and the bot will respond again.

Thanks helpbot.

It is working.