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

# Notifications Configuration

> Configure email and SMS notification templates and triggers

Set up automated notifications to members for events, renewals, and other activities.

## Capabilities

| Action             | ROLE\_CLIENT\_ADMIN | ROLE\_CLIENT\_USER |
| ------------------ | ------------------- | ------------------ |
| View templates     | ✅                   | ✅                  |
| Create templates   | ✅                   | ❌                  |
| Edit templates     | ✅                   | ❌                  |
| Configure triggers | ✅                   | ❌                  |
| Send test emails   | ✅                   | ❌                  |

## Features

### Notification Types

<CardGroup cols={2}>
  <Card title="Email Notifications" icon="envelope">
    Rich HTML emails with customizable templates
  </Card>

  <Card title="SMS Notifications" icon="message">
    Short text messages for urgent communications
  </Card>
</CardGroup>

#### Acceptance Criteria

##### Frontend

* [ ] Rich text editor for message body
* [ ] Live preview (desktop/mobile)
* [ ] Design customization panel
* [ ] Trigger configuration interface
* [ ] Send test email functionality

##### Backend / API

* [ ] Backend behavior supports this feature as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] All business rules for this feature are enforced.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

### Template Builder

<Tabs>
  <Tab title="Content">
    * Subject line (email only)
    * Message body with rich text editor
    * Merge tags for personalization
    * Preview in desktop and mobile views
  </Tab>

  <Tab title="Design">
    * Background color
    * Header logo
    * Header image
    * Font selection
    * Footer banner
  </Tab>

  <Tab title="Settings">
    * Template name
    * Template type (email/SMS)
    * Active/inactive status
    * Trigger configuration
  </Tab>
</Tabs>

#### Acceptance Criteria

##### Frontend

* [ ] Template list with search and filter
* [ ] Drag-and-drop template builder
* [ ] Template duplication

##### Backend / API

* [ ] Backend behavior supports this feature as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] Template names must be unique
* [ ] Email templates require subject line
* [ ] SMS templates limited to 160 characters (or 306 for multi-part)
* [ ] At least one default template per trigger type
* [ ] Cannot delete template if it's the only one for a trigger

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

### Available Merge Tags

| Tag                      | Description         | Example                                     |
| ------------------------ | ------------------- | ------------------------------------------- |
| `{FirstName}`            | Member's first name | John                                        |
| `{LastName}`             | Member's last name  | Smith                                       |
| `{FullName}`             | Full name           | John Smith                                  |
| `{Email}`                | Email address       | [john@example.com](mailto:john@example.com) |
| `{MembershipPlan}`       | Current plan name   | Professional                                |
| `{MembershipExpiryDate}` | Expiry date         | 15 Jan 2026                                 |
| `{DOB}`                  | Date of birth       | 1 Mar 1985                                  |
| `{City}`                 | City                | Sydney                                      |
| `{State}`                | State               | NSW                                         |
| `{Country}`              | Country             | Australia                                   |

#### Acceptance Criteria

##### Frontend

* [ ] Merge tag insertion buttons

##### Backend / API

* [ ] Backend behavior supports this feature as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] Merge tags must be valid (invalid tags render empty)

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

### Notification Triggers

Configure when notifications are sent:

| Trigger            | Description           |
| ------------------ | --------------------- |
| Membership Renewal | X days before expiry  |
| Membership Expired | On expiry date        |
| Payment Failed     | On payment failure    |
| Payment Success    | On successful payment |
| Event Registration | On event signup       |
| Event Reminder     | X days before event   |
| Course Completion  | On course completion  |
| CPD Reminder       | When CPD is due       |
| Welcome            | On account creation   |

#### Acceptance Criteria

##### Frontend

* [ ] UI supports the workflows described in this feature.

##### Backend / API

* [ ] Backend behavior supports this feature as documented.

##### Permissions

* [ ] Access is restricted per the Capabilities matrix on this page (or equivalent role rules).

##### Business Rules

* [ ] All business rules for this feature are enforced.

##### Error Handling

* [ ] Error states return clear messages and appropriate HTTP status codes.

## Implementation Contracts

### Backend (API)

```
GET    /api/notifications/templates           # List templates
POST   /api/notifications/templates           # Create template
GET    /api/notifications/templates/{id}      # Get template
PUT    /api/notifications/templates/{id}      # Update template
DELETE /api/notifications/templates/{id}      # Delete template

POST   /api/notifications/templates/{id}/test # Send test
POST   /api/notifications/templates/{id}/duplicate # Clone

GET    /api/notifications/triggers            # List triggers
PUT    /api/notifications/triggers/{id}       # Update trigger

GET    /api/notifications/logs                # Sent notifications log
```

### Data Model

```typescript theme={null}
interface NotificationTemplate {
  id: string;
  name: string;
  type: 'email' | 'sms';
  
  // Content
  subject?: string;  // Email only
  body: string;
  
  // Design (email only)
  backgroundColor?: string;
  headerLogoUrl?: string;
  headerImageUrl?: string;
  fontFamily?: string;
  footerBannerUrl?: string;
  
  // System
  active: boolean;
  createdAt: string;
  updatedAt: string;
  lastSentAt?: string;
  sendCount: number;
}

interface NotificationTrigger {
  id: string;
  type: string;
  templateId: string;
  enabled: boolean;
  config: {
    daysBefore?: number;
    daysAfter?: number;
  };
}
```

### Error Handling

| Error             | HTTP Status | Message                                    |
| ----------------- | ----------- | ------------------------------------------ |
| Duplicate name    | 409         | "A template with this name already exists" |
| Missing subject   | 400         | "Email templates require a subject line"   |
| SMS too long      | 400         | "SMS message exceeds character limit"      |
| Invalid merge tag | 400         | "Invalid merge tag: {InvalidTag}"          |
