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 → Developers → API Keys 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
{
"name": "Migma: Import Brand",
"nodes": [
{
"parameters": {},
"id": "manual-trigger",
"name": "Start",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [250, 300]
},
{
"parameters": {
"method": "POST",
"url": "https://api.migma.ai/v1/projects/import",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\"urls\": [\"https://yourwebsite.com\"]}",
"options": {}
},
"id": "import-brand",
"name": "Import Brand",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [450, 300],
"credentials": {
"httpBearerAuth": {
"id": "YOUR_CREDENTIAL_ID",
"name": "Migma API"
}
}
}
],
"connections": {
"Start": {
"main": [[{ "node": "Import Brand", "type": "main", "index": 0 }]]
}
}
}
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
{
"name": "Migma: Generate Email",
"nodes": [
{
"parameters": {},
"id": "manual-trigger",
"name": "Start",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [250, 300]
},
{
"parameters": {
"method": "POST",
"url": "https://api.migma.ai/v1/projects/emails/generate",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\"projectId\": \"YOUR_PROJECT_ID\", \"prompt\": \"Create a welcome email for new subscribers\"}",
"options": {}
},
"id": "generate-email",
"name": "Generate Email",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [450, 300],
"credentials": {
"httpBearerAuth": {
"id": "YOUR_CREDENTIAL_ID",
"name": "Migma API"
}
}
}
],
"connections": {
"Start": {
"main": [[{ "node": "Generate Email", "type": "main", "index": 0 }]]
}
}
}
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
{
"name": "Migma: Export HTML",
"nodes": [
{
"parameters": {},
"id": "manual-trigger",
"name": "Start",
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [250, 300]
},
{
"parameters": {
"method": "GET",
"url": "=https://api.migma.ai/v1/export/html/YOUR_CONVERSATION_ID",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"options": {}
},
"id": "export-html",
"name": "Export HTML",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [450, 300],
"credentials": {
"httpBearerAuth": {
"id": "YOUR_CREDENTIAL_ID",
"name": "Migma API"
}
}
}
],
"connections": {
"Start": {
"main": [[{ "node": "Export HTML", "type": "main", "index": 0 }]]
}
}
}
files[0].content: Full HTML content as stringfiles[0].url: Download URL (valid for 24 hours)files[0].fileSize: Size in bytes
Replace
YOUR_CREDENTIAL_ID, YOUR_PROJECT_ID, and YOUR_CONVERSATION_ID with your actual values, or use n8n expressions like {{ $json.data.projectId }} to pass data between nodes.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
{
"name": "Migma: Complete Workflow",
"nodes": [
{
"parameters": {
"documentId": {
"__rl": true,
"value": "1uS3X18r5pqrcZK6iHMI6StQtBaLAZvpavrUhahv_bTE",
"mode": "list",
"cachedResultName": "Migma Leads v1",
"cachedResultUrl": ""
},
"sheetName": {
"__rl": true,
"value": 1667714778,
"mode": "list",
"cachedResultName": "Sheet01",
"cachedResultUrl": ""
},
"options": {}
},
"id": "df5ca5e4-3224-42bd-a593-eecfeceaf60f",
"name": "Read Stores",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 3,
"position": [
-1760,
352
]
},
{
"parameters": {
"options": {}
},
"id": "a83ab73f-b6cd-4882-970f-983c93d7b10a",
"name": "Loop Stores",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [
-1552,
352
]
},
{
"parameters": {
"method": "POST",
"url": "https://api.migma.ai/v1/projects/import",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\"urls\": [\"{{ $json['Store URL'] }}\"]}",
"options": {}
},
"id": "2a72b8c9-76fd-4ee2-aee6-a9627e6f8a2c",
"name": "Import Store",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
-1360,
352
],
"credentials": {
"httpBearerAuth": {
"id": "StqUFSi6OmezZlVH",
"name": "Bearer Auth account"
}
}
},
{
"parameters": {
"amount": 5,
"unit": "seconds"
},
"id": "94310ed1-811c-480a-81cd-50c0b4d3d2d2",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"typeVersion": 1,
"position": [
-192,
560
],
"webhookId": "wait-webhook-gen"
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.data.status }}",
"operation": "equals",
"value2": "completed"
}
]
}
},
"id": "55ff368a-5dee-479d-aecf-c6f78c7807e4",
"name": "Is Ready?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
32,
560
]
},
{
"parameters": {
"method": "POST",
"url": "https://api.migma.ai/v1/shopify/connect",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\"projectId\": \"{{ $json.data.projectId }}\", \"shopifyStoreUrl\": \"{{ $('Loop Stores').item.json['Store URL'] }}\"}",
"options": {}
},
"id": "b5f28477-5b11-49c7-a6c0-51a6605c6a60",
"name": "Connect Shopify",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
-784,
128
]
},
{
"parameters": {
"method": "POST",
"url": "https://api.migma.ai/v1/projects/emails/generate",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\"projectId\": \"{{ $json.data.projectId }}\", \"prompt\": \"Create a welcome email\", \"webMode\": true}",
"options": {}
},
"id": "db9b18ac-e681-4771-890b-a7516d89aaf2",
"name": "Generate Email",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
-384,
64
]
},
{
"parameters": {
"url": "=https://api.migma.ai/v1/projects/emails/{{ $json.data.conversationId }}/status",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"options": {}
},
"id": "43a7fc19-604f-48a8-b01b-b564d01db916",
"name": "Check Generation",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
-176,
48
],
"credentials": {
"httpBearerAuth": {
"id": "StqUFSi6OmezZlVH",
"name": "Bearer Auth account"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://api.migma.ai/v1/emails/test/send",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\"conversationId\": \"{{ $json.data.conversationId }}\", \"to\": \"{{ $('Loop Stores').item.json['Store Owner Email'] }}\"}",
"options": {}
},
"id": "7ea88642-5680-49ff-ae09-df719a68f773",
"name": "Send Test Email",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
608,
144
]
},
{
"parameters": {},
"type": "n8n-nodes-base.manualTrigger",
"typeVersion": 1,
"position": [
-1920,
352
],
"id": "bb3666c4-1a2b-4638-8b50-c90e91761c82",
"name": "When clicking ‘Execute workflow’"
},
{
"parameters": {
"url": "=https://api.migma.ai/v1/projects/import/{{ $json.data.projectId }}/status",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"options": {}
},
"id": "3d6bf6d2-cfd7-4106-b291-a658cd3dc7db",
"name": "Check Import Status1",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [
-1168,
352
],
"credentials": {
"httpBearerAuth": {
"id": "StqUFSi6OmezZlVH",
"name": "Bearer Auth account"
}
}
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.data.status }}",
"operation": "equals",
"value2": "active"
}
]
}
},
"id": "8cd0a55d-23fa-47d7-a42c-4e3377f587c9",
"name": "Is Complete?1",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [
-992,
352
]
},
{
"parameters": {
"amount": 10
},
"type": "n8n-nodes-base.wait",
"typeVersion": 1.1,
"position": [
-784,
368
],
"id": "5930e29f-c31b-4f8c-a5b9-6595df8a3e41",
"name": "Wait1",
"webhookId": "318bf499-3ab0-4862-979e-7ae8f7555e66"
}
],
"pinData": {},
"connections": {
"Read Stores": {
"main": [
[
{
"node": "Loop Stores",
"type": "main",
"index": 0
}
]
]
},
"Loop Stores": {
"main": [
[
{
"node": "Import Store",
"type": "main",
"index": 0
}
],
[
{
"node": "Import Store",
"type": "main",
"index": 0
}
]
]
},
"Import Store": {
"main": [
[
{
"node": "Check Import Status1",
"type": "main",
"index": 0
}
]
]
},
"Wait": {
"main": [
[
{
"node": "Is Ready?",
"type": "main",
"index": 0
}
]
]
},
"Is Ready?": {
"main": [
[
{
"node": "Send Test Email",
"type": "main",
"index": 0
}
],
[
{
"node": "Wait",
"type": "main",
"index": 0
}
]
]
},
"Connect Shopify": {
"main": [
[
{
"node": "Generate Email",
"type": "main",
"index": 0
}
]
]
},
"Generate Email": {
"main": [
[
{
"node": "Check Generation",
"type": "main",
"index": 0
}
]
]
},
"Check Generation": {
"main": [
[
{
"node": "Is Ready?",
"type": "main",
"index": 0
}
]
]
},
"Send Test Email": {
"main": [
[
{
"node": "Loop Stores",
"type": "main",
"index": 0
}
]
]
},
"When clicking ‘Execute workflow’": {
"main": [
[
{
"node": "Read Stores",
"type": "main",
"index": 0
}
]
]
},
"Check Import Status1": {
"main": [
[
{
"node": "Is Complete?1",
"type": "main",
"index": 0
}
]
]
},
"Is Complete?1": {
"main": [
[
{
"node": "Connect Shopify",
"type": "main",
"index": 0
}
],
[
{
"node": "Wait1",
"type": "main",
"index": 0
}
]
]
},
"Wait1": {
"main": [
[
{
"node": "Check Import Status1",
"type": "main",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "52001030-f518-4ec1-9ecb-ef3adc46bf07",
"meta": {
"instanceId": "2d68fadaa6ab455961c0fbd849b7b2cf998bc0f9d88f3977fe8e22efddd544b8"
},
"id": "Gk1gFIZGdAKIJ7oo",
"tags": []
}
- 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
{
"name": "Migma: Shopify Multi-Store",
"nodes": [
{
"parameters": {
"documentId": "YOUR_GOOGLE_SHEET_ID",
"sheetName": "Sheet1",
"options": {}
},
"id": "read-sheet",
"name": "Read Stores",
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 3,
"position": [250, 300],
"credentials": {
"googleSheetsOAuth2Api": {
"id": "YOUR_GOOGLE_CREDENTIAL_ID",
"name": "Google Sheets"
}
}
},
{
"parameters": {
"batchSize": 1,
"options": {}
},
"id": "loop",
"name": "Loop Stores",
"type": "n8n-nodes-base.splitInBatches",
"typeVersion": 3,
"position": [450, 300]
},
{
"parameters": {
"method": "POST",
"url": "https://api.migma.ai/v1/projects/import",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\"urls\": [\"{{ $json['Store URL'] }}\"]}",
"options": {}
},
"id": "import-store",
"name": "Import Store",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [650, 300],
"credentials": {
"httpBearerAuth": {
"id": "YOUR_CREDENTIAL_ID",
"name": "Migma API"
}
}
},
{
"parameters": {
"amount": 10,
"unit": "seconds"
},
"id": "wait",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"typeVersion": 1,
"position": [850, 300],
"webhookId": "wait-webhook"
},
{
"parameters": {
"method": "GET",
"url": "=https://api.migma.ai/v1/projects/import/{{ $json.data.projectId }}/status",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"options": {}
},
"id": "check-status",
"name": "Check Status",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [1050, 300],
"credentials": {
"httpBearerAuth": {
"id": "YOUR_CREDENTIAL_ID",
"name": "Migma API"
}
}
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.data.status }}",
"operation": "equals",
"value2": "active"
}
]
}
},
"id": "is-ready",
"name": "Is Ready?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [1250, 300]
},
{
"parameters": {
"method": "POST",
"url": "https://api.migma.ai/v1/shopify/connect",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\"projectId\": \"{{ $json.data.projectId }}\", \"shopifyStoreUrl\": \"{{ $('Loop Stores').item.json['Store URL'] }}\"}",
"options": {}
},
"id": "connect-shopify",
"name": "Connect Shopify",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [1450, 200],
"credentials": {
"httpBearerAuth": {
"id": "YOUR_CREDENTIAL_ID",
"name": "Migma API"
}
}
},
{
"parameters": {
"method": "POST",
"url": "https://api.migma.ai/v1/projects/emails/generate",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\"projectId\": \"{{ $json.data.projectId }}\", \"prompt\": \"Create a welcome email\", \"webMode\": true}",
"options": {}
},
"id": "generate-email",
"name": "Generate Email",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [1650, 200],
"credentials": {
"httpBearerAuth": {
"id": "YOUR_CREDENTIAL_ID",
"name": "Migma API"
}
}
},
{
"parameters": {
"amount": 5,
"unit": "seconds"
},
"id": "wait-gen",
"name": "Wait",
"type": "n8n-nodes-base.wait",
"typeVersion": 1,
"position": [1850, 200],
"webhookId": "wait-webhook-gen"
},
{
"parameters": {
"method": "GET",
"url": "=https://api.migma.ai/v1/projects/emails/{{ $json.data.conversationId }}/status",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"options": {}
},
"id": "check-gen",
"name": "Check Generation",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [2050, 200],
"credentials": {
"httpBearerAuth": {
"id": "YOUR_CREDENTIAL_ID",
"name": "Migma API"
}
}
},
{
"parameters": {
"conditions": {
"string": [
{
"value1": "={{ $json.data.status }}",
"operation": "equals",
"value2": "completed"
}
]
}
},
"id": "is-gen-ready",
"name": "Is Ready?",
"type": "n8n-nodes-base.if",
"typeVersion": 1,
"position": [2250, 200]
},
{
"parameters": {
"method": "POST",
"url": "https://api.migma.ai/v1/emails/test/send",
"authentication": "genericCredentialType",
"genericAuthType": "httpBearerAuth",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"specifyBody": "json",
"jsonBody": "={\"conversationId\": \"{{ $json.data.conversationId }}\", \"to\": \"{{ $('Loop Stores').item.json['Store Owner Email'] }}\"}",
"options": {}
},
"id": "send-email",
"name": "Send Test Email",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4,
"position": [2450, 100],
"credentials": {
"httpBearerAuth": {
"id": "YOUR_CREDENTIAL_ID",
"name": "Migma API"
}
}
}
],
"connections": {
"Read Stores": {
"main": [[{ "node": "Loop Stores", "type": "main", "index": 0 }]]
},
"Loop Stores": {
"main": [[{ "node": "Import Store", "type": "main", "index": 0 }]]
},
"Import Store": {
"main": [[{ "node": "Wait", "type": "main", "index": 0 }]]
},
"Wait": {
"main": [[{ "node": "Check Status", "type": "main", "index": 0 }]]
},
"Check Status": {
"main": [[{ "node": "Is Ready?", "type": "main", "index": 0 }]]
},
"Is Ready?": {
"main": [
[{ "node": "Connect Shopify", "type": "main", "index": 0 }],
[{ "node": "Wait", "type": "main", "index": 0 }]
]
},
"Connect Shopify": {
"main": [[{ "node": "Generate Email", "type": "main", "index": 0 }]]
},
"Generate Email": {
"main": [[{ "node": "Wait", "type": "main", "index": 0 }]]
},
"Check Generation": {
"main": [[{ "node": "Is Ready?", "type": "main", "index": 0 }]]
},
"Is Ready?": {
"main": [
[{ "node": "Send Test Email", "type": "main", "index": 0 }],
[{ "node": "Wait", "type": "main", "index": 0 }]
]
},
"Send Test Email": {
"main": [[{ "node": "Loop Stores", "type": "main", "index": 0 }]]
}
}
}
Note: To send test emails, make sure your API key has the
EMAIL_SEND permission enabled in Migma Settings → Developers → API Keys.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 → Developers → 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
Need Help?
API Documentation
Complete API reference with all endpoints
Webhooks
Set up real-time event notifications
n8n Documentation
Learn more about n8n
Join Discord
Get help from the community