> For the complete documentation index, see [llms.txt](https://docs.delos.financial/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.delos.financial/messages/get-template-by-id.md).

# Get template by ID

Retrieves detailed information about a specific message template, including its content, configuration, and associated trigger events.

**Endpoint**

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

**Link**

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

### **Request**

#### **Path Parameters**

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

#### **Headers**

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

***

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

Returns the complete template object with all configuration details.

#### **Response Fields**

**Template Object**

| Field           | Type      | Description                                                                                                                       | Example                      |
| --------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------- | ---------------------------- |
| **`id`**        | `string`  | **Unique template identifier**.                                                                                                   | `"tpl_12345"`                |
| **`partnerId`** | `string`  | **Partner ID** that owns the template.                                                                                            | `"ptn_67890"`                |
| **`typeId`**    | `integer` | <p><strong>Template type</strong>:<br>- <code>1</code>: Email<br>- <code>2</code>: SMS<br>- <code>3</code>: Push notification</p> | `1`                          |
| **`subject`**   | `string`  | **Email subject line**.                                                                                                           | `"Welcome to Our Platform!"` |
| **`title`**     | `string`  | **Message title/header**.                                                                                                         | `"Account Created"`          |
| **`content`**   | `string`  | **Message body** with variables.                                                                                                  | `"Hello {{name}}, welcome!"` |
| **`button`**    | `string`  | **Button text** (for emails).                                                                                                     | `"Login Now"`                |
| **`link`**      | `string`  | **Button URL** (for emails).                                                                                                      | `"https://app.example.com"`  |
| **`updatedAt`** | `string`  | Last update timestamp (ISO 8601).                                                                                                 | `"2024-05-20T14:30:00Z"`     |
| **`createdAt`** | `string`  | Creation timestamp (ISO 8601).                                                                                                    | `"2024-01-15T10:00:00Z"`     |
| **`deletedAt`** | `string`  | Deletion timestamp (if soft-deleted).                                                                                             | `null`                       |
| **`delay`**     | `string`  | **Delivery delay** after trigger.                                                                                                 | `"5m"`                       |
| **`isActive`**  | `boolean` | **Template status**. `true` = active.                                                                                             | `true`                       |
| **`showTime`**  | `string`  | **Preferred sending time**.                                                                                                       | `"09:00"`                    |
| **`triggers`**  | `array`   | **Events that trigger this template**.                                                                                            | -                            |

**Trigger Object**

| Field            | Type      | Description                              | Example |
| ---------------- | --------- | ---------------------------------------- | ------- |
| **`eventId`**    | `integer` | **Event ID** that triggers the template. | `101`   |
| **`templateId`** | `integer` | **Template ID** reference.               | `1`     |
| **`event`**      | `object`  | **Event details** (see below).           | -       |

**Event Object**

| Field           | Type      | Description                             | Example              |
| --------------- | --------- | --------------------------------------- | -------------------- |
| **`id`**        | `integer` | **Event ID**.                           | `101`                |
| **`Name`**      | `string`  | **Event name**.                         | `"customer.created"` |
| **`variables`** | `array`   | **Available variables** for this event. | -                    |

**Variable Object**

| Field      | Type     | Description                         | Example          |
| ---------- | -------- | ----------------------------------- | ---------------- |
| **`name`** | `string` | **Variable name** for template use. | `"customerName"` |

**Example Response:**

json

```
{
  "item": {
    "id": "tpl_12345",
    "partnerId": "ptn_67890",
    "typeId": 1,
    "subject": "Welcome to Acme Payments!",
    "title": "Account Created Successfully",
    "content": "Hello {{customerName}}, your account has been created. Your customer ID is {{customerId}}.",
    "button": "Access Your Account",
    "link": "https://app.acme.com/login",
    "updatedAt": "2024-05-20T14:30:00Z",
    "createdAt": "2024-01-15T10:00:00Z",
    "deletedAt": null,
    "delay": "0s",
    "isActive": true,
    "showTime": "09:00",
    "triggers": [
      {
        "eventId": 101,
        "templateId": 1,
        "event": {
          "id": 101,
          "Name": "customer.created",
          "variables": [
            {"name": "customerId"},
            {"name": "customerName"},
            {"name": "email"}
          ]
        }
      }
    ]
  }
}
```

***

### **Examples**

#### **Request**

bash

```
curl -X GET 'https://stagep.tst-apidmndelss.com/v2/messages/templates/tpl_12345' \
  -H 'Authorization: Bearer eyJhbGci...wNLGA' \
  -H 'Accept: application/json'
```

#### **SMS Template Example**

**Response:**

json

```
{
  "item": {
    "id": "tpl_67890",
    "partnerId": "ptn_12345",
    "typeId": 2,
    "subject": "",
    "title": "Security Alert",
    "content": "Acme: Login detected from new device at {{location}}. Contact support if this wasn't you.",
    "button": "",
    "link": "",
    "updatedAt": "2024-05-18T16:20:00Z",
    "createdAt": "2024-02-10T11:30:00Z",
    "deletedAt": null,
    "delay": "0s",
    "isActive": true,
    "showTime": "00:00",
    "triggers": [
      {
        "eventId": 205,
        "templateId": 2,
        "event": {
          "id": 205,
          "Name": "security.login.unusual",
          "variables": [
            {"name": "deviceType"},
            {"name": "location"},
            {"name": "timestamp"}
          ]
        }
      }
    ]
  }
}
```

***

### **Error Responses**

1. **Template Not Found**:

   json

   ```
   { "error": "Template not found: tpl_99999" }
   ```
2. **Unauthorized**:

   json

   ```
   { "error": "Unauthorized" }
   ```

***

### **Notes**

* **Template Types**:
  * `1`: Email templates (include subject, button, link)
  * `2`: SMS templates (simplified structure)
  * `3`: Push notifications
* **Variable Usage**: Use `{{variableName}}` syntax in content to insert dynamic values.
* **Active Status**: Only templates with `isActive: true` will be triggered by events.
* **Soft Delete**: Templates may be soft-deleted (`deletedAt` not null) but still accessible for reference.

Real request:

```postman_json
Authorization: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjE2NCwiZXhwIjoxNzYxNTcxMjkyLCJrZXkiOiI1Y2ZiOGZjN2RmYjk4ZjVkYmIyZTgwNTVkZWFhN2U2Zjk4MzEyYmE3Iiwib3RwX3ZlcmlmaWVkIjpmYWxzZX0.Zu6m0G61S-1fLp32JUyJp-btyvxAi1NTLo7CrmuYwus
id*: io75SdrpdBSW
```

Real response:

```postman_json
{
  "item": {
    "id": "io75SdrpdBSW",
    "partnerId": "3354815d-1a23-4b1c-81ec-306388cddfa4",
    "typeId": 1,
    "subject": "Test",
    "title": "Test",
    "content": "TEst",
    "button": "Test",
    "link": "Test",
    "updatedAt": "2024-08-16T08:26:36Z",
    "createdAt": "2024-08-16T08:26:36Z",
    "deletedAt": "0001-01-01T00:00:00Z",
    "delay": null,
    "isActive": true,
    "showTime": null,
    "triggers": [
      {
        "eventId": 7,
        "templateId": 4,
        "event": {
          "id": 0,
          "Name": "",
          "variables": []
        }
      }
    ]
  }
}
```

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.delos.financial/messages/get-template-by-id.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
