Templated

Import HTML

Convert raw email HTML into an editable block-based document with AI.

Import HTML

The HTML import endpoint converts raw email HTML into a block-based craftState document, so imported emails become fully editable in the visual editor. Conversion is AI-powered and counts against your plan's monthly design-import allowance.

Convert HTML to blocks

curl -b cookies.txt -X POST \
  https://app.templated.email/api/convert-html \
  -H "Content-Type: application/json" \
  -d '{
    "accountSlug": "my-company",
    "html": "<html><body><h1>Hello</h1><p>Welcome aboard.</p></body></html>"
  }'

Note: unlike most endpoints, this one is not nested under /accounts/{slug} — the account is named in the body instead.

Request body

FieldTypeRequiredDescription
accountSlugstringYesAccount the conversion is billed against — you must be a member
htmlstringYesRaw HTML, max 500 KB

Response

{
  "craftState": { "ROOT": { "...": "..." } },
  "warnings": ["Unsupported <video> element was replaced with a fallback image"]
}

craftState is the parsed document object (see the Template Document Reference). To save it, serialize it to a string and pass it to the create template endpoint with source: "import". warnings lists anything the converter had to approximate.

Errors

StatusMeaning
400Missing accountSlug or html
413HTML exceeds 500 KB
422The converter could not produce a valid document from this HTML
429Burst rate limit, or monthly design-import allowance exhausted (code: IMPORT_LIMIT_MONTHLY — the response includes usage details and resetsAt)

Import limits

Conversions are metered per account per month (designImportsPerMonth, pooled across a parent account and its sub-accounts). The limit response tells you how many imports remain and when the meter resets.

Next steps

On this page