AI Endpoints
Summarize emails, ask questions about your event data, and AI-personalize content per recipient.
Provider
By default, Mailgrid uses Workers AI (Llama 3.1 8B) — no extra setup, included on every plan. If ANTHROPIC_API_KEY is set as a secret, the AI layer falls back to Claude Haiku for higher-quality output.
Summarize
POST /api/ai/summarize
Scopes: ai:use
{
"html": "<p>Long body text...</p>"
// OR
"text": "Long body text..."
}{
"summary": "Customer wants a refund for last week's invoice ...",
"tldr": "Refund request, invoice INV-204"
}Ask AI
POST /api/ai/ask
Natural-language queries over your tenant's event data + knowledge base.
{
"question": "Which campaigns had the highest open rate this month?",
"contextDays": 30
}Personalize
POST /api/ai/personalize
Rewrites a subject + body for a specific recipient using their contact metadata + the requested tone.
{
"recipientEmail": "anna@acme.com",
"subject": "New feature shipped",
"html": "<p>We launched X...</p>"
}Knowledge Base
Bonus context that Mailgrid feeds to the AI layer:
POST /api/knowledge— add an entry{ title, content, tags? }GET /api/knowledge— listGET /api/knowledge/:id— get oneDELETE /api/knowledge/:id— remove
Entries are auto-injected as context for both ai/ask and templates/generate.