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
yarn
pnpm
npx (no install)
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 < projectI d >
# 4. Generate an email
migma generate "Welcome email for new subscribers" --wait
# 5. Send using the conversation ID
migma send --to sarah@example.com --from-conversation < conversationI d > \
--subject "Welcome!" --from hello@yourbrand.migma.email --from-name "Your Brand"
Authentication
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
Command Description 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
Flag Effect --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 --reference <id>Remix from an existing conversation ID
Chain with validate: migma generate "..." --wait && migma validate all --conversation <conversationId>
Check on a running generation:
migma generate status < conversationI d >
Send
Send to an individual, a segment, or a tag. Emails send through Migma by default — you can also connect external providers .
Individual
To a segment
Raw HTML (fallback)
migma send \
--to sarah@example.com \
--from-conversation conv_abc123 \
--from hello@yourbrand.migma.email \
--from-name "Your Brand" \
--subject "Your discount inside"
--from-conversation exports and sends the generated email directly — no manual HTML export needed.
Command Description 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
Check What 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. See export options for details on each format.
# Save HTML locally
migma export html conv_abc123 --output ./email.html
# Export for Klaviyo
migma export klaviyo conv_abc123 --type hybrid
Format Command HTML migma export html <id>MJML migma export mjml <id>PDF migma export pdf <id>Klaviyo migma export klaviyo <id>Mailchimp migma export mailchimp <id>HubSpot migma export hubspot <id>
All export commands support --output <file> to download the result locally.
Campaigns
Create and manage marketing campaigns with lifecycle tracking (create, schedule, send, cancel).
Campaigns vs migma send: Use migma send for quick fire-and-forget sends (transactional emails, one-off blasts). Use migma campaigns when you need a named, trackable campaign tied to a project — with scheduling, status tracking, and recipient counts.
# Create a campaign from a generated email
migma campaigns create --project < projectI d > \
--name "Investor Update" --conversation < conversationI d > \
--from hello@company.migma.email --from-name "Company" \
--recipient-type tag --recipient-id < tagI d >
# Send immediately
migma campaigns send < campaignI d >
# Or schedule for later
migma campaigns schedule < campaignI d > --at "2026-03-15T14:00:00Z" --timezone "America/New_York"
# Cancel a scheduled campaign
migma campaigns cancel < campaignI d >
Command Description migma campaigns listList campaigns for a project migma campaigns createCreate a campaign from a generated email migma campaigns get <id>Get campaign details migma campaigns send <id>Send a campaign immediately migma campaigns schedule <id> --at <datetime>Schedule for future delivery migma campaigns cancel <id>Cancel a scheduled campaign
Emails
List and browse your generated emails.
migma emails list --project < projectI d >
Command Description migma emails listList emails for a project (paginated)
Flag Effect --limit <n>Max results (1-100, default 20) --status <status>Filter by status (pending, processing, completed, failed) --search <query>Search by title or subject
Audience
Command Description 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
Command Description 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 — see /sending-domains/overview)
migma domains managed create mycompany
# Custom domain
migma domains add mail.yourbrand.com
migma domains verify mail.yourbrand.com
Command Description 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
Command Description 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:
Flag Description --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:
Setting Priority API key MIGMA_API_KEY env var → config fileProject ID --project flag → MIGMA_PROJECT_ID env var → config file
Common workflows
Generate → Validate → Send
migma generate "Black Friday — 40% off everything" --wait
migma validate all --conversation < conversationI d >
migma send --to test@yourbrand.com --from-conversation < conversationI d > \
--from hello@yourbrand.migma.email --from-name "Your Brand" \
--subject "Black Friday Sale"
migma send --segment seg_vip --from-conversation < conversationI d > \
--from hello@yourbrand.migma.email --from-name "Your Brand" \
--subject "Black Friday Sale"
Import → Generate → Export to Klaviyo
migma projects import https://yourbrand.com --wait
migma projects use < projectI d >
migma generate "Monthly newsletter" --wait
migma export klaviyo < conversationI d >
CSV import → Tag → Send
migma contacts import ./subscribers.csv
migma tags create --name "Launch List"
migma send --tag < tagI d > --from-conversation < conversationI d > \
--subject "We're live!"