Skip to main content

Admin API Endpoints

All admin endpoints require verifyAdmin() authentication — the user must have a valid JWT and their email must exist in the admin_users table.

RAG Content Management

POST /api/admin/submit-content

Upload new content to the Pinecone RAG knowledge base.

{
"title": "Product Showcase with Tabs",
"content": "<!DOCTYPE html>...",
"type": "html",
"technique": "tabs",
"complexity": "intermediate",
"emailPurpose": "ecommerce",
"bestPracticeTags": ["responsive", "accessible"]
}
FieldTypeRequiredDescription
titlestringYesContent title
contentstringYesHTML, markdown, or AMP content
typestringYeshtml, blog, or amp4email
techniquestringYesKinetic technique (tabs, carousel, etc.)
complexitystringNobeginner, intermediate, advanced
emailPurposestringNoecommerce, newsletter, transactional
bestPracticeTagsstring[]NoTags for categorization

The endpoint:

  1. Generates embeddings using OpenAI (both 1536-dim and 3072-dim models)
  2. Injects technique-specific semantic descriptions into embedding text
  3. Stores vectors in both Pinecone indexes
  4. Returns the content ID for future reference

POST /api/admin/update-content

Update existing RAG content. Same fields as submit, plus id.

POST /api/admin/delete-content

{
"id": "content-uuid"
}

Removes from both Pinecone indexes.

GET /api/admin/list-content

Browse uploaded content with optional filtering.

GET /api/admin/list-content?technique=tabs&type=html&page=1&limit=20

GET /api/admin/rag-stats

Returns statistics about the RAG knowledge base:

{
"totalItems": 156,
"byTechnique": {
"tabs": 42,
"carousel": 28,
"survey": 18,
"accordion": 15,
"quiz": 12,
"menu": 10,
"stepper": 8,
"toggle": 5,
"amp4email": 18
},
"byType": {
"html": 98,
"blog": 42,
"amp4email": 16
}
}

QA Evaluations

POST /api/admin/run-evaluation

Run QA checks against generated email HTML.

{
"html": "<!DOCTYPE html>...",
"technique": "tabs",
"prompt": "Original prompt used"
}

Returns a detailed QA score with individual check results.

POST /api/admin/submit-evaluation

Save evaluation results for tracking quality over time.

GET /api/admin/list-evaluations

Retrieve past evaluation results.


Utilities

POST /api/admin/auto-tag

Uses Claude to automatically generate metadata tags for content:

{
"content": "<!DOCTYPE html>...",
"type": "html"
}

Returns:

{
"technique": "tabs",
"complexity": "intermediate",
"emailPurpose": "ecommerce",
"features": ["responsive", "tracking", "fallback"],
"bestPracticeTags": ["accessible", "outlook-compatible"]
}

POST /api/admin/submit-feedback

Collect feedback on generated emails:

{
"emailId": "...",
"rating": 4,
"feedback": "Good output but needs better fallback for Outlook"
}