> For the complete documentation index, see [llms.txt](https://api.senderwiz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://api.senderwiz.com/customer/templates/create-a-template.md).

# Create a Template

### 🆕 Create a Template

This endpoint allows you to upload and save a new template either via direct HTML content or using a ZIP archive.

***

#### 🔹 HTTP Request

```http
POST API-URL/templates
```

***

#### 📝 POST Parameters

| Parameter  | Type  | Required | Description                               |
| ---------- | ----- | -------- | ----------------------------------------- |
| `template` | array | Yes      | An array containing the template details. |

**📦 Data Block (Required)**

| Parameter    | Type   | Required | Description                                               |
| ------------ | ------ | -------- | --------------------------------------------------------- |
| `name`       | string | Yes      | The template name.                                        |
| `content`    | string | Yes      | HTML content of the template.                             |
| `archive`    | string | No       | File content of a ZIP archive (alternative to `content`). |
| `inline_css` | Yes/No | No       | Enable or disable inline CSS (`yes` or `no`).             |

***

#### 🔐 Authorization Header

```
X-API-KEY: your-api-key-here
```

***

#### 💻 PHP Example

```php
// CREATE A NEW TEMPLATE
$rand = rand();
$response = $endpoint->create([
    'name'          => 'My API template ' . $rand,
    'content'       => file_get_contents(__DIR__ . '/template-example.html'),
    //'archive'     => file_get_contents(__DIR__ . '/template-example.zip'),
    'inline_css'    => 'no', // yes|no
]);

// DISPLAY RESPONSE
echo '<hr /><pre>';
print_r($response->body);
echo '</pre>';
```

***

#### 📦 Sample JSON Response

```json
{
  "status": "success",
  "template_uid": "tpl9847xyz123"
}
```
