Design schema
RenderingDesign schema
A design is a versioned JSON document, validate it, migrate it, render it.
The shape: a body with rows; each row has columns; each column holds a list of blocks. A block carries a type and its values.
ts
import { validateDesign, migrateDesign } from "email-craft-sdk";
const design = validateDesign(json); // throws on an invalid design
const current = migrateDesign(json); // upgrade an older schema versionExisting Unlayer designs convert to this schema automatically when you loadDesign them.
validateDesign or migrateDesign
validateDesignonly accepts a design already atschema_version: "2.0". Use it on designs your own code produced.migrateDesigntakes anything stored earlier: a design with no version, an older version, or Unlayer's numericschemaVersion. It upgrades it, renames old camelCase keys such ascontentWidthto snake_case, then validates. A 2.0 design is only validated, so calling it every time is safe.- Both throw a Zod error when the design does not fit.
Rules that often fail
body.content_widthmust be a number from 320 to 1200."600px"fails on a 2.0 design.- Rows, columns and blocks each need an
id. Every row needs at least one column, and a column'swidthis 0 to 100. - A block's
typemust be one of the 20 known types, such asheading,text,raw-html,navigationorcustom, and it needs avaluesobject. - The result is a parsed copy: keys the schema does not know are left out of it.
Each level is described on the design object and block object pages.