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

# Update Template

> Update an existing template with channel-specific configurations

## Header

<ParamField header="Authorization" type="string" required>
  Bearer token for API authentication. Format: `Bearer {{apiToken}}`
</ParamField>

## Query Parameters

<ParamField query="template_id" type="UUID" required>
  The ID of the template to update.
</ParamField>

```json Request Body theme={null}
{
   "name": <template_name>,
   "description": <description>,
   "tagNames": [
     <tagName>
   ],
   "variables": [
     {
       "name": <variable_name>,
       "defaultValue": <default_value>
     }
  ]
}

```

## Body Parameters

<ParamField body="name" type="string" required>
  Specifies the name of the template.
</ParamField>

<ParamField body="description" type="string">
  A brief description of the template.
</ParamField>

<ParamField body="tagNames" type="array">
  A list of tag names associated with the template.
</ParamField>

<ParamField body="variables" type="array">
  A list of variables used in the template.

  <ParamField type="object">
    <ParamField name="name" type="string">
      The name of the variable.
    </ParamField>

    <ParamField name="defaultValue" type="string">
      The default value for the variable.
    </ParamField>
  </ParamField>
</ParamField>

<ParamField body="configurations" type="object" required>
  Channel-specific configurations for the template.

  <ParamField name="SMS" type="object">
    <ParamField name="body" type="string">
      SMS message body text.
    </ParamField>

    <ParamField name="channel" type="string">
      "SMS" — channel type.
    </ParamField>

    <ParamField name="isFlash" type="boolean">
      Flash SMS flag.
    </ParamField>

    <ParamField name="isUnicode" type="boolean">
      Unicode support flag.
    </ParamField>
  </ParamField>

  <ParamField name="EMAIL" type="object">
    <ParamField name="subject" type="string">
      Email subject line.
    </ParamField>

    <ParamField name="channel" type="string">
      "EMAIL" — channel type.
    </ParamField>

    <ParamField name="body" type="string">
      Email body (HTML or plain text).
    </ParamField>

    <ParamField name="attachments" type="array">
      List of attachment references.
    </ParamField>

    <ParamField name="isRawHTML" type="boolean">
      `true` if `body` contains raw HTML.
    </ParamField>

    <ParamField name="isPlainText" type="boolean">
      `true` if `body` is plain text.
    </ParamField>
  </ParamField>
</ParamField>

<RequestExample>
  ```json Request Example theme={null}
  {
    "name": "Sample_Template1",
    "description": "sample template description",
    "tagNames": [
      "sample_tag_1",
      "sample_tag_2"
    ],
    "variables": [
      {
        "name": "var1",
        "defaultValue": "var1 value"
      }
    ],
    "configurations": {
      "SMS": {
        "body": "sample message body",
        "channel": "SMS",
        "isFlash": false,
        "isUnicode": false
      },
      "EMAIL": {
        "subject": "test email subject",
        "channel": "EMAIL",
        "body": "<p>test body</p>",
        "attachments": [],
        "isRawHTML": false,
        "isPlainText": false
      }
    }
  }
  ```
</RequestExample>

## Response

<ResponseField name="data" type="object">
  <ResponseField name="templateId" type="UUID">
    Template ID.
  </ResponseField>

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

  <ResponseField name="draftVersionId" type="UUID">
    Draft version ID.
  </ResponseField>

  <ResponseField name="channelTemplateList" type="array">
    List of channel-specific template metadata.

    <ResponseField type="object">
      <ResponseField name="id" type="UUID">
        Channel template ID.
      </ResponseField>

      <ResponseField name="channel" type="string">
        Channel name (e.g., "SMS", "EMAIL").
      </ResponseField>

      <ResponseField name="configuration" type="object">
        Embedded configuration object.

        <ResponseField name="channel" type="string">
          Channel name.
        </ResponseField>
      </ResponseField>

      <ResponseField name="templateVersionId" type="UUID">
        Template version ID.
      </ResponseField>
    </ResponseField>
  </ResponseField>
</ResponseField>

<ResponseField name="error" type="object">
  <ResponseField name="errorCode" type="string">
    The error code (e.g., `BAD_REQUEST`).
  </ResponseField>

  <ResponseField name="message" type="string">
    A human-readable error message.
  </ResponseField>
</ResponseField>

<ResponseExample>
  ```json success (200) theme={null}
  {
    "data": {
      "templateId": "UUID", // Template ID
      "templateName": "string", // Template name
      "draftVersionId": "UUID", // Draft version ID
      "channelTemplateList": [
        {
          "id": "UUID", // Channel template ID
          "channel": "string", // Channel type
          "configuration": {
            "channel": "string" // Channel type
          },
          "templateVersionId": "UUID" // Template version ID
        },
        {
          "id": "UUID",
          "channel": "string",
          "configuration": {
            "channel": "string"
          },
          "templateVersionId": "UUID"
        }
      ]
    },
    "error": null,
    "errors": null,
    "meta": null
  }
  ```

  ```json bad request (400) theme={null}
  {
    "data": null,
    "error": {
      "errorCode": "BAD_REQUEST",
      "message": "Bad request"
    },
    "errors": [
      {
        "errorCode": "BAD_REQUEST",
        "message": "Bad request"
      }
    ],
    "meta": null
  }
  ```
</ResponseExample>

## Status Codes

* `200` - OK
* `400` - BAD REQUEST
* `401` - UNAUTHORISED
* `404` - NOT FOUND
