Schema6 min read•Audience: Developers
Template JSON Schema (AST)
Explore the abstract syntax tree (AST) used by PostBrix to represent emails: block types, attributes, styles, and children.
Key Takeaways
- PostBrix templates are represented as an array of EmailBlock objects.
- Each block has an id, type (e.g. mj-section, mj-column, mj-text), attributes, styles, and optional children.
- Enables deterministic programmatic generation and transformation of email designs.
The EmailBlock Interface#
In TypeScript:
code
typescript
Nesting and Validation Rules#
The AST strictly requires:
- Root blocks must be of type
mj-section. mj-sectionblocks may only containmj-columnchildren.mj-columnblocks contain leaf elements (mj-text,mj-image,mj-button,mj-spacer,mj-divider) or logic wrappers (logic-loop,logic-condition).- Content blocks cannot contain nested blocks.
Frequently Asked Questions
Can I generate PostBrix JSON ASTs using an AI agent or LLM?
Yes. Because the schema is fully typed and deterministic, LLMs can generate valid EmailBlock trees that open cleanly in the PostBrix visual editor.
What happens if an AST contains an unknown block type?
The rendering engine ignores unrecognized block types and logs a warning during compilation rather than crashing.