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.
Requires Node.js 18+.

Quick start

Five commands to go from zero to a sent email:

Authentication

A browser window opens so you can sign in and approve access. The CLI stores the key locally. Headless agents: migma login --claim, or fetch https://api.migma.ai/auth.md. CI and servers: set MIGMA_API_KEY.

Generate

Create on-brand emails with AI from a single command.
Chain with validate: migma generate "..." --wait && migma validate all --conversation <conversationId>
Create a series and save each email as a separate HTML file:
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:

Send

Send to an individual, a segment, or a tag. Emails send through Migma by default — you can also connect external providers.
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.
Add --idempotency-key <key> to send to make a retry safe: sending the same key with the same body within 24 hours replays the original response instead of sending twice. Use a deterministic key you can reproduce on retry (for example send-<emailId>-<recipient>), never a random value or timestamp.

Validate

Run preflight checks before you send.
All commands accept --html <file> or --conversation <id>.

Export

Export generated emails to files or platforms. See export options for details on each format.
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.
campaigns logs accepts --status (delivered, opened, clicked, bounced, spam_report), --limit (1-100), and --cursor for the next page. Stats come from the tracking worker and may be slightly stale; botOpens, botClicks, and mppOpens reflect Apple Mail Privacy Protection and bot detection when available.
campaigns create, campaigns send, and campaigns schedule all accept --idempotency-key <key> for safe retries. The same key with the same body within 24 hours replays the original response. For campaign sends, a deterministic key like campaign-send-<campaignId> prevents a retried send from going out twice. Don’t use a random value or timestamp.

Emails

List, fetch, and prompt-edit your generated emails.
emails logs accepts --status (delivered, opened, clicked, bounced, complained, suppressed, sent), --limit (1-100), and --cursor for the next page. Stats come from the tracking worker and may be slightly stale; opens are directional (Apple Mail Privacy Protection and bots inflate them) while clicks and delivery are stronger signals.

Audience

The CSV importer auto-detects common column names (email, firstName, first_name, First Name, etc.). Any unrecognized columns become custom fields.contacts add accepts --idempotency-key <key> so a retried create won’t duplicate the contact: the same key with the same body within 24 hours replays the original response. A deterministic key like contact-<email> works well.

Infrastructure


Options

The root CLI accepts --json, and most project-scoped commands accept --project <id>:

Configuration

The CLI stores config in ~/.migma/config.json:

Common workflows

1

Generate → Validate → Send

2

Import → Generate → Export to Klaviyo

3

CSV import → Tag → Send


npm

View on npm

Node.js SDK

Use the SDK in your apps

API Reference

Full endpoint docs