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

# Create Template

> Create a reusable email template with variable substitution.

## Headers

<ParamField header="Authorization" type="string" required>
  `Bearer YOUR_API_KEY`
</ParamField>

<ParamField header="Content-Type" type="string" required>
  `application/json`
</ParamField>

## Body

<ParamField body="name" type="string" required>
  Human-readable template name.
</ParamField>

<ParamField body="subject" type="string" required>
  Default subject line. Supports `{{variable}}` syntax.
</ParamField>

<ParamField body="html_content" type="string">
  HTML body with `{{variable}}` placeholders.
</ParamField>

<ParamField body="text_content" type="string">
  Plain text body with `{{variable}}` placeholders.
</ParamField>

<ParamField body="category" type="string" default="transactional">
  Template category. Values: `transactional`, `marketing`, `notification`, `welcome`, `custom`.
</ParamField>

## Response

<ResponseField name="id" type="string">
  Template ID — use this as `template_id` when sending emails.
</ResponseField>

<ResponseField name="name" type="string">Template name.</ResponseField>

<ResponseField name="subject" type="string">Default subject line.</ResponseField>

<ResponseField name="category" type="string">Template category.</ResponseField>

<ResponseField name="created_at" type="string">ISO 8601 creation timestamp.</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST https://api.usegately.com/api/v1/email/templates \
    -H "Authorization: Bearer gately_YOUR_API_KEY" \
    -H "Content-Type: application/json" \
    -d '{
      "name": "Welcome Email",
      "subject": "Welcome to {{project}}, {{name}}!",
      "html_content": "<h1>Hi {{name}},</h1><p>Welcome to <strong>{{project}}</strong>. Get started at <a href=\"{{url}}\">{{url}}</a>.</p>",
      "text_content": "Hi {{name}}, welcome to {{project}}. Get started at {{url}}.",
      "category": "welcome"
    }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://api.usegately.com/api/v1/email/templates', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer gately_YOUR_API_KEY',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      name: 'Welcome Email',
      subject: 'Welcome to {{project}}, {{name}}!',
      html_content: '<h1>Hi {{name}},</h1><p>Welcome to <strong>{{project}}</strong>.</p>',
      text_content: 'Hi {{name}}, welcome to {{project}}.',
      category: 'welcome',
    }),
  });

  const template = await response.json();
  ```

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

  response = requests.post(
      'https://api.usegately.com/api/v1/email/templates',
      headers={
          'Authorization': 'Bearer gately_YOUR_API_KEY',
          'Content-Type': 'application/json',
      },
      json={
          'name': 'Welcome Email',
          'subject': 'Welcome to {{project}}, {{name}}!',
          'html_content': '<h1>Hi {{name}},</h1>',
          'category': 'welcome',
      }
  )

  print(response.json())
  ```
</RequestExample>

<ResponseExample>
  ```json Success theme={null}
  {
    "id": "tmpl_abc123",
    "name": "Welcome Email",
    "subject": "Welcome to {{project}}, {{name}}!",
    "category": "welcome",
    "created_at": "2026-08-02T10:00:00Z"
  }
  ```

  ```json Validation error (400) theme={null}
  {
    "error": "name and subject are required"
  }
  ```

  ```json Unauthorized (401) theme={null}
  {
    "error": "Invalid or missing API key"
  }
  ```
</ResponseExample>
