Design and send emails with AI, straight from your code.
Get my API keyimport { Migma } from 'migma';
const migma = new Migma(process.env.MIGMA_API_KEY!);
const { data } = await migma.emails.generateAndWait({
projectId: 'your_brand_id',
prompt: 'Bring back customers who have not ordered in a while.',
languages: ['en'],
});
if (data?.result) {
const { subject, emails } = data.result;
await migma.sending.send({
recipientType: 'email',
recipientEmail: customer.email,
emailId: emails[0].emailId!,
subject,
from: process.env.EMAIL_FROM!,
fromName: 'Your Brand',
});
}Bring email to your AI assistant.
Install the official Migma plugin and sign in through your browser. No API key to paste.
Claude selected.Add Migma to Claude (opens in a new tab)See it in Claude
Try asking Claude
“Draft a welcome email using my brand and show me the preview.”
One API from your brand to the inbox.
Brands
import-brand.ts
const brand = await migma.projects.importAndWait({
urls: ['https://yourbrand.com'],
});
const projectId = brand.data?.projectId;Response
{
"projectId": "your_brand_id",
"status": "active",
"name": "Your Brand",
"domain": "yourbrand.com"
}Start from any website
Pass a URL and Migma learns the logo, colors, fonts and tone, so every email looks like your brand.
Design
design-email.ts
const { data } = await migma.emails.generateAndWait({
projectId,
prompt: 'Turn new signups into first orders.',
count: 3,
});
const emails = data?.result?.emails;Response
{
"emails": [{
"emailId": "email_abc123",
"subject": "Your first order is waiting.",
"html": "<!doctype html>...",
"screenshotUrl": "https://cdn.migma.ai/...",
"status": "ready"
}]
}Ask for one email or a whole series
Describe the outcome you want and get back the subject, HTML and a screenshot of each email.
Checks
check-email.ts
const check = await migma.validation.all({ html, subject });
const preview = await migma.previews.createAndWait({
html,
subject,
devices: ['gmail-chrome', 'outlook-2016', 'iphone-14-pro'],
});Response
{
"summary": {
"criticalIssues": 0,
"warnings": 1
}
}Catch problems before you send
Check client support, links, spelling and deliverability, then see screenshots from real devices.
Sending
send-email.ts
const { data, error } = await migma.sending.send(
{
recipientType: 'segment',
recipientId: 'seg_new_signups',
emailId: 'email_abc123',
subject: 'Your first order is waiting.',
from: process.env.EMAIL_FROM!,
fromName: 'Your Brand',
},
{ idempotencyKey: 'first-order-november' },
);Response
{
"id": "send_xyz789",
"provider": "migma",
"batchId": "batch_xyz789"
}Send to one person or a whole segment
Use Migma's sending or a provider you connected. An idempotency key stops a retry from sending twice.
Contacts
list-contacts.ts
const { data } = await migma.contacts.list({
projectId,
status: 'subscribed',
tags: 'vip,newsletter',
limit: 50,
});Response
{
"data": [{
"id": "contact_abc123",
"firstName": "Maya",
"status": "subscribed",
"tags": ["vip", "newsletter"]
}],
"count": 1
}Keep your audience in one place
Import contacts in bulk, then filter them by tag and status.
Webhooks
create-webhook.ts
const webhook = await migma.webhooks.create({
url: 'https://yourapp.com/webhooks/migma',
events: [
'email.generation.completed',
'project.import.completed',
'export.completed',
],
});Response
{
"id": "wh_abc123",
"url": "https://yourapp.com/webhooks/migma",
"active": true,
"secret": "<returned once, store it now>"
}Know when the work is done
Get an event when a design finishes, a brand imports or an export completes.
Export
export-email.ts
const html = await migma.export.html(conversationId);
const pdf = await migma.export.pdf(conversationId);
const klaviyo = await migma.export.klaviyo(conversationId);
const mailchimp = await migma.export.mailchimp(conversationId);Response
{
"files": [{
"filename": "email.html",
"format": "html",
"url": "https://cdn.migma.ai/..."
}],
"exportType": "html"
}Move it to the tools you already use
Export as HTML, PDF or PNG, or straight to Klaviyo, Mailchimp and HubSpot.
FAQ
