AI template generation
Easy Email Pro includes a standalone API for creating a complete email template from source material. It is separate from the in-editor AI Agent: the API returns a full Easy Email Pro template, while the Agent applies targeted edits to the current template.
The recommended workflow is:
- Crawl a public brand website with
/v1/easy-email/crawl-brand. - Let the user review or edit the returned source text.
- Send the source and a campaign prompt to
/v1/easy-email/generate-template. - Load the returned
{ subject, content }object into the editor.
Crawl a website​
const response = await fetch(
"https://agent-api.beacas.com/v1/easy-email/crawl-brand",
{
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ url: "https://example.com/" }),
},
);
if (!response.ok) throw new Error(await response.text());
const { source } = await response.json();
The crawler collects brand metadata, copy, public links, theme colors, and exact image URL/alt pairs. It follows a small number of relevant public pages; it does not crawl private pages or analyze the contents of images.
Treat the returned source as editable reference material. The source is plain text/Markdown and does not need to have a fixed schema.
Generate a complete template​
const response = await fetch(
"https://agent-api.beacas.com/v1/easy-email/generate-template",
{
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({
prompt: [
"Create a complete product-promotion email.",
"Use a compact hero, a two-column feature grid, one CTA, and a concise footer.",
"Keep every feature card to one short sentence.",
].join(" "),
source,
}),
},
);
if (!response.ok) {
const error = await response.json();
throw new Error(error.message || "Template generation failed");
}
const template = await response.json();
// template.subject
// template.content — Easy Email Pro page data
The generation endpoint accepts:
| Field | Type | Description |
|---|---|---|
prompt | string | Campaign goal and layout direction. |
source | string | Brand/source material, usually the crawler's Markdown output. |
The response is a complete template, not an Agent event stream. It can be passed to the editor as the initial template or applied as a full-template replacement.
Error handling​
| Status | Meaning |
|---|---|
400 | Request JSON or required fields are invalid. |
413 | The website or source is too large to process. |
415 | The crawl target did not return HTML. |
422 | The model returned a template that still failed validation after retries. |
502 | The crawl target or AI provider could not be reached. |
See the AI Agent guide for streaming in-editor edits and tool calls.