> ## Documentation Index
> Fetch the complete documentation index at: https://docs.unosend.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Create Template

> Create a new email template.

**name** `string` *required*

A friendly name for the template.

**subject** `string` *required*

The email subject line. Supports variables like `{{variable}}`.

**html** `string`

The HTML body of the email. Supports variables.

**text** `string`

The plain text body of the email. Supports variables.

### Request

```bash cURL theme={null}
curl -X POST https://api.unosend.co/templates \
  -H "Authorization: Bearer un_xxxxxxxxxx" \
  -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>"
  }'
```

```javascript JavaScript theme={null}
await fetch('https://api.unosend.co/templates', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer un_xxxxxxxxxx',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    name: 'Welcome Email',
    subject: 'Welcome to {{company_name}}, {{first_name}}!',
    html: '<h1>Welcome, {{first_name}}!</h1><p>Thanks for joining {{company_name}}.</p>'
  })
});
```

```python Python theme={null}
import requests

requests.post('https://api.unosend.co/templates',
  headers={'Authorization': 'Bearer un_xxxxxxxxxx'},
  json={
    'name': 'Welcome Email',
    'subject': 'Welcome to {{company_name}}, {{first_name}}!',
    'html': '<h1>Welcome, {{first_name}}!</h1><p>Thanks for joining {{company_name}}.</p>'
  }
)
```

### Response

```json 201 theme={null}
{
  "success": true,
  "data": {
    "id": "tpl_abc123",
    "name": "Welcome Email",
    "subject": "Welcome to {{company_name}}, {{first_name}}!",
    "html": "<h1>Welcome, {{first_name}}!</h1><p>Thanks for joining {{company_name}}.</p>",
    "created_at": "2024-01-15T10:30:00.000Z"
  }
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.