
Use the SDK, CLI, OpenClaw, Skills, or MCP to integrate Migma into your workflow
Installation
migma login or MIGMA_API_KEY (CI). Hosted MCP clients should connect https://migma.ai/mcp instead of constructing the SDK by hand.
Quick Start
OpenClaw
Use Migma from WhatsApp, Telegram, and Discord with OpenClaw.
Configuration
Error Handling
Every method returns{ data, error } — it never throws:
validation_error, not_found, unauthorized, forbidden, rate_limit_exceeded, conflict, timeout, network_error, internal_error, unknown
Async Polling Helpers
Email generation, brand import, and preview creation are asynchronous. The SDK provides*AndWait helpers that poll automatically until the operation completes:
You can cancel any polling operation with an
AbortController:
Generated emails and series
Generate one email or a full series from the same API. Passcount when you want a specific number of emails; otherwise Migma infers the output from the prompt.
result.html and result.subject are always the primary email for backwards compatibility. Use result.emails[] when you need the stable emailId, per-email HTML, screenshots, or series order.
Edit generated emails
Fetch one generated email by ID, run the existing synchronous edit, or start a queued edit:startEdit and getEditStatus require an SDK build that includes queued email edits. If your installed package does not expose them, use the REST fallback below. Older SDK builds may also retry synchronous edit calls after 5xx or 429; create the client with maxRetries: 0 before making that write, or prefer the idempotent REST async flow.startEdit(emailId, { prompt, label? }, options?: CallOptions) returns MigmaResult<EmailEditOperation> after the job is durably queued. It requires email:write and email:read; credits are checked when the worker starts, with no AI work on the request path. The initial result can have a terminal status on an idempotent replay, but it never includes result, so read it with getEditStatus(emailId, editId).
Poll according to pollAfterMs until the exact edit status is completed or failed. Do not use conversation generation status, because a previous turn may already be completed. There is no editAndWait helper, and failed or stalled rewrites are not automatically retried. Edit time varies with section and image complexity, provider behavior, and retries; no fixed maximum latency is established.
REST fallback
Email performance
See how a generated email performed across every API send of it, or pull its per-recipient send log:Resources
SDK resources cover the public v1 surface used by apps and agents (some advanced campaign/preview routes stay HTTP-only).Complete Example
Here’s a full workflow — import a brand, generate an email, export it, and send:conversationId also works. For multi-slot emails and series, send a specific email with emailId:
Resources
npm
View on npm registry
CLI
Use Migma from the command line
API Reference
Full endpoint documentation
Discord
Get help from the community