Email Generation API
Two endpoints handle AI-powered email generation, each suited for different use cases.
POST /api/generate
The primary email generation endpoint. Uses the full RAG pipeline for context-aware, high-quality kinetic email output.
Request
curl -X POST https://kinetic.email/api/generate \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Create a product showcase email with tabbed navigation for a shoe brand",
"conversationHistory": []
}'
| Field | Type | Required | Description |
|---|---|---|---|
prompt | string | Yes | Email generation prompt |
conversationHistory | array | No | Previous messages for multi-turn context |
Response
{
"success": true,
"html": "<!DOCTYPE html>...",
"ampHtml": "<!doctype html><html ⚡4email>...",
"blueprint": { "subject": "...", "design": { "colors": {...} }, "sections": [...] },
"usage": {
"input_tokens": 15234,
"output_tokens": 4521
},
"ragContext": {
"codeExamples": 4,
"knowledgeArticles": 3
}
}
ampHtml and blueprint are included when generateAmp: true is passed in the request.
How It Works
- Auth & tokens — Verifies user JWT, deducts
ai_generationtokens - Structured prompt assembly — Combines Playground config tabs into a single prompt:
- Email Type, Kinetic Features, Color Scheme, RAG Model
- Brand Style Guide (colors, fonts, tone, business context, logo)
- Uploaded images with names and descriptions
- Saved sections marked for verbatim injection
- Technique extraction — Parses
**Kinetic Features:**from structured prompts - Dual RAG queries (parallel):
- Query A: Technique-filtered Pinecone search (topK=10)
- Query B: Broad unfiltered search (topK=15)
- Merge & deduplicate — Combines results, removes duplicates
- Re-rank — Claude Haiku selects best 7 results for diversity
- Content focus filtering — Blog results split by
contentFocus: kinetic builds getkinetic+generalblogs, AMP builds getamp+generalblogs - Blueprint generation — Claude Haiku generates a structural blueprint with finalized copy and design system. If brand design tokens exist, they are injected as constraints — Haiku uses them instead of picking new values. Uploaded images are assigned to sections. Saved sections are marked as locked.
- Design token override — After blueprint parse, brand design tokens are force-merged into the blueprint's
designobject as a safety net - Parallel generation — Claude Sonnet 4.6 generates kinetic HTML and (if requested) AMP4Email HTML simultaneously, both referencing the same blueprint. Saved sections are injected verbatim with positional instructions. Images are referenced with
<img>tags (kinetic) or<amp-img>(AMP). A "View in browser" link using{{VIB_URL}}is included at the top. - QA check — Validates output against kinetic email rules
Supported Techniques
| Technique | Description |
|---|---|
tabs | Radio button tabbed interfaces |
accordion | Checkbox expand/collapse sections |
carousel | Radio button image/content carousels |
survey | Progressive disclosure survey forms |
quiz | Interactive quizzes with reveal states |
menu | Hamburger menu overlays |
stepper | Multi-step wizard flows |
toggle | Simple on/off switches |
amp4email | AMP-powered interactive emails |
POST /api/generate-email
A simpler generation endpoint that calls Claude directly without the RAG pipeline. Faster but less context-aware.
Request
curl -X POST https://kinetic.email/api/generate-email \
-H "Authorization: Bearer <token>" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Create a simple tabbed email for a newsletter"
}'
Response
{
"success": true,
"html": "<!DOCTYPE html>...",
"usage": {
"input_tokens": 2100,
"output_tokens": 3800
}
}
When to Use Which
| Scenario | Endpoint |
|---|---|
| Production email generation | /api/generate (RAG pipeline) |
| Quick prototyping | /api/generate-email (direct Claude) |
| Complex kinetic techniques | /api/generate (has technique examples) |
| Simple static emails | /api/generate-email (faster) |