Skip to main content

Get Your API Key

First, you’ll need to create a Migma.ai account and generate an API key:
1

Sign Up

Create an account at migma.ai
2

Navigate to Settings

Go to Settings → Developers → API Keys
3

Create API Key

Click Create API Key, select permissions, and save your key securely
Store your API key securely! It won’t be shown again after creation. Treat it like a password.
Prefer the terminal? Install the CLI with npm install -g @migma/cli and run migma login to get started — then use commands like migma generate, migma send, and migma validate directly from your shell.

Import Your Brand

Before generating emails, you need to import your brand information:
Node.js SDK
cURL
JavaScript
Python
Brand import is asynchronous. The SDK’s importAndWait handles polling automatically. With raw HTTP, save the projectId and poll the status endpoint or use webhooks.

Generate Your First Email

Once your brand is imported, generate an email:
Node.js SDK
cURL
JavaScript
Python

Poll for Status

Email generation is asynchronous. Use the SDK’s generateAndWait — it handles polling automatically. Or set up webhooks to get notified when generation completes without polling at all.

Get, Edit, and Send the Generated Email

Use emailId from result.emails[] to fetch, prompt-edit, test-send, or send one generated email. This is required for email series because conversationId points at the whole generation.
Node.js SDK
cURL
JavaScript

Complete Example

Here’s a complete workflow from import to generated HTML:
Node.js SDK

Next steps

Node.js SDK

Full SDK guide with error handling, polling, and all 14 resources

CLI

Generate, send, and validate from your terminal

MCP

Connect Migma to Cursor, Codex, Claude, VS Code, and other AI tools

Skills

Add Migma to AI coding assistants

Set Up Webhooks

Real-time notifications instead of polling

API Reference

Full endpoint documentation

Common Issues

Check that your API key is correct and included in the Authorization header as Bearer YOUR_API_KEY
Brand imports can take 30-60 seconds. Use webhooks to get notified when complete instead of polling.
Check the error message in the response. Common issues:
  • Invalid projectId (brand not imported yet)
  • Prompt is too vague or too long
  • Rate limit exceeded
The generated HTML is optimized for email clients. Run email preflight checks to test compatibility across 30+ clients, or send a test email to yourself first.