Command Palette

Search for a command to run...

API Reference

Templates

Create and manage reusable email templates with variables. Templates support HTML with variable substitution for dynamic content.

POST/v1/templates

Create a Template

Request Body

ParameterTypeRequiredDescription
namestringRequiredTemplate name
subjectstringRequiredEmail subject (supports variables)
htmlstringOptionalHTML content (supports variables)
textstringOptionalPlain text version
variablesstring[]OptionalList of variable names used in the template
cURL
curl -X POST https://www.unosend.co/api/v1/templates \
  -H "Authorization: Bearer un_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Welcome Email",
    "subject": "Welcome to {{company_name}}, {{first_name}}!",
    "html": "<h1>Welcome, {{first_name}}!</h1><p>Thanks for joining {{company_name}}.</p>",
    "text": "Welcome, {{first_name}}! Thanks for joining {{company_name}}.",
    "variables": ["company_name", "first_name"]
  }'

Response

201 Created
{
  "id": "550e8400-e29b-41d4-a716-446655440000",
  "name": "Welcome Email",
  "subject": "Welcome to {{company_name}}, {{first_name}}!",
  "html": "<h1>Welcome, {{first_name}}!</h1><p>Thanks for joining {{company_name}}.</p>",
  "text": "Welcome, {{first_name}}! Thanks for joining {{company_name}}.",
  "variables": ["company_name", "first_name"],
  "created_at": "2024-01-15T10:30:00.000Z"
}

Variable Syntax

Use double curly braces for variables in your templates:

Template Example
<h1>Hello, {{first_name}}!</h1>
<p>Your order #{{order_id}} has been shipped.</p>
<p>Track it here: <a href="{{tracking_url}}">Track Order</a></p>
GET/v1/templates

List Templates

cURL
curl https://www.unosend.co/api/v1/templates \
  -H "Authorization: Bearer un_your_api_key"

Response

200 OK
{
  "data": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "name": "Welcome Email",
      "subject": "Welcome to {{company_name}}, {{first_name}}!",
      "html": "<h1>Welcome, {{first_name}}!</h1>...",
      "text": "Welcome, {{first_name}}!...",
      "variables": ["company_name", "first_name"],
      "created_at": "2024-01-15T10:30:00.000Z",
      "updated_at": "2024-01-15T10:30:00.000Z"
    }
  ]
}

Send Email with Template

Use the template_id parameter when sending emails:

cURL
curl -X POST https://www.unosend.co/api/v1/emails \
  -H "Authorization: Bearer un_your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "from": "hello@yourdomain.com",
    "to": ["user@example.com"],
    "template_id": "550e8400-e29b-41d4-a716-446655440000",
    "template_data": {
      "first_name": "John",
      "company_name": "Acme Inc"
    }
  }'
DELETE/v1/templates/:id

Delete Template

cURL
curl -X DELETE https://www.unosend.co/api/v1/templates/550e8400-e29b-41d4-a716-446655440000 \
  -H "Authorization: Bearer un_your_api_key"