# Update template account

**Endpoint**

`POST/v2/messages/templates/{id}`

**Link**

{% embed url="<https://stagep.tst-apidmndelss.com/openapi/v2.html#/operations/Messages_UpdateTemplate>" %}

### **Request**

#### **Path Parameters**

| Parameter | Type     | Description                | Required | Example       |
| --------- | -------- | -------------------------- | -------- | ------------- |
| **`id`**  | `string` | **Template ID** to update. | Yes      | `"tpl_12345"` |

#### **Headers**

| Key             | Value              | Required |
| --------------- | ------------------ | -------- |
| `Authorization` | `Bearer <JWT>`     | Yes      |
| `Content-Type`  | `application/json` | Yes      |
| `Accept`        | `application/json` | Yes      |

#### **Request Body (JSON)**

All fields are optional - only include the fields you want to update.

| Field          | Type      | Description & Requirements                                                                                                        | Required | Example                                       |
| -------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------- | -------- | --------------------------------------------- |
| **`typeId`**   | `integer` | <p><strong>Template type</strong>:<br>- <code>1</code>: Email<br>- <code>2</code>: SMS<br>- <code>3</code>: Push notification</p> | No       | `1`                                           |
| **`subject`**  | `string`  | **Email subject line** (required for email templates).                                                                            | No       | `"Updated Welcome Message!"`                  |
| **`title`**    | `string`  | **Message title/header**.                                                                                                         | No       | `"Account Verified"`                          |
| **`content`**  | `string`  | **Message body** with variable placeholders.                                                                                      | No       | `"Hello {{name}}, your account is verified!"` |
| **`button`**   | `string`  | **Button text** (for email templates).                                                                                            | No       | `"Access Dashboard"`                          |
| **`link`**     | `string`  | **Button URL** (for email templates).                                                                                             | No       | `"https://app.example.com/dashboard"`         |
| **`delay`**    | `string`  | **Delivery delay** after trigger (e.g., "5m", "2h").                                                                              | No       | `"10m"`                                       |
| **`isActive`** | `boolean` | **Template activation status**.                                                                                                   | No       | `true`                                        |
| **`showTime`** | `string`  | **Preferred sending time** (24-hour format).                                                                                      | No       | `"10:00"`                                     |
| **`triggers`** | `array`   | **Events that trigger this template** (see below).                                                                                | No       | -                                             |

**Trigger Object**

| Field         | Type      | Description                                      | Example |
| ------------- | --------- | ------------------------------------------------ | ------- |
| **`eventId`** | `integer` | **ID of the event** that triggers this template. | `101`   |

**Example Request Body (Partial Update):**

json

```
{
  "subject": "Updated Welcome Message",
  "content": "Hello {{customerName}}, welcome to our updated platform!",
  "isActive": true
}
```

**Example Request Body (Full Update):**

json

```
{
  "typeId": 1,
  "subject": "Password Reset Complete",
  "title": "Password Updated",
  "content": "Hello {{name}}, your password has been successfully reset.",
  "button": "Login Now",
  "link": "https://app.example.com/login",
  "delay": "0s",
  "isActive": true,
  "showTime": "09:00",
  "triggers": [
    {
      "eventId": 150
    }
  ]
}
```

***

### **Response (200 OK)**

Returns the updated template object with all current values.

#### **Response Fields**

| Field           | Type      | Description                          | Example                               |
| --------------- | --------- | ------------------------------------ | ------------------------------------- |
| **`id`**        | `string`  | Template ID (unchanged).             | `"tpl_12345"`                         |
| **`partnerId`** | `string`  | Partner ID (unchanged).              | `"ptn_67890"`                         |
| **`typeId`**    | `integer` | Updated template type.               | `1`                                   |
| **`subject`**   | `string`  | Updated subject.                     | `"Updated Welcome Message"`           |
| **`title`**     | `string`  | Updated title.                       | `"Account Verified"`                  |
| **`content`**   | `string`  | Updated content.                     | `"Hello {{name}}, welcome!"`          |
| **`button`**    | `string`  | Updated button text.                 | `"Access Dashboard"`                  |
| **`link`**      | `string`  | Updated link URL.                    | `"https://app.example.com/dashboard"` |
| **`updatedAt`** | `string`  | **New update timestamp**.            | `"2024-05-21T14:45:00Z"`              |
| **`createdAt`** | `string`  | Original creation timestamp.         | `"2024-01-15T10:00:00Z"`              |
| **`deletedAt`** | `string`  | Deletion timestamp (null if active). | `null`                                |
| **`delay`**     | `string`  | Updated delay.                       | `"10m"`                               |
| **`isActive`**  | `boolean` | Updated active status.               | `true`                                |
| **`showTime`**  | `string`  | Updated show time.                   | `"10:00"`                             |
| **`triggers`**  | `array`   | Updated trigger events.              | -                                     |

**Example Response:**

json

```
{
  "item": {
    "id": "tpl_12345",
    "partnerId": "ptn_67890",
    "typeId": 1,
    "subject": "Updated Welcome Message",
    "title": "Account Verified",
    "content": "Hello {{customerName}}, welcome to our updated platform!",
    "button": "Access Dashboard",
    "link": "https://app.example.com/dashboard",
    "updatedAt": "2024-05-21T14:45:00Z",
    "createdAt": "2024-01-15T10:00:00Z",
    "deletedAt": null,
    "delay": "10m",
    "isActive": true,
    "showTime": "10:00",
    "triggers": [
      {
        "eventId": 101,
        "templateId": 1,
        "event": {
          "id": 101,
          "Name": "customer.created",
          "variables": [
            {"name": "customerId"},
            {"name": "customerName"},
            {"name": "email"}
          ]
        }
      }
    ]
  }
}
```

***

### **Examples**

#### **Request**

bash

```
curl -X POST 'https://stagep.tst-apidmndelss.com/v2/messages/templates/tpl_12345' \
  -H 'Authorization: Bearer eyJhbGci...wNLGA' \
  -H 'Content-Type: application/json' \
  -d '{
    "content": "Hello {{name}}, we have improved our security features!",
    "isActive": true,
    "delay": "5m"
  }'
```

#### **Deactivate Template**

bash

```
curl -X POST 'https://stagep.tst-apidmndelss.com/v2/messages/templates/tpl_12345' \
  -H 'Authorization: Bearer eyJhbGci...wNLGA' \
  -H 'Content-Type: application/json' \
  -d '{
    "isActive": false
  }'
```

***

### **Error Responses**

1. **Template Not Found**:

   json

   ```
   { "error": "Template not found: tpl_99999" }
   ```
2. **Invalid Event ID**:

   json

   ```
   { "error": "Event ID 999 not found" }
   ```
3. **Validation Error**:

   json

   ```
   { "error": "Subject is required for email templates" }
   ```

***

### **Notes**

* **Partial Updates**: Only included fields are modified; omitted fields remain unchanged.
* **Variable Validation**: Content is validated against available event variables.
* **Immediate Effect**: Changes take effect immediately for new triggers.
* **Audit Trail**: `updatedAt` timestamp is automatically updated.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.delos.financial/messages/update-template-account.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
