Email infrastructure for the agentic era

Generate, preview, validate, and send emails, from your code, your terminal, or your AI agent. One API, every workflow.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import Migma from 'migma';

const migma = new Migma(process.env.MIGMA_API_KEY);

const email = await migma.emails.generateAndWait({
  projectId: 'proj_abc123', // your brand colors, logo, and knowledge
  prompt: 'Welcome email for new subscribers',
});

await migma.sending.send({
  recipientEmail: '[email protected]',
  conversationId: email.data.conversationId,
  subject: email.data.result.subject,
  from: '[email protected]',
  fromName: 'Your Brand',
});
200POST /v1/projects/emails/generate

One platform, every interface

Node.js library

Import a brand, generate an email, and send it, all in a few lines of TypeScript. The SDK handles polling, retries, and error handling for you.

SDK docs

Command line

Create and send emails without leaving the terminal. Chain commands in scripts, pipe JSON output, or add to your CI/CD pipeline.

CLI reference

Emails from any chat platform

OpenClaw is an open-source AI agent for WhatsApp, Telegram, Discord, and Slack. Install the Migma skill and generate, validate, and send emails from a chat message.

OpenClaw docs

Built for AI agents

Connect Migma to your agent stack, MCP, Skills, or direct API calls

Brands

import-brand.ts
import Migma from 'migma';

const migma = new Migma(process.env.MIGMA_API_KEY);

// Import brand from a website, auto-polls
const brand = await migma.projects.importAndWait({
  urls: ['https://yourbrand.com']
});

console.log(brand.data.projectId); // proj_abc123
console.log(brand.data.name);

// List all projects
const projects = await migma.projects.list();
console.log(projects.data.projects);

Import brands from any URL

Pass a website URL, Migma extracts colors, fonts, logos, and tone of voice automatically. Returns a projectId you use everywhere.

Learn more

Email Generation

generate-email.ts
import Migma from 'migma';

const migma = new Migma(process.env.MIGMA_API_KEY);

// Generate and wait, returns conversationId
const email = await migma.emails.generateAndWait({
  projectId: 'proj_123',
  prompt: 'Welcome email for new subscribers',
  languages: ['en']
});

console.log(email.data.conversationId); // conv_xyz789
console.log(email.data.result.subject);
console.log(email.data.result.html);

Generate on-brand emails

Async email generation returns a conversationId. Poll or use webhooks. Get HTML, React code, and subject when ready.

Learn more

Send Email

send-email.ts
import Migma from 'migma';

const migma = new Migma(process.env.MIGMA_API_KEY);

// Send to a single recipient using conversationId
const result = await migma.sending.send({
  recipientType: 'email',
  recipientEmail: '[email protected]',
  conversationId: email.data.conversationId,
  subject: email.data.result.subject,
  from: '[email protected]',
  fromName: 'Your Brand',
});

console.log(result.data.id);

// Or send to an entire segment
await migma.sending.send({
  recipientType: 'segment',
  recipientId: 'seg_vip',
  conversationId: email.data.conversationId,
  subject: 'Exclusive offer',
  from: '[email protected]',
  fromName: 'Your Brand',
});

Send to individuals or audiences

Pass a conversationId, the API resolves the template and project automatically. Send to one recipient, a tag, or a segment.

Learn more

Email Preview

preview-email.ts
import Migma from 'migma';

const migma = new Migma(process.env.MIGMA_API_KEY);

// Create previews and wait for screenshots
const preview = await migma.previews.createAndWait({
  html: email.data.result.html,
  subject: 'Welcome aboard!',
  devices: [
    'gmail-web', 'outlook-2021',
    'iphone-15', 'pixel-8'
  ]
});

// Each device has a screenshot URL
for (const d of preview.data.devices) {
  console.log(d.deviceName, d.screenshotUrl);
}

Preview on 40+ real devices

Generate screenshots rendered on real email clients. Test across Gmail, Outlook, iPhone, and more.

Learn more

Contacts

list-contacts.ts
import Migma from 'migma';

const migma = new Migma(process.env.MIGMA_API_KEY);

// List contacts with filters
const contacts = await migma.contacts.list({
  projectId: 'proj_123',
  status: 'subscribed',
  tags: 'vip,newsletter',
  page: 1,
  limit: 50
});

console.log(contacts.data);
console.log(contacts.count);

Manage your audience

Import contacts in bulk, segment audiences, filter by tags and status, and manage subscriber lists.

Learn more

Export

export-email.ts
import Migma from 'migma';

const migma = new Migma(process.env.MIGMA_API_KEY);

// Export to HTML
const html = await migma.export.html('conv_abc123');
console.log(html.data.files[0].url);

// Export to Klaviyo
const klaviyo = await migma.export.klaviyo('conv_abc123');

// Export to PDF
const pdf = await migma.export.pdf('conv_abc123');

// Other formats: mjml, mailchimp, hubspot

Export to any ESP

Export conversations to Mailchimp, Klaviyo, HubSpot, HTML, MJML, or PDF, one method per format.

Learn more

Get started in minutes

Three steps to your first AI-generated email

1

Install

terminal
npm install migma
2

Authenticate

terminal
export MIGMA_API_KEY="sk_live_..."
3

Generate and send

generate-and-send.ts
import Migma from 'migma';

const migma = new Migma(process.env.MIGMA_API_KEY);

// Generate, returns a conversationId
const email = await migma.emails.generateAndWait({
  projectId: 'proj_123',
  prompt: 'Welcome email for new subscribers',
  languages: ['en']
});

// Send the generated email
await migma.sending.send({
  recipientType: 'email',
  recipientEmail: '[email protected]',
  conversationId: email.data.conversationId,
  subject: email.data.result.subject,
  from: '[email protected]',
  fromName: 'Your Brand',
});

Frequently Asked Questions

How do I authenticate with the API?

Include your API key in the Authorization header as a Bearer token. You can create and manage API keys from your dashboard settings.

What are the rate limits?

Free plans allow 10 requests/minute, Pro plans 100 requests/minute, and Enterprise plans have custom limits. Rate limit info is included in response headers.

Is there a TypeScript SDK?

Yes. Install the official SDK with npm install migma. It's TypeScript-first with full type definitions, async/await support, and built-in polling helpers.

How does email generation work via API?

Call migma.emails.generateAndWait() or POST to /v1/projects/emails/generate. You'll get back a conversationId and the generated HTML. Use the HTML to send via the sending API, or export to Klaviyo, Mailchimp, PDF, and more.

Can I validate emails programmatically?

Yes. The validation API checks compatibility across 40+ email clients, validates links, runs AI spell/grammar checks, and predicts deliverability, all via simple POST endpoints.

Do you support webhooks?

Yes. Instead of polling for status updates, configure webhooks to receive real-time notifications when email generation completes, exports finish, or other events occur.