Documentation Index
Fetch the complete documentation index at: https://docs.lettr.com/llms.txt
Use this file to discover all available pages before exploring further.
The client.templates resource manages Lettr-managed templates. To send a template, see Sending Emails → Send with a Template.
List Templates
const { data, error } = await client.templates.list({ project_id: 123, per_page: 20 });
if (!error) {
for (const template of data.templates) {
console.log(template.name, template.slug);
}
}
API Reference
GET /templates
Get a Template
const { data, error } = await client.templates.get("welcome-email");
// with a specific project:
await client.templates.get("welcome-email", 123);
if (!error) {
console.log(data.html);
console.log(data.active_version);
}
Create a Template
Provide html or json (the TOPOL.io editor format), not both:
const { data, error } = await client.templates.create({
name: "My Template",
html: "<html>...</html>",
project_id: 123, // optional
folder_id: 5, // optional
});
if (!error) {
console.log(data.id, data.slug, data.active_version);
}
API Reference
POST /templates
Update & Delete
await client.templates.update("my-template", { name: "Renamed" });
await client.templates.delete("my-template");
await client.templates.delete("my-template", 123); // within a project
Retrieve the variables a template expects — useful for validating data before sending:
const { data, error } = await client.templates.getMergeTags("welcome-email", {
project_id: 123, // optional
version: 2, // optional
});
if (!error) {
for (const tag of data.merge_tags) {
console.log(tag.key, tag.required, tag.type);
}
}
API Reference
GET /templates//merge-tags
What’s Next
Template Language
Merge tag syntax, conditionals, loops
lettr-kit CLI
Pull and sync templates locally