Skip to main content
The Migma CLI wraps the full API into terminal commands. Use it for quick workflows, scripting, CI/CD pipelines, or anywhere you’d rather type than code.
npm install -g @migma/cli
Requires Node.js 18+.

Quick start

Five commands to go from zero to a sent email:
# 1. Authenticate
migma login

# 2. Import your brand
migma projects import https://yourbrand.com --wait

# 3. Set it as default
migma projects use <projectId>

# 4. Generate an email
migma generate "Welcome email for new subscribers" --wait --save ./welcome.html

# 5. Send it
migma send --to [email protected] --html ./welcome.html --subject "Welcome!"

Authentication

migma login
You’ll be prompted for your API key. Get one from Settings → API Keys. You can also set the MIGMA_API_KEY environment variable — the CLI checks it first, then falls back to the stored config.
export MIGMA_API_KEY=sk_live_your_key_here
CommandDescription
migma loginSave your API key (interactive prompt)
migma logoutRemove stored credentials
migma whoamiShow current key and default project

Generate

Create on-brand emails with AI from a single command.
migma generate "Summer sale — 30% off everything" --wait
FlagEffect
--waitBlock until generation completes
--save <file>Save the finished HTML locally (requires --wait)
--openOpen the result in your browser (requires --wait)
--image <url>Attach a reference image to the prompt
Chain with validate: migma generate "..." --wait --save ./email.html && migma validate all --html ./email.html
Check on a running generation:
migma generate status <conversationId>

Send

Send to an individual, a segment, or a tag.
migma send \
  --to [email protected] \
  --html ./promo.html \
  --subject "Your discount inside" \
  --var name=Sarah --var discount=20%
--from-conversation exports the HTML automatically — no manual export step needed.
CommandDescription
migma send test <conversationId> --to <email>Send a test email
migma send batch-status <batchId>Check batch delivery progress

Validate

Run preflight checks before you send.
migma validate all --html ./email.html
CheckWhat it does
migma validate allRun every check, show overall score
migma validate compatibilityTest across 30+ email clients (score/100)
migma validate linksFind broken links
migma validate spellingAI-powered grammar and spelling
migma validate deliverabilitySpam score and inbox prediction
All commands accept --html <file> or --conversation <id>.

Export

Export generated emails to files or platforms.
# Save HTML locally
migma export html conv_abc123 --output ./email.html

# Export for Klaviyo
migma export klaviyo conv_abc123 --type hybrid
FormatCommand
HTMLmigma export html <id>
MJMLmigma export mjml <id>
PDFmigma export pdf <id>
Klaviyomigma export klaviyo <id>
Mailchimpmigma export mailchimp <id>
HubSpotmigma export hubspot <id>
All export commands support --output <file> to download the result locally.

Audience

CommandDescription
migma contacts listList contacts (paginated)
migma contacts add --email <email>Create a contact
migma contacts get <id>Get contact details
migma contacts update <id> --firstName JaneUpdate a contact
migma contacts remove <id>Delete a contact
migma contacts import ./file.csvBulk import from CSV
The CSV importer auto-detects common column names (email, firstName, first_name, First Name, etc.). Any unrecognized columns become custom fields.
CommandDescription
migma tags listList all tags
migma tags create --name "VIP"Create a tag
migma tags delete <id>Delete a tag
CommandDescription
migma segments listList all segments
migma segments create --name "Active" --description "..."Create a segment
migma segments get <id>Get segment details
migma segments delete <id>Delete a segment

Infrastructure

CommandDescription
migma projects listList all projects (--all for every page)
migma projects get <id>Get project details
migma projects import <url>Import brand from URL (--wait to block)
migma projects use <id>Set default project
# Instant managed domain (no DNS)
migma domains managed create mycompany

# Custom domain
migma domains add mail.yourbrand.com
migma domains verify mail.yourbrand.com
CommandDescription
migma domains listList sending domains
migma domains add <domain>Add a custom domain
migma domains verify <domain>Verify DNS records
migma domains managed create <prefix>Create instant subdomain
migma domains managed delete <domain>Delete managed subdomain
CommandDescription
migma webhooks listList all webhooks
migma webhooks create --url <url> --events <events...>Create a webhook
migma webhooks test <id>Send a test event
migma webhooks delete <id>Delete a webhook

Global options

Every command supports these flags:
FlagDescription
--jsonMachine-readable JSON output
--project <id>Override the default project for this command
--helpShow help for any command
# Pipe JSON into jq
migma contacts list --json | jq '.contacts[].email'

Configuration

The CLI stores config in ~/.migma/config.json:
SettingPriority
API keyMIGMA_API_KEY env var → config file
Project ID--project flag → MIGMA_PROJECT_ID env var → config file

Common workflows

1

Generate → Validate → Send

migma generate "Black Friday — 40% off" --wait --save ./bf.html
migma validate all --html ./bf.html
migma send --to [email protected] --html ./bf.html --subject "Black Friday Sale"
migma send --segment seg_vip --html ./bf.html --subject "Black Friday Sale"
2

Import → Generate → Export to Klaviyo

migma projects import https://yourbrand.com --wait
migma projects use <projectId>
migma generate "Monthly newsletter" --wait
migma export klaviyo <conversationId>
3

CSV import → Tag → Send

migma contacts import ./subscribers.csv
migma tags create --name "Launch List"
migma send --tag <tagId> --html ./launch.html --subject "We're live!"