import Migma from 'migma';
const migma = new Migma('YOUR_API_KEY');
const { data, error } = await migma.emails.importHtml({
projectId: 'PROJECT_ID',
html: '<html><body>Welcome</body></html>',
name: 'welcome.html',
instruction: 'Keep this exactly as-is'
});
// Poll /status or use importHtmlAndWait() to get result.emails[].curl --request POST \
--url https://api.migma.ai/v1/projects/emails/import-html \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"projectId": "<string>",
"html": "<string>",
"name": "<string>",
"htmls": [
{
"name": "<string>",
"source": "<string>"
}
],
"instruction": "<string>",
"languages": [
"<string>"
],
"visibility": "unlisted",
"generateMedia": true
}
'import requests
url = "https://api.migma.ai/v1/projects/emails/import-html"
payload = {
"projectId": "<string>",
"html": "<string>",
"name": "<string>",
"htmls": [
{
"name": "<string>",
"source": "<string>"
}
],
"instruction": "<string>",
"languages": ["<string>"],
"visibility": "unlisted",
"generateMedia": True
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.migma.ai/v1/projects/emails/import-html",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'projectId' => '<string>',
'html' => '<string>',
'name' => '<string>',
'htmls' => [
[
'name' => '<string>',
'source' => '<string>'
]
],
'instruction' => '<string>',
'languages' => [
'<string>'
],
'visibility' => 'unlisted',
'generateMedia' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.migma.ai/v1/projects/emails/import-html"
payload := strings.NewReader("{\n \"projectId\": \"<string>\",\n \"html\": \"<string>\",\n \"name\": \"<string>\",\n \"htmls\": [\n {\n \"name\": \"<string>\",\n \"source\": \"<string>\"\n }\n ],\n \"instruction\": \"<string>\",\n \"languages\": [\n \"<string>\"\n ],\n \"visibility\": \"unlisted\",\n \"generateMedia\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.migma.ai/v1/projects/emails/import-html")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"projectId\": \"<string>\",\n \"html\": \"<string>\",\n \"name\": \"<string>\",\n \"htmls\": [\n {\n \"name\": \"<string>\",\n \"source\": \"<string>\"\n }\n ],\n \"instruction\": \"<string>\",\n \"languages\": [\n \"<string>\"\n ],\n \"visibility\": \"unlisted\",\n \"generateMedia\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.migma.ai/v1/projects/emails/import-html")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"projectId\": \"<string>\",\n \"html\": \"<string>\",\n \"name\": \"<string>\",\n \"htmls\": [\n {\n \"name\": \"<string>\",\n \"source\": \"<string>\"\n }\n ],\n \"instruction\": \"<string>\",\n \"languages\": [\n \"<string>\"\n ],\n \"visibility\": \"unlisted\",\n \"generateMedia\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"conversationId": "<string>",
"status": "pending",
"message": "<string>",
"link": "<string>",
"count": 123,
"referenceId": "<string>"
},
"error": "<string>"
}{
"success": false,
"error": "<string>",
"code": "<string>",
"data": {}
}{
"success": false,
"error": "<string>",
"code": "<string>",
"data": {}
}{
"success": false,
"error": "<string>",
"code": "<string>",
"data": {}
}Import HTML Email (Async)
Convert existing HTML or .eml into editable Migma emails using the same HTML to Email path as Create. Requires API key with email:write. Provide html for one file or htmls (1-12). Optional instruction describes keep-as-is vs apply-brand. Returns immediately with a conversationId and pending status. Use GET /v1/projects/emails//status to retrieve production HTML, screenshots, and per-email IDs. Do not send HTML to generate.
import Migma from 'migma';
const migma = new Migma('YOUR_API_KEY');
const { data, error } = await migma.emails.importHtml({
projectId: 'PROJECT_ID',
html: '<html><body>Welcome</body></html>',
name: 'welcome.html',
instruction: 'Keep this exactly as-is'
});
// Poll /status or use importHtmlAndWait() to get result.emails[].curl --request POST \
--url https://api.migma.ai/v1/projects/emails/import-html \
--header 'Authorization: <api-key>' \
--header 'Content-Type: application/json' \
--data '
{
"projectId": "<string>",
"html": "<string>",
"name": "<string>",
"htmls": [
{
"name": "<string>",
"source": "<string>"
}
],
"instruction": "<string>",
"languages": [
"<string>"
],
"visibility": "unlisted",
"generateMedia": true
}
'import requests
url = "https://api.migma.ai/v1/projects/emails/import-html"
payload = {
"projectId": "<string>",
"html": "<string>",
"name": "<string>",
"htmls": [
{
"name": "<string>",
"source": "<string>"
}
],
"instruction": "<string>",
"languages": ["<string>"],
"visibility": "unlisted",
"generateMedia": True
}
headers = {
"Authorization": "<api-key>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.migma.ai/v1/projects/emails/import-html",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'projectId' => '<string>',
'html' => '<string>',
'name' => '<string>',
'htmls' => [
[
'name' => '<string>',
'source' => '<string>'
]
],
'instruction' => '<string>',
'languages' => [
'<string>'
],
'visibility' => 'unlisted',
'generateMedia' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: <api-key>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.migma.ai/v1/projects/emails/import-html"
payload := strings.NewReader("{\n \"projectId\": \"<string>\",\n \"html\": \"<string>\",\n \"name\": \"<string>\",\n \"htmls\": [\n {\n \"name\": \"<string>\",\n \"source\": \"<string>\"\n }\n ],\n \"instruction\": \"<string>\",\n \"languages\": [\n \"<string>\"\n ],\n \"visibility\": \"unlisted\",\n \"generateMedia\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.migma.ai/v1/projects/emails/import-html")
.header("Authorization", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"projectId\": \"<string>\",\n \"html\": \"<string>\",\n \"name\": \"<string>\",\n \"htmls\": [\n {\n \"name\": \"<string>\",\n \"source\": \"<string>\"\n }\n ],\n \"instruction\": \"<string>\",\n \"languages\": [\n \"<string>\"\n ],\n \"visibility\": \"unlisted\",\n \"generateMedia\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.migma.ai/v1/projects/emails/import-html")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"projectId\": \"<string>\",\n \"html\": \"<string>\",\n \"name\": \"<string>\",\n \"htmls\": [\n {\n \"name\": \"<string>\",\n \"source\": \"<string>\"\n }\n ],\n \"instruction\": \"<string>\",\n \"languages\": [\n \"<string>\"\n ],\n \"visibility\": \"unlisted\",\n \"generateMedia\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"conversationId": "<string>",
"status": "pending",
"message": "<string>",
"link": "<string>",
"count": 123,
"referenceId": "<string>"
},
"error": "<string>"
}{
"success": false,
"error": "<string>",
"code": "<string>",
"data": {}
}{
"success": false,
"error": "<string>",
"code": "<string>",
"data": {}
}{
"success": false,
"error": "<string>",
"code": "<string>",
"data": {}
}Authorizations
API key authentication. Use 'Authorization: Bearer YOUR_API_KEY' where YOUR_API_KEY is obtained from the Migma dashboard under Settings → Developers → API Keys.
Body
^[0-9a-fA-F]{24}$Single HTML or .eml source. Provide html or htmls, not both.
Filename for a single html paste.
200Multiple HTML or .eml files. One file becomes one canvas slot.
1 - 12 elementsShow child attributes
Show child attributes
Natural-language conversion instruction (keep as-is vs apply brand).
200005private, unlisted, public Generate AI media for missing images. Defaults to the project setting, then true.
Was this page helpful?