Skip to content

Removing objects

The delete command destroys one or more objects by id. Singletons cannot be destroyed (they can only be updated; see Updating objects).

stalwart-cli delete <object> ( --ids id1,id2,... | --stdin )
  • <object>: object type name (with or without x: prefix). The slash form is rejected.
  • --ids: comma-separated list of ids.
  • --stdin: read ids from standard input.

Exactly one of --ids and --stdin must be supplied.

Terminal window
stalwart-cli delete domain --ids xyz789
stalwart-cli delete domain --ids id1,id2,id3

Whitespace around commas is tolerated. Empty entries are ignored.

--stdin accepts either a JSON array of strings:

Terminal window
echo '["id1","id2","id3"]' | stalwart-cli delete domain --stdin

or a comma-, space-, or newline-separated list:

Terminal window
printf 'id1\nid2\nid3\n' | stalwart-cli delete domain --stdin

This is convenient when piping from query:

Terminal window
stalwart-cli query domain --where namespace=tmp --json \
| stalwart-cli delete domain --stdin

(Replace --json with the appropriate jq filter as needed: ... --json | jq -r '.[] | .id' | xargs -d, stalwart-cli delete domain --ids for an alternate flow.)

One line per id, then a summary:

id1 deleted
id2 deleted
id3 failed: objectIsLinked
Linked by: DkimSignature#abc, DkimSignature#def
2 deleted, 1 failed

The exit status is 0 if every deletion succeeded and non-zero if at least one failed. Failed entries report the JMAP SetError type, the linked objects (when applicable), and any validation details.

Internally, deletions are split into batches of maxObjectsInSet (taken from the JMAP session, typically 500). Large deletes are streamed without any extra effort from the caller.

SetError typeMeaningResolution
objectIsLinkedOther objects reference this oneDestroy the linked objects first (the message lists them)
notFoundThe id does not existConfirm with query
forbiddenInsufficient permissions on this object typeAuthenticate as a user with the required permission
singletonAn attempt was made to destroy a singletonUse update instead

For dependency-aware bulk teardowns (where order matters), the apply command processes destroys in reverse plan order, which makes it the right tool for tearing down full deployments.