Skip to main content

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": []
}'
FieldTypeRequiredDescription
promptstringYesEmail generation prompt
conversationHistoryarrayNoPrevious messages for multi-turn context

Response

{
"success": true,
"html": "<!DOCTYPE html>...",
"usage": {
"input_tokens": 15234,
"output_tokens": 4521
},
"ragContext": {
"codeExamples": 4,
"knowledgeArticles": 3
}
}

How It Works

  1. Auth & tokens — Verifies user JWT, deducts ai_generation tokens
  2. Technique extraction — Parses **Kinetic Features:** from structured prompts
  3. Dual RAG queries (parallel):
    • Query A: Technique-filtered Pinecone search (topK=10)
    • Query B: Broad unfiltered search (topK=15)
  4. Merge & deduplicate — Combines results, removes duplicates
  5. Re-rank — Claude Haiku selects best 7 results for diversity
  6. Generate — Claude Sonnet generates HTML using RAG context
  7. QA check — Validates output against kinetic email rules

Supported Techniques

TechniqueDescription
tabsRadio button tabbed interfaces
accordionCheckbox expand/collapse sections
carouselRadio button image/content carousels
surveyProgressive disclosure survey forms
quizInteractive quizzes with reveal states
menuHamburger menu overlays
stepperMulti-step wizard flows
toggleSimple on/off switches
amp4emailAMP-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

ScenarioEndpoint
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)