Templates
The Templates API allows you to manage reusable email templates.
Base URL
https://api.unsent.dev/v1/templatesFeatures
Reusable Content
Create templates with HTML and Text content
Easy Creation
Design and save email layouts
Updates
Modify existing templates easily
Overview
The Templates API allows you to create, manage, and reuse email templates. Templates define the subject, HTML content, and text content for emails, enabling consistent branding and reducing repetitive work. Templates can be used with the Send Email endpoint by specifying a templateId.
Quick Start
List Templates
Retrieve all email templates for your team.
curl -X GET https://api.unsent.dev/v1/templates \
-H "Authorization: Bearer your-api-key"Example Response:
[
{
"id": "tmpl_abc123",
"name": "Welcome Email",
"subject": "Welcome to Our Service!",
"html": "<html><body><h1>Welcome {{name}}!</h1></body></html>",
"content": "Welcome {{name}}!",
"teamId": "team_xyz789",
"createdAt": "2026-01-05T10:00:00.000Z",
"updatedAt": "2026-01-05T10:00:00.000Z"
},
{
"id": "tmpl_def456",
"name": "Newsletter",
"subject": "This Week's Updates",
"html": "<html><body><h2>News</h2><p>{{content}}</p></body></html>",
"content": null,
"teamId": "team_xyz789",
"createdAt": "2026-01-04T15:30:00.000Z",
"updatedAt": "2026-01-05T09:20:00.000Z"
}
][!NOTE] Templates are returned in descending order by creation date (newest first).
Create a Template
Create a new email template with reusable content.
curl -X POST https://api.unsent.dev/v1/templates \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"name": "Welcome Email",
"subject": "Welcome to our service!",
"html": "<html><body><h1>Welcome {{name}}!</h1><p>We are excited to have you.</p></body></html>",
"content": "Welcome {{name}}! We are excited to have you."
}'Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Template name for identification (min: 1 character) |
subject | string | Yes | Email subject line (Required) |
html | string | No | HTML version of the email content |
content | string | No | Plain text version of the email content |
Example Response:
{
"id": "tmpl_new123"
}[!TIP] Use variables like
{{name}}or{{company}}in your templates. These can be replaced with actual values when sending emails.
Get a Template
Retrieve details of a specific template by ID.
curl -X GET https://api.unsent.dev/v1/templates/tmpl_abc123 \
-H "Authorization: Bearer your-api-key"Example Response:
{
"id": "tmpl_abc123",
"name": "Welcome Email",
"subject": "Welcome to Our Service!",
"html": "<html><body><h1>Welcome {{name}}!</h1></body></html>",
"content": "Welcome {{name}}!",
"teamId": "team_xyz789",
"createdAt": "2026-01-05T10:00:00.000Z",
"updatedAt": "2026-01-05T10:00:00.000Z"
}Error Response (404):
{
"code": "NOT_FOUND",
"message": "Template not found"
}Update a Template
Update an existing template. All fields are optional—only include the fields you want to change.
curl -X PATCH https://api.unsent.dev/v1/templates/tmpl_abc123 \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"subject": "Welcome to Our Amazing Service!",
"html": "<html><body><h1>Welcome {{name}}!</h1><p>Updated content here.</p></body></html>"
}'Request Body
| Field | Type | Required | Description |
|---|---|---|---|
name | string | No | Updated template name |
subject | string | No | Updated email subject |
html | string | No | Updated HTML content |
content | string | No | Updated text content |
Example Response:
{
"success": true
}Delete a Template
Permanently delete a template.
curl -X DELETE https://api.unsent.dev/v1/templates/tmpl_abc123 \
-H "Authorization: Bearer your-api-key"Example Response:
{
"success": true
}[!WARNING] Deleting a template is permanent and cannot be undone. Make sure you no longer need this template before deleting.
Response Schema
Template Object
| Field | Type | Description |
|---|---|---|
id | string | Unique template identifier |
name | string | Template name |
subject | string | Email subject line |
html | string | null | HTML email content (optional) |
content | string | null | Plain text email content (optional) |
teamId | string | Your team identifier |
createdAt | string | ISO 8601 timestamp of creation |
updatedAt | string | ISO 8601 timestamp of last update |
Using Templates with Emails
To send an email using a template, specify the templateId when calling the Send Email endpoint:
curl -X POST https://api.unsent.dev/v1/emails \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"from": "noreply@yourdomain.com",
"to": "user@example.com",
"templateId": "tmpl_abc123"
}'[!NOTE] When using
templateId, the template'ssubject,html, andcontentare used automatically. You can override these by explicitly providing them in the request.
Best Practices
Organize Templates
Use clear, descriptive names like "Welcome-New-User" or "Invoice-Reminder"
Test Before Use
Send test emails with your templates before using them in campaigns
Version Control
Keep track of template changes by updating them regularly