Click Create API Key, select permissions, and save your key securely
Store your API key securely! It won’t be shown again after creation. Treat it like a password.
Prefer the terminal? Install the CLI with npm install -g @migma/cli and run migma login to get started — then use commands like migma generate, migma send, and migma validate directly from your shell.
Brand import is asynchronous. The SDK’s importAndWait handles polling automatically. With raw HTTP, save the projectId and poll the status endpoint or use webhooks.
// generateAndWait polls automatically until the email is readyconst { data, error } = await migma.emails.generateAndWait({ projectId: 'your_project_id', prompt: 'Create a welcome email for new subscribers', languages: ['en']});console.log('HTML:', data.result.html);
cURL
Copy
Ask AI
curl -X POST https://api.migma.ai/v1/projects/emails/generate \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "projectId": "your_project_id", "prompt": "Create a welcome email for new subscribers", "language": "en", "purpose": "welcome" }'
Email generation is asynchronous. The SDK’s generateAndWait handles polling automatically. For manual polling:
Node.js SDK
Copy
Ask AI
// generateAndWait already handles polling — but you can also poll manually:const { data } = await migma.emails.getGenerationStatus('conversation_id');if (data.status === 'completed') { console.log('HTML:', data.result.html);}
JavaScript
Copy
Ask AI
async function waitForGeneration(conversationId) { while (true) { const response = await fetch( `https://api.migma.ai/v1/projects/emails/${conversationId}/status`, { headers: { 'Authorization': 'Bearer YOUR_API_KEY' } } ); const data = await response.json(); const status = data.data.status; if (status === 'completed') { console.log('Email generated successfully!'); console.log('HTML:', data.data.html); console.log('React:', data.data.react); return data.data; } else if (status === 'failed') { throw new Error(`Generation failed: ${data.data.error}`); } // Wait 2 seconds before next poll await new Promise(resolve => setTimeout(resolve, 2000)); }}
Better approach: Use the SDK’s generateAndWait or set up webhooks to get notified when generation completes.