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.
curl -fsSL https://migma.ai/cli | sh
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 and note the printed email ID
migma generate "Welcome email for new subscribers" --wait

# 5. Send the generated email
migma send --to sarah@example.com --email <emailId> \
  --subject "Welcome!" --from hello@yourbrand.migma.email --from-name "Your Brand"

Authentication

migma login
You’ll be prompted for your API key. Get one from Settings → API Integration → 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=your_migma_api_key
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
--reference <id>Remix from an existing conversation ID
--count <n>Request a specific number of emails for a series
Chain with validate: migma generate "..." --wait && migma validate all --conversation <conversationId>
Create a series and save each email as a separate HTML file:
migma generate "Three-email onboarding series for new trial users" --count 3 --wait --save ./onboarding.html
When a generation returns multiple emails, --save ./onboarding.html writes onboarding-1.html, onboarding-2.html, and so on. The status output also lists each email ID, which you use to fetch, edit, or send that email. Check on a running generation:
migma generate-status <conversationId>

Send

Send to an individual, a segment, or a tag. Emails send through Migma by default — you can also connect external providers.
migma send \
  --to sarah@example.com \
  --email email_abc123 \
  --from hello@yourbrand.migma.email \
  --from-name "Your Brand" \
  --subject "Your discount inside"
Use --email with the email ID returned by generation status or selected in the editor, especially multi-slot emails and series. --from-conversation works for single-email conversations.
CommandDescription
migma send-test --email <emailId> --to <email>Send a test email
migma 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 compatibilityCompatibility report for major email clients (score out of 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
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.

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 <projectId> \
  --name "Investor Update" --conversation <conversationId> --email <emailId> \
  --from hello@company.migma.email --from-name "Company" \
  --recipient-type tag --recipient-id <tagId>

# Send immediately
migma campaigns send <campaignId>

# Or schedule for later
migma campaigns schedule <campaignId> --at "2026-03-15T14:00:00Z" --timezone "America/New_York"

# Cancel a scheduled campaign
migma campaigns cancel <campaignId>
CommandDescription
migma campaigns listList campaigns for a project
migma campaigns create --name <name> --conversation <conversationId> --email <emailId> --from <email> --from-name <name> --recipient-type tag --recipient-id <id>Create 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, fetch, and prompt-edit your generated emails.
migma emails list --project <projectId>
migma emails get <emailId> --output ./email.html
migma emails edit <emailId> --prompt "Make this welcome email shorter" --output ./email.html
CommandDescription
migma emails listList emails for a project (paginated)
migma emails get <emailId>Get one generated email with production HTML
migma emails edit <emailId> --prompt <text>Prompt Migma to edit one generated email
FlagEffect
--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

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> --first-name 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 — see /sending-domains/overview)
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

Options

The root CLI accepts --json, and most project-scoped commands accept --project <id>:
FlagDescription
--jsonMachine-readable JSON output
--project <id>Override the default project on project-scoped commands
--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 everything" --wait
migma validate all --conversation <conversationId>
migma send --to test@yourbrand.com --from-conversation <conversationId> \
  --from hello@yourbrand.migma.email --from-name "Your Brand" \
  --subject "Black Friday Sale"
migma send --segment seg_vip --email <emailId> \
  --from hello@yourbrand.migma.email --from-name "Your Brand" \
  --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> --email <emailId> \
  --from hello@yourbrand.migma.email --from-name "Your Brand" \
  --subject "We're live!"

npm

View on npm

Node.js SDK

Use the SDK in your apps

API Reference

Full endpoint docs