Overview
Automate your email workflows using Migma and n8n. Import brands from websites and generate AI-powered emails using simple drag-and-drop nodes.What is n8n? An open-source workflow automation tool with a visual interface. Perfect for connecting APIs without writing code.
Quick Setup
1
Get Your API Key
Go to Migma Settings → API Integration and create an API key
2
Add Credentials in n8n
In n8n: Settings → Credentials → Add Credential → Http Bearer AuthPaste your API key and name it “Migma API”
Key Endpoints
All endpoints usehttps://api.migma.ai as the base URL.
| Endpoint | Method | Description |
|---|---|---|
/v1/projects/import | POST | Import a brand from website URL |
/v1/projects/import/{projectId}/status | GET | Check import status |
/v1/projects/{projectId} | GET | Get project details |
/v1/projects/emails/generate | POST | Generate an email |
/v1/projects/emails/{conversationId}/status | GET | Check generation status |
/v1/export/html/{conversationId} | GET | Export as HTML |
/v1/emails/test/send | POST | Send test email |
Full API Reference
View complete documentation with all parameters and responses
Copy-Paste Workflows
1. Import a Brand
Import brand assets from a website URL.Import Brand Workflow JSON
Import Brand Workflow JSON
projectId: Use this to check statusstatus: Will be “pending” initiallydomain: Extracted domain name
2. Generate an Email
Generate an AI-powered email for a project.Generate Email Workflow JSON
Generate Email Workflow JSON
conversationId: Use this to check status and exportstatus: Will be “pending” initiallylink: Direct link to view in Migma dashboard
3. Export as HTML
Export the generated email as HTML.Export HTML Workflow JSON
Export HTML Workflow JSON
files[0].content: Full HTML content as stringfiles[0].url: Download URL (valid for 24 hours)files[0].fileSize: Size in bytes
Complete Workflow
Here’s a full workflow that imports a brand, waits for completion, generates an email, and exports it:Complete Workflow JSON
Complete Workflow JSON
- Imports a brand
- Waits and checks if import is complete (loops until done)
- Generates an email
- Waits and checks if generation is complete (loops until done)
- Exports the final HTML
Advanced Use Cases
Shopify Multi-Store Automation
For processing multiple Shopify stores from a spreadsheet, see this advanced workflow:1
Prepare Your Data
Create a Google Sheet with columns:
Store URL, Store Owner Email, Store Name2
Read from Sheet
Use n8n’s Google Sheets node to read all stores
3
Loop Through Stores
Use “Split in Batches” node to process each store one at a time
4
For Each Store
- Import brand:
POST /v1/projects/import - Connect Shopify:
POST /v1/shopify/connect - Generate email:
POST /v1/projects/emails/generate - Send test email:
POST /v1/emails/test/send
Shopify Multi-Store Workflow JSON
Shopify Multi-Store Workflow JSON
Note: To send test emails, make sure your API key has the
EMAIL_SEND permission enabled in Migma Settings → API Integration.Using Webhooks Instead of Polling
For better performance, use Migma webhooks instead of wait/check loops:- Add a Webhook node in n8n and copy the webhook URL
- In Migma Settings → API Integration → Webhooks, create a webhook
- Subscribe to events:
project.import.completedandemail.generation.completed - Your n8n workflow will be triggered automatically when events occur
Tips
Passing Data Between Nodes
Passing Data Between Nodes
Use n8n expressions to reference previous node data:
{{ $json.data.projectId }}- Access projectId from current node{{ $('Import Brand').item.json.data.projectId }}- Access data from specific node
Handling Errors
Handling Errors
Add an Error Trigger node to catch failures and send alerts or retry logic.
Batch Processing
Batch Processing
Use Split in Batches node to process multiple items from spreadsheets or databases.
Export Formats
Export Formats
Available export endpoints:
/v1/export/html/{conversationId}- Standard HTML/v1/export/klaviyo/{conversationId}- Klaviyo format/v1/export/mailchimp/{conversationId}- Mailchimp format/v1/export/mjml/{conversationId}- MJML format