/v1/workspaces/{workspace_id}/templates/{name}/renderAuthRender a saved template against a data payload. Returns subject + html + text without sending.
Path parameters
workspace_id*string · uuidId of the workspace.
name*stringName of the template.
Request body
data*objectData to render into the template. Keys are your variable names and are kept exactly as sent.
Example: {"name":"Alice","order_id":"ord_123"}
Response · 200
subject*stringThe rendered subject line.
html*stringFully-rendered HTML body.
text*stringPlain-text body (derived if not authored).
Example
Request
POST https://api.mail.productcraft.co/v1/workspaces/{workspace_id}/templates/{name}/render
Authorization: Bearer YOUR_TOKEN
Content-Type: application/json
{
"data": {
"name": "Alice",
"order_id": "ord_123"
}
}import { Mail } from "@productcraft/mail";
// Reads PRODUCTCRAFT_API_KEY from the environment
const mail = new Mail();
const renderedMessage = await mail.templates.render("welcome", { data: { name: "Alice", order_id: "ord_123" } });mail.templates.render(name, params, options?): Mail.RenderedMessage
Response
{
"subject": "string",
"html": "string",
"text": "string"
}