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, pass template_slug to client.emails.send() — see Sending Emails .
import lettr
client = lettr.Lettr( "lttr_your_api_key" )
List Templates
template_list = client.templates.list( per_page = 10 )
for template in template_list.templates:
print ( f " { template.name } ( { template.slug } )" )
API Reference GET /templates
Get a Template
template = client.templates.get( "welcome-email" )
print (template.html)
# Or fetch only the rendered HTML for a project
html = client.templates.get_html( project_id = 1 , slug = "welcome-email" )
Create a Template
Provide html or json (the TOPOL.io editor format), not both:
template = client.templates.create(
name = "Welcome Email" ,
html = "<h1>Hello {{ NAME }} !</h1><p>Welcome aboard.</p>" ,
project_id = 123 , # optional
folder_id = 5 , # optional
)
API Reference POST /templates
Update & Delete
Updating a template creates a new version:
client.templates.update(
"welcome-email" ,
html = "<h1>Hi {{ NAME }} !</h1><p>Updated content.</p>" ,
)
client.templates.delete( "welcome-email" )
client.templates.delete( "welcome-email" , project_id = 123 ) # within a project
Retrieve the variables a template expects — useful for validating data before sending:
merge_tags = client.templates.get_merge_tags( "welcome-email" )
for tag in merge_tags.merge_tags:
print ( f " { tag.key } (required: { tag.required } , type: { tag.type } )" )
API Reference GET /templates//merge-tags
What’s Next
Template Language Merge tag syntax, conditionals, loops
Sending Emails Send a template with substitution data