Edit Templates in Beefree SDK with Claude AI
Overview
This recipe explains how to build an AI-powered partial design editing system that makes targeted modifications to existing email templates using Anthropic's Messages API, along with the Claude Sonnet 4 model, and integrates with Beefree SDK using both Simple Schema and the Content Services API.
This recipe covers:
Simple Schema: Understanding the template structure and unified schema for partial edits.
Anthropic API Integration: Structuring API calls for targeted template modifications.
Frontend Integration: Capturing end user edit requests and managing template state.
Response Parsing: Extracting and validating partial JSON edits from AI responses.
Beefree SDK Integration: Applying partial edits to existing templates and updating the builder.
Reference the complete code for this project in the partial-design-edits-concept folder inside the Simple Schema GitHub repository.
Prerequisites
Node.js
Beefree SDK credentials
Understanding of Beefree SDK's Simple Schema
Knowledge of Beefree SDK's Content Services API and
/simple-to-full-json endpoint
Core Concepts and Steps
This section details all of the core concepts required to integrate AI-powered partial design editing within Beefree SDK. It includes descriptions of each concept, sample code, and the complete implementation at the end, along with customization tips.
As a reminder, the complete code for this recipe is available for reference in GitHub.
The following video shows the final result, and how the code for this recipe looks when you run it locally on your machine.
The following diagram shows how these core concepts relate to one another to create the experience shown in the video above.

1. Simple Schema Structure for Partial Edits
Simple Schema is a simplified JSON format that makes it easy to generate email templates programmatically. It uses a hierarchical structure with templates, rows, columns, and modules. Understanding and using Simple Schema is critical for building AI-powered workflows, because it's simpler JSON makes it much easier for AI to read, understand, and build. Beefree SDK's full JSON is complex and feature-rich, making it difficult to train AI on.
For partial design edits, we work with existing templates and make targeted modifications to specific sections while preserving the overall structure.
Template Structure for Edits
The following code snippet shows the template structure for simple JSON that supports partial edits.
Supported Module Types for Edits
Simple Schema supports the following module types for partial edits:
title- Email titles and headingsparagraph- Text contentbutton- Call-to-action buttonsimage- Images and graphicsdivider- Visual separatorshtml- Custom HTML contentlist- Bulleted or numbered listsmenu- Menusicons- Social media and other icons
Edit Types and Contexts
The following code snippet shows how to define different types of edits with specific contexts.
2. Anthropic API Integration for Partial Edits
This section discusses how to structure and make API calls to Anthropic for generating targeted template modifications.
API Call Structure
The following code snippet shows an example API call to Anthropic for partial design edits.
Partial Edit Request
The following code snippet shows an example prompt for partial design edits.
Sample Response
The following code snippet shows an example response from Anthropic for partial edits.
3. Frontend Integration for Partial Edits
This section discusses the Frontend integration and how to capture an end user's edit requests, manage template state, and provide real-time preview of changes.
Capturing Edit Requests
The following code snippet shows how to capture user edit requests.
Processing Edit Requests
Template State Management
4. Response Parsing for Partial Edits
This section includes two important topics. The first is how to parse the response from Anthropic to extract the edit instructions. The second is how to apply these edits to the existing template structure.
Extracting Edit Instructions
The following code snippet shows how to parse edit instructions from Anthropic's response.
Applying Edits to Template
5. Beefree SDK Integration for Partial Edits
This section discusses the Beefree SDK integration for applying partial edits. Beefree SDK provides the editing environment to load the modified JSON into once the edits are applied. Once it is loaded within the editor, the end user can see the changes and continue customizing their email design.
Converting Modified Template to Full JSON
Loading Modified Template in Builder
Edit History and Undo Functionality
Complete Implementation
This section includes the code for both APIs together (Anthropic API call and /simple-to-full-json API call), and the dependencies they require.
Proxy Server (proxy-server.js)
Partial Edit Strategies
Content Updates
Purpose: Modify text content while preserving design
Context: Update the content while maintaining the existing design and structure
Key Elements:
Text modifications
Content replacement
Message updates
Call-to-action changes
Style Modifications
Purpose: Change colors, fonts, and styling
Context: Modify colors, fonts, and styling while keeping the content intact
Key Elements:
Color scheme updates
Font changes
Spacing adjustments
Visual enhancements
Layout Adjustments
Purpose: Modify structure and arrangement
Context: Adjust the layout and spacing while preserving the content and overall design
Key Elements:
Column adjustments
Row modifications
Spacing changes
Structure updates
Module Additions
Purpose: Add new content sections
Context: Add new modules or sections while maintaining the existing design consistency
Key Elements:
New sections
Additional modules
Content blocks
Interactive elements
Customization Tips
This section list a few customization tips you can apply to the code in your own environment.
Edit Types: Modify the
editTypesarray to support different types of modificationsValidation Rules: Add custom validation for specific edit types
Preview Functionality: Implement real-time preview of changes before applying
Batch Edits: Support multiple edits in a single request
Template Versioning: Implement version control for template modifications
User Experience: Add confirmation dialogs and progress indicators
Troubleshooting
If you encounter any errors, try troubleshooting the following:
Path Resolution: Ensure edit paths correctly reference template structure
Validation Errors: Check that modifications maintain schema compliance
State Management: Verify template state is properly maintained across edits
Performance: Optimize for large templates and complex modifications
This recipe provides a complete foundation for building AI-powered partial design editing systems with Beefree SDK and Anthropic's Messages API and Claude Sonnet 4 model.
Last updated
Was this helpful?

