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

# 5. Send using the conversation ID
migma send --to sarah@example.com --from-conversation <conversationId> \
  --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 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
--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 <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 \
  --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.
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. 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> \
  --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 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
migma campaigns archive <id>Archive a campaign
migma campaigns unarchive <id>Unarchive a campaign
migma campaigns list --archivedList only archived campaigns

Emails

List and browse your generated emails.
migma emails list --project <projectId>
CommandDescription
migma emails listList emails for a project (paginated)
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> --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 — 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

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 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 --from-conversation <conversationId> \
  --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> --from-conversation <conversationId> \
  --subject "We're live!"

npm

View on npm

Node.js SDK

Use the SDK in your apps

API Reference

Full endpoint docs