# Messaging Templates

**Base URL:** `https://api.welkinhealth.com/{tenantName}/{instanceName}/messaging-templates`

Messaging Templates define reusable message templates with dynamic variable substitution for SMS, email, and chat communications. Templates are configured in Welkin Designer and are read-only via the API.

***

## Get All Templates

**GET** `/messaging-templates`

Returns all message templates for the instance.

### Query Parameters

| Parameter | Type    | Required | Description                               |
| --------- | ------- | -------- | ----------------------------------------- |
| `channel` | string  | No       | Filter by channel: `SMS`, `EMAIL`, `CHAT` |
| `active`  | boolean | No       | Filter by active status                   |
| `page`    | integer | No       | Page number (default: 0)                  |
| `size`    | integer | No       | Page size (default: 20)                   |

### Example Request

```bash
curl -X GET "https://api.welkinhealth.com/acme/live/messaging-templates?channel=SMS" \
  -H "Authorization: Bearer {access_token}"
```

### Example Response

```json
[
  {
    "id": "tmpl_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "name": "appointment_reminder",
    "label": "Appointment Reminder",
    "channel": "SMS",
    "body": "Hi {{patientFirstName}}, reminder: appointment on {{appointmentDate}} at {{appointmentTime}} with {{providerName}}. Reply STOP to opt out.",
    "variables": ["patientFirstName", "appointmentDate", "appointmentTime", "providerName"],
    "active": true,
    "createdAt": "2026-01-15T00:00:00Z"
  }
]
```

***

## Get Template by Name

**GET** `/messaging-templates/{templateName}`

Returns a single template by its programmatic name.

### Path Parameters

| Parameter      | Type   | Required | Description                                                      |
| -------------- | ------ | -------- | ---------------------------------------------------------------- |
| `templateName` | string | Yes      | Programmatic name of the template (e.g., `appointment_reminder`) |

### Example Request

```bash
curl -X GET "https://api.welkinhealth.com/acme/live/messaging-templates/appointment_reminder" \
  -H "Authorization: Bearer {access_token}"
```

### Example Response

```json
{
  "id": "tmpl_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
  "name": "appointment_reminder",
  "label": "Appointment Reminder",
  "channel": "SMS",
  "body": "Hi {{patientFirstName}}, reminder: appointment on {{appointmentDate}} at {{appointmentTime}} with {{providerName}}. Reply STOP to opt out.",
  "variables": ["patientFirstName", "appointmentDate", "appointmentTime", "providerName"],
  "active": true,
  "createdAt": "2026-01-15T00:00:00Z"
}
```

***

## Template Variable Syntax

Variables in template bodies use double-curly-brace syntax: `{{variableName}}`

| Variable Source | Examples                                      |
| --------------- | --------------------------------------------- |
| Patient profile | `{{patientFirstName}}`, `{{patientLastName}}` |
| Program data    | `{{programName}}`, `{{phaseLabel}}`           |
| Calendar        | `{{appointmentDate}}`, `{{appointmentTime}}`  |
| Provider        | `{{providerName}}`, `{{providerPhone}}`       |

***

## Template Object

| Field       | Type     | Description                                         |
| ----------- | -------- | --------------------------------------------------- |
| `id`        | string   | Template UUID                                       |
| `name`      | string   | Programmatic name (used in Communication API calls) |
| `label`     | string   | Display label                                       |
| `channel`   | string   | `SMS`, `EMAIL`, or `CHAT`                           |
| `body`      | string   | Template body with `{{variable}}` placeholders      |
| `subject`   | string   | Email subject line (EMAIL channel only)             |
| `variables` | array    | List of variable names used in the template         |
| `active`    | boolean  | Whether template is active                          |
| `createdAt` | datetime | Creation timestamp                                  |


---

# 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.welkinhealth.com/developer-and-integration-guide/api-reference/messaging-templates.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.
