Scripting & Automation

Automate workflows with msgctl CLI

Batch Operations

#!/bin/bash
# Bulk create aliases from CSV
while IFS=, read -r alias destination; do
    msgctl alias create "$alias" "$destination"
done < aliases.csv

JSON Output for Processing

msgctl alias list --format json | jq '.[] | select(.enabled==false)'
msgctl domain list --format json | jq -r '.[].domain'

Exit Codes

msgctl returns standard exit codes:

  • 0 - Success
  • 1 - General error
  • 2 - Authentication error
  • 3 - Resource not found

Example: Daily Quarantine Report

#!/bin/bash
# Send daily report of quarantined messages
COUNT=$(msgctl quarantine list --since today --format json | jq length)
echo "Quarantined messages today: $COUNT" | mail -s "Daily Report" admin@example.com