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
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’sgenerateAndWait — it handles polling automatically. Or set up webhooks to get notified when generation completes without polling at all.
Manual polling with the SDK
Manual polling with the SDK
Get, Edit, and Send the Generated Email
UseemailId 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
Import takes too long
Import takes too long
Brand imports can take 30-60 seconds. Use webhooks to get notified when complete instead of polling.
Generation fails
Generation fails
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
HTML looks broken
HTML looks broken
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.