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 lettr.templates() service manages Lettr-managed templates. To send a template, set templateSlug on CreateEmailOptions — see Sending Emails.
import com.lettr.Lettr;
import com.lettr.services.templates.model.*;
Lettr lettr = new Lettr("your-api-key");
List Templates
ListTemplatesResponse templates = lettr.templates().list();
// With pagination
ListTemplatesResponse page = lettr.templates().list(
ListTemplatesParams.builder()
.projectId(5)
.perPage(10)
.page(2)
.build()
);
API Reference
GET /templates
Get a Template
TemplateDetail template = lettr.templates().get("welcome-email");
System.out.println("Name: " + template.getName());
System.out.println("Active version: " + template.getActiveVersion());
// With a specific project
TemplateDetail scoped = lettr.templates().get("welcome-email", 5);
Create a Template
Provide html or json (the TOPOL.io editor format), not both:
CreateTemplateResponse response = lettr.templates().create(
CreateTemplateOptions.builder()
.name("Welcome Email")
.html("<p>Hello {{FIRST_NAME}}!</p>")
.projectId(5) // optional
.folderId(10) // optional
.build()
);
System.out.println("Slug: " + response.getSlug());
API Reference
POST /templates
Update & Delete
UpdateTemplateResponse updated = lettr.templates().update("welcome-email",
UpdateTemplateOptions.builder()
.html("<p>Hello {{FIRST_NAME}}, welcome aboard!</p>")
.build()
);
lettr.templates().delete("welcome-email");
lettr.templates().delete("welcome-email", 5); // within a project
Retrieve the variables a template expects — useful for validating data before sending:
GetMergeTagsResponse tags = lettr.templates().getMergeTags("welcome-email");
for (MergeTag tag : tags.getMergeTags()) {
System.out.println(tag.getKey() + " (required: " + tag.isRequired() + ")");
}
API Reference
GET /templates//merge-tags
What’s Next
Template Language
Merge tag syntax, conditionals, loops
Sending Emails
Send a template with substitution data