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

# Create Communication Template

> Create a new communication template metadata record.

## Method

`POST` `/v1/comms/templates`

## Body Parameters

<ParamField name="name" type="string" required>Human-readable template name.</ParamField>
<ParamField name="key" type="string" required>Unique key used when resolving the template (must be unique per workspace).</ParamField>
<ParamField name="channel" type="string" required>Delivery channel (`email`, `sms`, `whatsapp`, `push_notification`, etc.).</ParamField>
<ParamField name="purpose" type="string">Template purpose (`transactional` or `marketing`). Defaults to `transactional`.</ParamField>
<ParamField name="status" type="string">Initial status (`draft`, `active`, `inactive`, or `archived`). Defaults to `draft`.</ParamField>

## Headers

<ParamField header="Authorization" type="string">Bearer token (requires `comms:write`).</ParamField>
<ParamField header="content-type" type="string">`application/json`</ParamField>

## Request Example

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST "https://api.voyantcloud.com/v1/comms/templates" \
    -H "Authorization: Bearer $VOYANT_API_KEY" \
    -H "content-type: application/json" \
    -d '{
      "name": "Booking Confirmation",
      "key": "booking_confirmation",
      "channel": "email",
      "purpose": "transactional",
      "status": "active"
    }'
  ```

  ```javascript Node.js theme={null}
  const res = await fetch("https://api.voyantcloud.com/v1/comms/templates", {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.VOYANT_API_KEY}`,
      "content-type": "application/json",
    },
    body: JSON.stringify({
      name: "Payment Reminder",
      key: "payment_reminder",
      channel: "sms"
    }),
  })
  const template = await res.json()
  ```

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

  payload = {
    "name": "WhatsApp Campaign",
    "key": "promo_whatsapp_march",
    "channel": "whatsapp",
    "purpose": "marketing"
  }

  resp = requests.post(
    "https://api.voyantcloud.com/v1/comms/templates",
    headers={
      "Authorization": f"Bearer {os.environ['VOYANT_API_KEY']}",
      "content-type": "application/json",
    },
    json=payload,
  )
  created = resp.json()
  ```
</RequestExample>

## Response Fields

* `id` – Template ID.
* `workspace_id` – Workspace owning the template.
* `name`, `key`, `channel`, `purpose`, `status` – Echoed metadata.
* `created_at`, `updated_at` – ISO timestamps.

## Response Example

<ResponseExample>
  ```json 201 Created theme={null}
  {
    "id": "tmpl_01J0CBFPXW7SP2N8A9Q7T2048Q",
    "workspace_id": "ws_01HZYPM2QF2R8X9SZQ0J9SYBCN",
    "name": "Booking Confirmation",
    "key": "booking_confirmation",
    "channel": "email",
    "purpose": "transactional",
    "status": "active",
    "created_at": "2025-01-08T10:22:31.000Z",
    "updated_at": "2025-01-08T10:22:31.000Z"
  }
  ```
</ResponseExample>

<Warning>
  Duplicate keys return `409` with error code `TEMPLATES_DUPLICATE`. Choose a unique `key` per workspace.
</Warning>
