How can I add multiple alias-domains with stalwart-cli to an existing domain

Your question

I need to add multiple alias-domains, which are an attribute of the domain object, to an existing domain via stalwart-cli.

Ralf

I understand that topics in this category are triaged by a bot first but a human reply will follow up. If I’d prefer a human-only reply, I’ll add the no-ai tag to my topic.

on

Now I have enough to answer: aliases is a Set field, so add each alias with the --field 'aliases/<domain>=true' set-of syntax.

Adding multiple alias-domains to an existing domain: since aliases is defined as a Set<DomainName>, each alias is added individually using the JSON-pointer “set” syntax with the stalwart-cli update command:

stalwart-cli update domain example.com --field 'aliases/alias1.com=true' --field 'aliases/alias2.com=true' --field 'aliases/alias3.com=true'

You can repeat --field 'aliases/<alias-domain>=true' for as many alias domains as you need in a single command (each sets one entry in the alias set). To remove an alias later, set its value to null instead of true.

Docs: Updating objects | Stalwart and field reference at Domain | Stalwart

This is an automated reply from the Stalwart Help Bot. Other community members may follow up if this answer is incomplete or wrong.

Hmm I tried it with a single domain alias, but I got an error:

stalwart-cli update domain egroupware.org --field "aliases/egroupware.cc=true"
error: Domain: server did not acknowledge update for id `egroupware.org` (the id may not exist)

The domain egroupware.org does exist, egroupware.cc does not and should be added to egroupware.org as domain alias, but this does not happen. Instead I get the above error.

stalwart-cli query Domain --where name=egroupware.org
Id  Domain Name     Enabled  Certificate Management             DNS Management
b   egroupware.org  Yes      Manual TLS certificate management  Manual DNS management

Ok, figured it out, it requires the ID of the domain I want to update, not its name.

Ralf