> ## 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.

<ParamField body="name" type="string" required>
  A friendly name for the template.
</ParamField>

<ParamField body="subject" type="string" required>
  The email subject line. Supports variables like `{{variable}}`.
</ParamField>

<ParamField body="html" type="string">
  The HTML body of the email. Supports variables.
</ParamField>

<ParamField body="text" type="string">
  The plain text body of the email. Supports variables.
</ParamField>

### Request

<CodeGroup>
  ```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>'
    }
  )
  ```
</CodeGroup>

### 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"
  }
}
```
