DocumentationAI assistant

AI assistant

Generate and improve email templates with AI from the editor or the /ai API.

The AI assistant helps you write and polish emails: it generates subjects and bodies from an instruction, builds a complete HTML template, and rewrites existing HTML to your directions. It lives in the template editor, backed by the /ai API.

What it can do

EndpointWhat it is for
POST /ai/generateGenerates text: subjects, a plain-text body or a general answer, depending on task
POST /ai/generate-templateBuilds a full template: subject, preheader and html
POST /ai/improveRewrites existing HTML following an instruction

All of them accept optional template context (templateId, versionId, locale, description, current subject and variables) so the result fits your design.

Model

By default it uses Gemini 2.0 Flash (google/gemini-2.0-flash-001), a fast, cheap model. You can force another model per request with the model field; an admin can also set the default model globally.

From the editor to production

  1. Generate or improve

    From the editor, ask the assistant for a subject, a body or a full template. Or send HTML to /ai/improve with an instruction ("make it shorter", "formal tone").

  2. Review and edit

    The result is a starting point. Refine it in the Monaco/Unlayer editor — see Create and edit templates.

  3. Publish

    Save and publish a version. Only PUBLISHED versions can be sent — see Publish workflow.

API details

Request bodies, responses, the token hard block (402) and the rate limit are in AI generation API.