API5 min read•Audience: Developers
Programmatic Templates
Manage templates via API: fetching template structures, cloning projects, and syncing template revisions.
Key Takeaways
- Retrieve complete project ASTs using GET /api/v1/projects/:id.
- Inspect JSON AST, compiled HTML, and current version numbers programmatically.
- Automate template backups and synchronization with your internal CMS.
GET /api/v1/projects/:id#
Fetches full project details:
code
bash
Returns the project's metadata, raw JSON AST, and published HTML.
Automating Template Synchronization#
You can automate template governance in CI/CD:
- Trigger a webhook or cron job to fetch template definitions from PostBrix.
- Commit the JSON AST or compiled MJML into your internal Git repository for audit logging.
- Validate that marketing changes did not remove mandatory transactional fields (like
{{orderId}}).
Frequently Asked Questions
Can I create new templates programmatically via the API?
Yes. Use POST /api/v1/projects to initialize a new project with a valid JSON AST payload.
How do I know which version of a template was used to render an email?
Project objects include an updated_at timestamp and revision integer that increments on every save.