Skip to main content

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 service manages Lettr-managed templates. To send a template, set the template on CreateEmailOptions — see Sending Emails.
use lettr::Lettr;
use lettr::templates::{ListTemplatesOptions, CreateTemplateOptions, UpdateTemplateOptions};

let client = Lettr::new("your-api-key");

List Templates

let response = client.templates.list(ListTemplatesOptions::new()).await?;
for template in &response.templates {
    println!("{}: {} (slug: {})", template.id, template.name, template.slug);
}

API Reference

GET /templates

Get a Template

let detail = client.templates.get("welcome-email", None).await?;
println!("Version: {:?}, has HTML: {}", detail.active_version, detail.html.is_some());

Create a Template

Provide HTML or JSON (the TOPOL.io editor format), not both:
let options = CreateTemplateOptions::new("Welcome Email")
    .with_html("<h1>Hello {{FIRST_NAME}}!</h1>")
    .with_project_id(5);

let result = client.templates.create(options).await?;
println!("Created: {} (slug: {})", result.name, result.slug);

API Reference

POST /templates

Update & Delete

Updating a template creates a new active version:
let options = UpdateTemplateOptions::new()
    .with_html("<h1>Hello {{NAME}}!</h1>");
let updated = client.templates.update("welcome-email", options).await?;
println!("Updated version: {}", updated.active_version);

client.templates.delete("welcome-email", None).await?;

Get Merge Tags

Retrieve the variables a template expects — useful for validating data before sending:
let tags = client.templates.get_merge_tags("welcome-email", None, None).await?;
for tag in &tags.merge_tags {
    println!("{}: required={}", tag.key, tag.required);
}

API Reference

GET /templates//merge-tags

What’s Next

Template Language

Merge tag syntax, conditionals, loops

Sending Emails

Send a template with substitution data